I suggest you ...

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

4 votes
Vote
Sign in
Check!
(thinking…)
Reset
or sign in with
  • facebook
  • google
    Password icon
    Signed in as (Sign out)
    You have left! (?) (thinking…)
    Anonymous shared this idea  ·   ·  Flag idea as inappropriate…  ·  Admin →

    1 comment

    Sign in
    Check!
    (thinking…)
    Reset
    or sign in with
    • facebook
    • google
      Password icon
      Signed in as (Sign out)
      Submitting...
      • Anonymous commented  ·   ·  Flag as inappropriate

        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;

        }
        }
        }

      Feedback and Knowledge Base