OrmLite Schema attribute for MySQL just appends?

Hi,

Any reason the Schema attribute for MySQL Provider just prepends a text to the table rather than do a full quoted schema reference?

For example:
[Schema("myschema")] class table { ...

does: `myschema_table`

when it should do: `myschema`.`table`

A Schema is not the same thing in MySql compared with other databases, it’s more like a different database so we use it’s used as a namespace alias instead.

Oh I see, I remember now that in SQL Server a schema is like a namespace separation and not a separate database. Okay so this attribute was never intended for cross database access. For example a SqlExpression query that references two different databases on the one db server?

Right, OrmLite doesn’t do anything special to enable cross DB queries, it just sends the SQL to the RDBMS.

Just off the top of your head if I did override this, might it work?

 public class CustomMySqlDialectProvider : MySqlDialectProvider
    {
        public override string GetTableName(string table, string schema = null)
        {
            if (schema == null) {
                return NamingStrategy.GetTableName(table);
            } else {
                return $$"{NamingStrategy.GetSchemaName(schema)}.{NamingStrategy.GetTableName(table)}";
            }
        }

        public override string GetQuotedTableName(string tableName, string schema = null)
        {
            if (schema == null) {
                return $$"`{NamingStrategy.GetTableName(tableName)}`";
            } else {
                return $$"`{NamingStrategy.GetSchemaName(schema)}`.`{NamingStrategy.GetTableName(tableName)}`";
            }
        }
    }

Also requires in AppHost for me:

   var databaseProvider = new CustomMySqlDialectProvider();
   MySqlDialectProvider.Instance = databaseProvider;
    OrmLiteConfig.DialectProvider = databaseProvider;

That’s what you need to do to modify the generated SQL yes.