[Solved] Wildcards underscore problem

The forum for ZeosLib 7.2 Report problems. Ask for help, post proposals for the new version and Zeoslib 7.2 features here. This is a forum that will be edited once the 7.2.x version goes into RC/stable!!

My personal intention for 7.2 is to speed up the internals as optimal a possible for all IDE's. Hope you can help?! Have fun with testing 7.2
Post Reply
naumov13
Fresh Boarder
Fresh Boarder
Posts: 16
Joined: 19.09.2019, 14:33

[Solved] Wildcards underscore problem

Post 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.
Last edited by naumov13 on 15.03.2021, 16:18, edited 1 time in total.
marsupilami
Platinum Boarder
Platinum Boarder
Posts: 1956
Joined: 17.01.2011, 14:17

Re: Wildcards underscore problem

Post 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
naumov13
Fresh Boarder
Fresh Boarder
Posts: 16
Joined: 19.09.2019, 14:33

Re: Wildcards underscore problem

Post 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.
You do not have the required permissions to view the files attached to this post.
marsupilami
Platinum Boarder
Platinum Boarder
Posts: 1956
Joined: 17.01.2011, 14:17

Re: Wildcards underscore problem

Post 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
marsupilami
Platinum Boarder
Platinum Boarder
Posts: 1956
Joined: 17.01.2011, 14:17

Re: Wildcards underscore problem

Post by marsupilami »

I created a ticket on SourceForge, so this problem will not be forgotten easily: https://sourceforge.net/p/zeoslib/tickets/386/
naumov13
Fresh Boarder
Fresh Boarder
Posts: 16
Joined: 19.09.2019, 14:33

Re: Wildcards underscore problem

Post by naumov13 »

Hello,
Do you have any news about this?
I did checked it on Zeos 7.2.6-stable. The problem still stay.
marsupilami
Platinum Boarder
Platinum Boarder
Posts: 1956
Joined: 17.01.2011, 14:17

Re: Wildcards underscore problem

Post 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
naumov13
Fresh Boarder
Fresh Boarder
Posts: 16
Joined: 19.09.2019, 14:33

Re: Wildcards underscore problem

Post 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!
Post Reply