Connection component database name quoting
Connection component database name quoting
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.
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.
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.
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.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.
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
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