Connection component database name quoting

Discussion of open issues, suggestions and bugs regarding PgDAC (PostgreSQL Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
snorkel
Posts: 384
Joined: Tue 08 Aug 2006 15:10
Location: Milwaukee WI USA

Connection component database name quoting

Post by snorkel » Tue 30 Dec 2008 23:36

Hi,
I just noticed if I created a database like this:

create database "Delete_me";

The try to connect to it the connection component does not do automatic name qouting. For a component it would be best just to qoute things in the background like database name, otherwise the programmer has to do something like this all the time:
var
dbname:='Delete_me';
myconnection.database:= format('"%s"',[dbname]);

In a query this is expected, but the connection component should handle this.

If the databasename is not quoted it won't be able to find the database with the caps because PostgtreSQL automaticly lowercases everything unless it's qouted.

In the connection component the following should be automaticly qouted:
database
schema
username
password

So in other words any tpgconnection server attribute should be qouted to handle case sensitivity.

snorkel
Posts: 384
Joined: Tue 08 Aug 2006 15:10
Location: Milwaukee WI USA

Post by snorkel » Tue 30 Dec 2008 23:43

oh,
The table component would probably need fixing as well for the table and schema name properties.

Plash
Devart Team
Posts: 2844
Joined: Wed 10 May 2006 07:09

Post by Plash » Wed 31 Dec 2008 08:47

This is not a bug. This is a feature. The TableName property of TPgTable is case-insensitive unless it is quoted. The same behaviour is present in all other our DACs.
The following two queries are equivalent:

SELECT * FROM dept
SELECT * FROM DEPT

So the TableName property is case-insensitive.

TPgTable has the QuoteNames option. If you set this option to True, TPgTable quotes table name automatically. This option will be published in the next PgDAC build.

The same thing is related to the Schema and Database properties. These properties have the same behaviour as the TableName and StoredProcName properties.

snorkel
Posts: 384
Joined: Tue 08 Aug 2006 15:10
Location: Milwaukee WI USA

Post by snorkel » Wed 31 Dec 2008 14:02

Plash wrote:This is not a bug. This is a feature. The TableName property of TPgTable is case-insensitive unless it is quoted. The same behaviour is present in all other our DACs.
The following two queries are equivalent:

SELECT * FROM dept
SELECT * FROM DEPT

So the TableName property is case-insensitive.

TPgTable has the QuoteNames option. If you set this option to True, TPgTable quotes table name automatically. This option will be published in the next PgDAC build.

The same thing is related to the Schema and Database properties. These properties have the same behaviour as the TableName and StoredProcName properties.
A QouteNames option is satisfactory, what about for the tpgconnection component, does it have a QouteNames Option as well? I am more concerned about the connection component as I would have to change a bunch of code to migrate from a competing product.

snorkel
Posts: 384
Joined: Tue 08 Aug 2006 15:10
Location: Milwaukee WI USA

Post by snorkel » Wed 31 Dec 2008 14:26

I just checked and I could not find a qoute names option for tpgconnection published or otherwise.

In all the other PostgreSQL solutions available you do not have to manually qoute the database name or the other connection params like username, password etc.

For example if I have a database created like this:

create database "DeleteMe"

I should not have to qoute the database ,username or the password property, PostgreSQL will lowercase these automaticly on the backend unless qouted, so currently I have to modify all my code that uses the connection component to manually qoute all the connection params that get sent to the server.

There are times when a user wants a database name to have the uppercase characters, so qouting is a must in these situations, and in order to handle them all it's best just to qoute inside the component all the time for database name, username,password etc.

Do you guys understand what I am trying to get across here?

for tpgconnection I don't want to do this everytime:

myconnection.database:= "DeleteMe" or in the case of using a var I have to do:
myconnection:= '"'+dbname+'"'; or
myconnecton:= format('"%s',[dbname]);

Please add a qoutenames option for the Tpgconnection component or simply qoute them automatilcy.

Thanks,

Snorkel

Plash
Devart Team
Posts: 2844
Joined: Wed 10 May 2006 07:09

Post by Plash » Mon 05 Jan 2009 09:19

In the next build we'll remove converting database name to the lowercase. So you will not need to add quotes to Database, UserName, and Password.

snorkel
Posts: 384
Joined: Tue 08 Aug 2006 15:10
Location: Milwaukee WI USA

Post by snorkel » Mon 05 Jan 2009 15:49

Plash wrote:In the next build we'll remove converting database name to the lowercase. So you will not need to add quotes to Database, UserName, and Password.
Great, the final release should be pretty solid.
Any idea when the next build will be available?

Thanks,

Snorkel

Plash
Devart Team
Posts: 2844
Joined: Wed 10 May 2006 07:09

Post by Plash » Thu 08 Jan 2009 09:26

The new build is already released.

Post Reply