Página 1 de 1

Not able to use " (double quotes) in new version

Publicado: Lun Nov 29, 2021 2:26 pm
por Milan Mehta
I have just updated my xailer Enterprise Edition.

While trying to recompile all my projects, I noticed one big change :
I am not allowed to use " (double quote) in the SQL.

I have used it extensively. In fact hb_vartoexp() function puts " mark in the result.

What is the way out ?

TIA
Milan.

Re: Not able to use " (double quotes) in new version

Publicado: Mar Nov 30, 2021 8:18 am
por Milan Mehta
This is happening with SqLite Data Source only.

However, it is working fine with MySQL / Maria Databases.

Re: Not able to use " (double quotes) in new version

Publicado: Mar Nov 30, 2021 4:27 pm
por ignacio
Hello,

I had the same problem. Is a change of behaviour of SQLite:

Double-quoted String Literals Are Accepted
The SQL standard requires double-quotes around identifiers and single-quotes around string literals. For example:

"this is a legal SQL column name"
'this is an SQL string literal'
SQLite accepts both of the above. But, in an effort to be compatible with MySQL 3.x (which was one of the most widely used RDBMSes when SQLite was first being designed) SQLite will also interpret a double-quotes string as string literal if it does not match any valid identifier.

This misfeature means that a misspelled double-quoted identifier will be interpreted as a string literal, rather than generating an error. It also lures developers who are new to the SQL language into the bad habit of using double-quoted string literals when they really need to learn to use the correct single-quoted string literal form.

In hindsight, we should not have tried to make SQLite accept MySQL 3.x syntax, and should have never allowed double-quoted string literals. However, there are countless applications that make use of double-quoted string literals and so we continue to support that capability to avoid breaking legacy.

As of SQLite 3.27.0 (2019-02-07) the use of a double-quoted string literal causes a warning message to be sent to the error log.

As of SQLite 3.29.0 (2019-07-10) the use of double-quoted string literals can be disabled at run-time using the SQLITE_DBCONFIG_DQS_DDL and SQLITE_DBCONFIG_DQS_DML actions to sqlite3_db_config(). The default settings can be altered at compile-time using the -DSQLITE_DQS=N compile-time option. Application developers are encouraged to compile using -DSQLITE_DQS=0 in order to disable the double-quoted string literal misfeature by default. If that is not possible, then disable double-quoted string literals for individual database connections using C-code like this:

sqlite3_db_config(db, SQLITE_DBCONFIG_DQS_DDL, 0, (void*)0);
sqlite3_db_config(db, SQLITE_DBCONFIG_DQS_DML, 0, (void*)0);
Or, if double-quoted string literals are disabled by default, but need to be selectively enabled for some historical database connections, that can be done using the same C-code as shown above except with the third parameter changed from 0 to 1.

Re: Not able to use " (double quotes) in new version

Publicado: Mar Dic 21, 2021 3:25 pm
por Milan Mehta
Can you please shed some more light on the following Statement:

"The default settings can be altered at compile-time using the -DSQLITE_DQS=N compile-time option. Application developers are encouraged to compile using -DSQLITE_DQS=0 in order to disable the double-quoted string literal misfeature by default."

I have tons of legacy programs in which I have used HB_ValToExp() function in the construction of SQL, which typically uses double-quotes. It is an almost impossible task to change them.

In order to compile such programs in the new Xailer, what command should I use at the time of compilation in Project -> Project Properties -> Harbour ?

Kindly guide.
TIA
Milan.

Re: Not able to use " (double quotes) in new version

Publicado: Mar Dic 21, 2021 6:50 pm
por ignacio
Hi,

Please test with the file attached. There is a new property on TSqlite class with the name: lDoubleQuotes. You must set its value to .T. before opening the datasource.

Just include the .O files in your project. Any feedback will be highly appreciated.

Regards,

Re: Not able to use " (double quotes) in new version

