DB Compatibility Issues While Using ORM

For a long time, I have used ORM tools to use databases and I didn’t need to deal differences between different databases much. Until now, I have only beaten by following:

Character Limit of Identifiers

For example oracle limits table names and column names to 30 characters. I have been using ActiveObjects ORM from Atlassian since 2013 and older versions of it was not checking this and as a result shipped code was not working for Oracle.

Reserved Words

Keywords and reserved identifiers. Some identifiers are not valid as column or table names for some databases. Unfortunately the list changes for every database. There is an online tool for checking identifiers, but it seems to be outdated. For example “virtual” is a reserved word for MysQL 5.7, but it was not a reserved work for MySQL 5.6 and below. But this tool doesn’t find it.

Uppercase/Lowercase conventions

For a portable SQL it is a best practice to use quotes around identifiers. Because quoting an identifier also makes it case-sensitive, whereas unquoted names are always folded to lower case or uppercase depending on the database.

SQL standard requires unquoted names should be folded to upper case but PostgreSQL does exactly opposite of this, it converts them to lowercase.

For example, the identifier Foo is considered to be FOO for most databases but for PostgreSQL it is considered foo. To be compatible with all databases use “Foo” sot that it is considered as “Foo”, not foo or FOO by different databases.

Leave a Reply

Your email address will not be published. Required fields are marked *