Quantcast
Channel: Delphi – The Wiert Corner – irregular stream of stuff
Viewing all articles
Browse latest Browse all 1440

Spring4d Marshmallow ORM – ensuring the right identifier quoting is used

$
0
0

When an ORM generates the SQL for a certain database back-end, it needs to use the right quoting.

Normally, the Spring4D Marshmallow project derives that from the back-end specific adapter used.

But if you use a generic TDriverConnectionAdapter, then you need to manually set the QueryLanguage property in your IDBConnection using a valid value from Spring.Persistence.SQL.Interfaces. This then uses the correct SQLGenerator from the TSQLGeneratorRegister to generate the SQL including correct quotes.

To quote identifiers, most back-ends use a double quote, but MySQL uses a backtick.

via:

You obviously already modified that code as the commented out code is the correct one.
I guess you already got that mistake when you started using MySQL via ADO as MySQL needs the backtick.

Set QueryLanguage of your IDBConnection properly (the valid values are in Spring.Persistence.SQL.Interfaces). Then the correct SQLGenerator will be used.
If you are using an adapter that is specific to a certain database then it sets the QueryLanguage properly but if you are using an adapter for components that can connect to multiple databases (like ADO or FireDAC) it does not, hence the need you specify it.

 

–jeroen


Viewing all articles
Browse latest Browse all 1440

Trending Articles