Publicado: Mié Dic 22, 2021 7:38 am
por Milan Mehta
I have linked both SQLite.o and lSQLite.o into the project.

I am getting following Error :

C:/Xailer7.1.3/Lib/libxailer.a(Win9XFiles.o):(.text+0x7a4): undefined reference to `_imp__FindNextFileX@8'
C:/Xailer7.1.3/Lib/libxailer.a(Win9XFiles.o):(.text+0x98f): undefined reference to `_imp__CreateFileX@28'
C:/Xailer7.1.3/Lib/libxailer.a(Win9XFiles.o):(.text+0x9a9): undefined reference to `_imp__GetFileAttributesX@4'
C:/Xailer7.1.3/Lib/libxailer.a(Win9XFiles.o):(.text+0x9bd): undefined reference to `_imp__SetFileAttributesX@8'
C:/Xailer7.1.3/Lib/libxailer.a(Win9XFiles.o):(.text+0x9dd): undefined reference to `_imp__DeleteFileX@4'
C:/Xailer7.1.3/Lib/libxailer.a(Win9XFiles.o):(.text+0x9f7): undefined reference to `_imp__MoveFileX@8'
C:/Xailer7.1.3/Lib/libxailer.a(Win9XFiles.o):(.text+0xa11): undefined reference to `_imp__CreateDirectoryX@8'
C:/Xailer7.1.3/Lib/libxailer.a(Win9XFiles.o):(.text+0xa25): undefined reference to `_imp__GetCurrentDirectoryX@8'
C:/Xailer7.1.3/Lib/libxailer.a(Win9XFiles.o):(.text+0xa45): undefined reference to `_imp__SetCurrentDirectoryX@4'
C:/Xailer7.1.3/Lib/libxailer.a(Win9XFiles.o):(.text+0xa5f): undefined reference to `_imp__RemoveDirectoryX@4'
C:/Xailer7.1.3/Lib/libxailer.a(Win9XFiles.o):(.text+0xa79): undefined reference to `_imp__GetTempFileNameX@16'
C:/Xailer7.1.3/Lib/libxailer.a(Win9XFiles.o):(.text+0xa8d): undefined reference to `_imp__GetTempPathX@8'
C:/Xailer7.1.3/Lib/libxailer.a(Win9XFiles.o):(.text+0xaa7): undefined reference to `_imp__FindFirstFileX@8'

Kindly guilde.
TIA
Milan Mehta.

Re: Not able to use " (double quotes) in new version

Publicado: Mié Dic 22, 2021 11:43 am
por ignacio
Hi,

I'm not able to reproduce your error. Please try with a new sample project.
Imagen 349.png
Imagen 349.png (9.61 KiB) Visto 3914 veces
BTW, I can confirm that the new SQLITE class module handles correctly your problem with that new property.

Regards,

Re: Not able to use " (double quotes) in new version

Publicado: Mié Dic 22, 2021 3:13 pm
por Milan Mehta
Please find attached a new small sample project.
Can you please try this ? It still gives me errors as above.

TIA
Milan.

Re: Not able to use " (double quotes) in new version

Publicado: Mié Dic 22, 2021 6:04 pm
por ignacio
Hi,

Working fine with some changes:

1) Updated datasource cConnect path value
2) Table does not exist, so I use 'acmast' instead
3) Changed fieldname to 'ecomoperator'. SQL string:

Código: Seleccionar todo

cSql := ' Select * from acmast where ' + HB_VALTOEXP(cField) + " = 'N' "
Result:
Imagen 350.png
Imagen 350.png (9.79 KiB) Visto 3899 veces
Regards,

Re: Not able to use " (double quotes) in new version

Publicado: Jue Dic 23, 2021 8:06 am
por Milan Mehta
The problem has been solved!
Many Many thanks.
Milan Mehta.

Re: Not able to use " (double quotes) in new version

Publicado: Jue Dic 23, 2021 11:55 am
por ignacio
Great!!