Default Table names different between postgres and SqlServer/Mysql

Doing a migration from Mysql to Postgres. My data migration tool was able to create all the tables and data in Postgres using the exact same table names.

Ormlite seems to think they should be different (Lower case, and then camel case becomes underscores…).

I’m sure this was done for a reason, and since I can’t reasonably use Ormlite to migrate my data directly and having to attribute the classes with an alias that is exactly the same name as the class seems a) silly and b) laborious c) more maintenance in the long run:

Is there a way to change the behavior of table names in the Postgres ormlite package?

( The same issue would be true for Sql Server->Postgres as well I believe)

PS: I see the code that does it in Github… but I don’t see a hook to change it…

Follow up, I was able to create my own naming strategy and attach it to the dialect, but still have the question about why that naming strategy is used…

That’s the convention for PostgreSQL table and column names due to how PostgreSQL treats unquoted identifiers.

You can specify a different naming strategy with:

OrmLiteConfig.DialectProvider.NamingStrategy= new OrmLiteNamingStrategyBase();

Here are some examples of different naming strategies.

Most Dialects use the default strategy above with PostgreSQL’s conventional snake_case used in PostgreSqlNamingStrategy.

Other built-in naming strategies:

  • AliasNamingStrategy
  • LowercaseUnderscoreNamingStrategy
  • UpperCaseNamingStrategy

Yes, but Ormlite does not issue queries with unquoted identifiers, does it? So there must be an assumption that there are other clients that don’t? Is that really even true these days? Can’t think of BI, ETL or orm tool or orm tool that doesn’t… but maybe small sample size.

OrmLite defaults to naming convention most used for PostgreSQL, if you create table names with quotes then they’ll forever need to be referenced using quotes, if snake_case is used it’s not necessary.