The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 2,319 other followers

Spring4d Marshmallow ORM – ensuring the right identifier quoting is used

Posted by jpluimers on 2019/10/29

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.


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.



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

<span>%d</span> bloggers like this: