Support Upsert with MySQL
AWS Charges by the IOp, not supporting UPSERT effectively doubles the cost (and reduces the performance) of running mysql/mariadb on that platform with the SELECT/INSERT behavior of OrmLite

-
Anonymous commented
I did a crude patch for MySql As Follows:
public static int Save(T record)
{
var sqlToExecute = "";using (var Db = GetConnection())
{try
{
var insertSQL = Db.ToInsertStatement(record);
var updateSQL = Db.ToUpdateStatement(record);// strip out the UPDATE 'tablename' SET ....
updateSQL = updateSQL.Replace(Db.GetQuotedTableName<T>(), "");
updateSQL = updateSQL.Replace(" SET", "");// remove trailing WHERE <PK=Id>...
updateSQL = updateSQL.Substring(0, updateSQL.IndexOf(" WHERE `"));//lastly something weird with nulls = '{}'
sqlToExecute = (insertSQL + " ON DUPLICATE KEY " + updateSQL).Replace("'{}'", "NULL");Db.ExecuteSql(sqlToExecute);
return 1;
}
catch (Exception e)
{Log.Error(0, $"Error saving record, sql={sqlToExecute}", e);
return -1;
}
}
}