Postgres potential casing issue

I’ve read the documentation but I seem to be hitting a potential issue with AutoQuery and Postgres. I noticed in the release notes that the conversion to snake_case was dropped in v8.9 I think?

My PostgreSQL tables are PascalCase when migrations has created them.

For these models:

  • PendingRegistration
  • BusinessMember

ModelDefinition is PascalCase:

  • PendingRegistration
  • BusinessMember

Plain OrmLite SQL is also PascalCase:
SELECT … FROM “PendingRegistration”
SELECT … FROM “BusinessMember”

But AutoQuery emits snake_case SQL instead:
FROM “pending_registration”
FROM “business_member”

So the name rewrite is not happening in model metadata or plain OrmLite SQL generation. It appears to happen inside the AutoQuery pipeline.

It wasn’t dropped, the older PostgreSQL configuration still uses snake_case whilst the new OrmLite Configuration, e.g:

services.AddOrmLite(options => options.UsePostgres(connectionString));

now matches EF Default and uses quoted “PascalCase” as explained in the v8.9 Release Notes.

You can revert to use previous snake_case naming strategy in the new configuration with:

services.AddOrmLite(options => options.UsePostgres(connString, dialect => {
        dialect.NamingStrategy = new PostgreSqlNamingStrategy();
    })
);

Now if your App is configured with new OrmLite configuration and its NamingStrategy hasn’t been overridden it should use the new quoted “PascalCase” default.

As is the case in all new Apps we’ve ported, feel free to link to a stand-alone example (on GitHub) where AutoQuery doesn’t respect the default configuration.

Thanks for the info. It was my issue, tried to create an example and couldn’t reproduce it! I was hitting the singleton before UsePostgres() which changed to PascalCase.

Any way, all sorted!

1 Like