Page 1 of 1

[Solved] Wildcards underscore problem

Posted: 19.09.2019, 14:58
by naumov13
Hello

In version 7.1.4, the TZAbstractDatabaseMetadata.FillWildcards method
created an array of one element with the symbol '%'.
In version 7.2 there are two elements: '%' and '_'.

As a result, I get an error when executing queries with table names containing the character '_'. I studied this problem and realized that it resolves if I escape the underscore in this way

Code: Select all

s: = StringReplace (ATableName, '_', '/ _', [rfReplaceAll]);
But such a solution does not suit me. I have too many tables and queries where the underscore character appears.

I saw a couple of similar topics on this forum, and in both cases, it was proposed to modify the FillWildcards function as a solution.
And I can do that too.
And I’ll probably do it.

But I would like to understand - why?
What is the purpose of the underscore in the Wildcards array?
If nobody needs it there, maybe you should remove it?
If it is there for some reason, then why not provide the opportunity to override this method in code?

Something like

Code: Select all

MyConnection.SetWildcards(['%'])
or maybe

Code: Select all

MyConnection.UseUnderscoreInWildcards := False
It seems to me that this would be the most reasonable solution.

Re: Wildcards underscore problem

Posted: 20.09.2019, 08:32
by marsupilami
Hello,

that is because _ and % are the default SQL wildcard characters and FillWildcards is meant to provide all wildcard characters the selected database supports. Descandants can override FillWideChars if the underlying database supports more wilccard characters or different wildcard characters. This way Zeos can escape wildcard characters if necessary.

Could you please try the current SVN version of Zeos 7.2? If that version doesn't work for you, could you please provide the following information:
- The compiler and IDE you use (i.e. Delphi 2010 , Lazarus 2.0.2 + FPC 3.0.4, ...)
- The database driver you use in Zeos
- The database you use including version numbers
- The operating system of your server and your clien
- some code that shows the problem

Best regards,

Jan

Re: Wildcards underscore problem

Posted: 08.10.2019, 13:13
by naumov13
Hello!
Sorry for the long silence - I did not receive a notification about your answer.

My environment:
Windows 8.1 x64
Lazarus 1.8.0 x32
FPC: 3.0.4
ZEOS version: I tried both 7.2.1-rc and 7.2.4-stable
Database driver: SQLite (sqlite3.dll v3.18.0 in attachment)

In the attachment is a project demonstrating the problem that I reported.
There is simple application with 2 buttons for 2 way to get error.
Some comments in code.

Re: Wildcards underscore problem

Posted: 27.10.2019, 12:29
by marsupilami
Hello,

I am sorry for the long delay in my answer. Unfortunately we can't send emails from the board because of restrictions on SourceForge. I will take a look at the source code later on.

Best regards,

Jan

Re: Wildcards underscore problem

Posted: 27.10.2019, 12:49
by marsupilami
I created a ticket on SourceForge, so this problem will not be forgotten easily: https://sourceforge.net/p/zeoslib/tickets/386/

Re: Wildcards underscore problem

Posted: 10.01.2020, 21:25
by naumov13
Hello,
Do you have any news about this?
I did checked it on Zeos 7.2.6-stable. The problem still stay.

Re: Wildcards underscore problem

Posted: 14.01.2020, 16:22
by marsupilami
Hello,

I checked your test program. Both caeses execute without problems in the current SVN version of Zeos 7.2. I would expect an error for Wildcard Bug #1 though because the _ is a wildcard and needs to be escaped normally.

So - please use the current SVN version of Zeos 7.2.

Best regards,

Jan

Re: Wildcards underscore problem

Posted: 15.03.2021, 16:17
by naumov13
Hello.

Sorry for the long silence.
I didn’t work on that project for a long time and now I came back to it again.

Checked the problem with current stable version zeos-7.2.10
As far as I can tell, this issue has been resolved.

Many thanks!