Skip to content
This repository was archived by the owner on Dec 24, 2022. It is now read-only.

Commit 2977f7c

Browse files
committed
Ensure BeforeExecFilter is called in ExecLongScalarAsync
1 parent 56498ea commit 2977f7c

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

src/ServiceStack.OrmLite/Async/OrmLiteResultsFilterExtensionsAsync.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,11 @@ public static Task<int> ExecNonQueryAsync(this IDbCommand dbCmd, string sql, Dic
5454

5555
public static Task<int> ExecNonQueryAsync(this IDbCommand dbCmd, CancellationToken token = default)
5656
{
57+
OrmLiteConfig.BeforeExecFilter?.Invoke(dbCmd);
58+
5759
if (OrmLiteConfig.ResultsFilter != null)
5860
return OrmLiteConfig.ResultsFilter.ExecuteSql(dbCmd).InTask();
5961

60-
OrmLiteConfig.BeforeExecFilter?.Invoke(dbCmd);
61-
6262
if (Log.IsDebugEnabled)
6363
Log.DebugCommand(dbCmd);
6464

@@ -213,14 +213,19 @@ public static Task<object> ScalarAsync(this IDbCommand dbCmd, string sql, Cancel
213213

214214
public static Task<long> ExecLongScalarAsync(this IDbCommand dbCmd)
215215
{
216-
return dbCmd.ExecLongScalarAsync(null, default(CancellationToken));
216+
return dbCmd.ExecLongScalarAsync(null, default);
217217
}
218218

219219
public static Task<long> ExecLongScalarAsync(this IDbCommand dbCmd, string sql, CancellationToken token)
220220
{
221221
if (sql != null)
222222
dbCmd.CommandText = sql;
223223

224+
if (Log.IsDebugEnabled)
225+
Log.DebugCommand(dbCmd);
226+
227+
OrmLiteConfig.BeforeExecFilter?.Invoke(dbCmd);
228+
224229
if (OrmLiteConfig.ResultsFilter != null)
225230
return OrmLiteConfig.ResultsFilter.GetLongScalar(dbCmd).InTask();
226231

src/ServiceStack.OrmLite/Async/OrmLiteWriteCommandExtensionsAsync.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,6 @@ internal static async Task<long> InsertAsync<T>(this IDbCommand dbCmd, T obj, Ac
314314
OrmLiteConfig.InsertFilter?.Invoke(dbCmd, obj);
315315

316316
var dialectProvider = dbCmd.GetDialectProvider();
317-
318317
dialectProvider.PrepareParameterizedInsertStatement<T>(dbCmd,
319318
insertFields: dialectProvider.GetNonDefaultValueInsertFields<T>(obj));
320319

src/ServiceStack.OrmLite/OrmLiteWriteCommandExtensions.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -782,6 +782,8 @@ internal static void RemovePrimaryKeyWithDefaultValue<T>(this Dictionary<string,
782782

783783
private static long InsertInternal<T>(IOrmLiteDialectProvider dialectProvider, IDbCommand dbCmd, object obj, Action<IDbCommand> commandFilter, bool selectIdentity)
784784
{
785+
OrmLiteUtils.AssertNotAnonType<T>();
786+
785787
dialectProvider.SetParameterValues<T>(dbCmd, obj);
786788

787789
commandFilter?.Invoke(dbCmd); //dbCmd.OnConflictInsert() needs to be applied before last insert id

0 commit comments

Comments
 (0)