Hi,
we are using the UpdateOnlyFields Method in a .Net 4.8 application with ServiceStack.OrmLite in version 6.11.0.
With MSSQL our code works well. Switching to MySql/MariaDb, the generated SQL looks like this:
UPDATE `RessourceElement` SET `ContentString`= WHERE (`Key` = @0)
Our code looks like this:
try
{
int updated = conn.UpdateOnlyFields(model, onlyFields, @where, commandFilter);
if (updated != 1 && throwWhenNotFound)
{
throw new Exception("Datenbank-Operation UpdateOnly fehlgeschlagen - es wurde kein passendes Element in der Datenbank aktualisiert. Last SQL: " + conn.GetLastSql());
}
}
catch (Exception e)
{
Log.Error("Datenbank-Operation UpdateOnly fehlgeschlagen. Last SQL: " + conn.GetLastSql(), e);
throw;
}
The GetLastSql() is empty in the catch block.
The variables have the following values:
model = new RessourceElement{ ContentString = NewContentString}
onlyFields = r => new {r.ContentString}
where = x => x.Key == "*****"
We already tried with different databases / servers. No difference.
Any hints or ideas what could be the issue?
Today I can not debug into the sources.
If I add a commandFilter and output the CommandText there, I get the SQL shown above.
I will update on monday, when I have debugged further.
In the catch block, this exception is handeled and the execution continues and produces an invalid SQL.
Stack:
MySql.Data.MySqlClient.MySqlException: “Only MySqlParameter objects may be stored”
Diese Ausnahme wurde ursprünglich von dieser Aufrufliste ausgelöst:
MySql.Data.MySqlClient.MySqlParameterCollection.Add(object)
ServiceStack.OrmLite.DbDataParameterExtensions.AddParam(ServiceStack.OrmLite.IOrmLiteDialectProvider, System.Data.IDbCommand, object, ServiceStack.OrmLite.FieldDefinition, System.Action<System.Data.IDbDataParameter>) in SqlExpression.cs
ServiceStack.OrmLite.DbDataParameterExtensions.AddUpdateParam(ServiceStack.OrmLite.IOrmLiteDialectProvider, System.Data.IDbCommand, object, ServiceStack.OrmLite.FieldDefinition) in SqlExpression.cs
ServiceStack.OrmLite.DbDataParameterExtensions.GetUpdateParam(ServiceStack.OrmLite.IOrmLiteDialectProvider, System.Data.IDbCommand, object, ServiceStack.OrmLite.FieldDefinition) in SqlExpression.cs
ServiceStack.OrmLite.OrmLiteDialectProviderBase.PrepareUpdateRowStatement(System.Data.IDbCommand, object, System.Collections.Generic.ICollection) in OrmLiteDialectProviderBase.cs
Perhaps also important: We are using mysqlconnector as dialect.