Marshmallow EscapeChar causes SQL Script error (Tested using FireDAC)
when trying to get entities from database, raises a Sql script error. I Fixed it local making the follow change.
Unit:
Spring.Persistence.SQL.Generator.Ansi.pas
function TAnsiSQLGenerator.GetEscapeChar: Char;
begin
(-) Result := '"';
(+) Result := '`';
end;
Comments (10)
-
reporter -
repo owner -
repo owner I cannot simply change that without knowing what DBMS you are using this with and if that DBMS possibly has its own query language with an appropriate quote char.
Please specify
-
reporter I’m using MySQL, but I guess _`_ is an universal quote char, does not?
-
repo owner I was guessing MySQL - and there is a proper generator for that using the backtick quote char - you need to set the correct QueryLanguage (qlMySQL from Spring.Persistence.SQL.Interfaces.pas) to your TFireDACConnectionAdapter instance as there is no logic to automatically detect what DBMS it is connecting to (it might be possible looking at the DriverName property of the TFDConnection or something like that but that was beyond the scope of implementing the FD adapters at the time).
-
repo owner - changed status to closed
-
repo owner Addition: the backtick is a MySQL (probably other DBMS as well) thing - Ansi specifies the double quote for identifiers - according to the MySQL documentation this can also be changed: https://dev.mysql.com/doc/refman/5.6/en/sql-mode.html#sqlmode_ansi_quotes - but as said the MySQL generator takes care and specifies backtick as quote char and other MySQL specifics
-
reporter Stefan, thanks for help, I tryied set my FireDacAdapter.QueryLanguage to ‘qlMysql' but got an error “Item not Found”, so looking the disponible options where system was looking for, there was a “QUERY_LANGUAGE_MYSQL”, then setting it up
mFDAdapter := TFireDACConnectionAdapter.Create(FDbHelper.Conexao); mFDAdapter.QueryLanguage := 'QUERY_LANGUAGE_MYSQL'; FSession := TSession.Create(mFDAdapter);
it worked very fine!
-
repo owner As I wrote:
qlMySQL from Spring.Persistence.SQL.Interfaces.pas
-
reporter Oh yes, it worked!
- Log in to comment