Fixed delete prepared statements from stores
This commit is contained in:
parent
61151bef0c
commit
5618b28c49
@ -101,7 +101,7 @@ namespace HermesSocketServer.Store
|
|||||||
sql = _generator.GeneratePreparedDeleteSql("TtsChatVoice", count, ["userId", "chatterId"]);
|
sql = _generator.GeneratePreparedDeleteSql("TtsChatVoice", count, ["userId", "chatterId"]);
|
||||||
|
|
||||||
_logger.Debug($"User - Deleting {count} rows from database: {sql}");
|
_logger.Debug($"User - Deleting {count} rows from database: {sql}");
|
||||||
await _generator.DoPreparedStatement(_database, sql, list, ["id"]);
|
await _generator.DoPreparedStatementRaw(_database, sql, list, ["id"]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,23 @@ namespace HermesSocketServer.Store
|
|||||||
foreach (var column in columns)
|
foreach (var column in columns)
|
||||||
{
|
{
|
||||||
var propValue = columnPropertyRelations[column]!.GetValue(value);
|
var propValue = columnPropertyRelations[column]!.GetValue(value);
|
||||||
var propType = columnPropertyRelations[column]!.PropertyType;
|
c.Parameters.AddWithValue(column.ToLower() + valueCounter, propValue ?? DBNull.Value);
|
||||||
|
}
|
||||||
|
valueCounter++;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task DoPreparedStatementRaw<V>(Database database, string sql, IEnumerable<V> values, string[] columns)
|
||||||
|
{
|
||||||
|
await database.Execute(sql, (c) =>
|
||||||
|
{
|
||||||
|
var valueCounter = 0;
|
||||||
|
foreach (var value in values)
|
||||||
|
{
|
||||||
|
foreach (var column in columns)
|
||||||
|
{
|
||||||
|
object? propValue = value;
|
||||||
c.Parameters.AddWithValue(column.ToLower() + valueCounter, propValue ?? DBNull.Value);
|
c.Parameters.AddWithValue(column.ToLower() + valueCounter, propValue ?? DBNull.Value);
|
||||||
}
|
}
|
||||||
valueCounter++;
|
valueCounter++;
|
||||||
|
@ -107,7 +107,7 @@ namespace HermesSocketServer.Store
|
|||||||
sql = _generator.GeneratePreparedDeleteSql("GroupPermissionPolicy", count, ["id"]);
|
sql = _generator.GeneratePreparedDeleteSql("GroupPermissionPolicy", count, ["id"]);
|
||||||
|
|
||||||
_logger.Debug($"GroupPermissionPolicy - Deleting {count} rows from database: {sql}");
|
_logger.Debug($"GroupPermissionPolicy - Deleting {count} rows from database: {sql}");
|
||||||
await _generator.DoPreparedStatement(_database, sql, list, ["id"]);
|
await _generator.DoPreparedStatementRaw(_database, sql, list.Select(id => new Guid(id)), ["id"]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -102,7 +102,7 @@ namespace HermesSocketServer.Store
|
|||||||
sql = _generator.GeneratePreparedDeleteSql("User", count, ["id"]);
|
sql = _generator.GeneratePreparedDeleteSql("User", count, ["id"]);
|
||||||
|
|
||||||
_logger.Debug($"User - Deleting {count} rows from database: {sql}");
|
_logger.Debug($"User - Deleting {count} rows from database: {sql}");
|
||||||
await _generator.DoPreparedStatement(_database, sql, list, ["id"]);
|
await _generator.DoPreparedStatementRaw(_database, sql, list, ["id"]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -104,7 +104,7 @@ namespace HermesSocketServer.Store
|
|||||||
sql = _generator.GeneratePreparedDeleteSql("TtsVoice", count, ["id"]);
|
sql = _generator.GeneratePreparedDeleteSql("TtsVoice", count, ["id"]);
|
||||||
|
|
||||||
_logger.Debug($"User - Deleting {count} rows from database: {sql}");
|
_logger.Debug($"User - Deleting {count} rows from database: {sql}");
|
||||||
await _generator.DoPreparedStatement(_database, sql, list, ["id"]);
|
await _generator.DoPreparedStatementRaw(_database, sql, list, ["id"]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user