MySQL double quotes get removed

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
BKeffer
Posts: 6
Joined: Tue 23 Jan 2018 19:45

MySQL double quotes get removed

Post by BKeffer » Thu 25 Jan 2018 16:22

Hey!

I'm still trying out your components. Now I want to use UniDAC and MySQL.
If I do

Code: Select all

AnyTable.SQL.Text:= 'SELECT * FROM automat WHERE name="Test"'
all double quotes will be replaced by

Code: Select all

`
This is not a single quote, it's a quote for table names, not for strings.
The same happens when

Code: Select all

AnyTable.Connection.MacroByName('any_condition').Value:= 'name="Test"';

How can I solve this Problem?
Last edited by BKeffer on Thu 25 Jan 2018 18:27, edited 1 time in total.

ViktorV
Devart Team
Posts: 3168
Joined: Wed 30 Jul 2014 07:16

Re: MySQL double quotes get remove

Post by ViktorV » Thu 25 Jan 2018 16:56

To solve the issue, please try to set the EnableUniSQL global variable from the Uni unit to False. For example:

Code: Select all

initialization
  EnableUniSQL := False;

BKeffer
Posts: 6
Joined: Tue 23 Jan 2018 19:45

Re: MySQL double quotes get remove

Post by BKeffer » Thu 25 Jan 2018 17:08

Yeh, but then the macros will not work anymore :-/

Code: Select all

SQL.Text:= '{select_clause}';

ViktorV
Devart Team
Posts: 3168
Joined: Wed 30 Jul 2014 07:16

Re: MySQL double quotes get removed

Post by ViktorV » Mon 29 Jan 2018 13:49

Since UniDAC is designed to develop applications that support various databases, it converts SQL into universal format. Therefore, for MySQL UniDAC replaces the character " with `.
UniDAC uses the characters "{" and "}" to specify macros within SQL queries. If the SQL parser finds any expression in {}, it replaces this expression with a predefined macro. A global variable EnableUniSQL is responsible for the above functionality. Therefore, when setting EnableUniSQL to False, the conversion of SQL into universal format will be disabled, but macros will stop working either.

Post Reply