Closed GoogleCodeExporter closed 9 years ago
What framework do you use? How does the framework detect the database name,
does it
parse the JDBC URL? How does it parse the URL exactly?
Or do you create the database URL using some algorithm (appending the database
name
to "jdbc:h2:mem:")? If the algorithm to create the URL is in your application, I
suggest to use the uppercase name.
While not directly related to your problem, there is also the problem that the
file
system is case insensitive in Windows.
For me, this is not a bug but a request for a new feature. A bug would be a
deviation
from the specification or documentation, but using the database name in the
query is
not a fully supported feature (it's also not documented). And so far I don't
think
it's a feature I would like to add.
Original comment by thomas.t...@gmail.com
on 4 Jun 2010 at 9:37
> What framework do you use?
One we built :-)
> Or do you create the database URL using some algorithm (appending the
database
> name to "jdbc:h2:mem:")?
Yes that's what we do.
> If the algorithm to create the URL is in your application, I
> suggest to use the uppercase name.
We can't : we have a whole lot of queries that are saved in .sql files
(including at our customers), and they are shared for Postgresql and H2. The
thing is, it used to work on H2 : when r2251 was committed, all
token.equals(currentToken) were replaced by equalsToken(token, currentToken)
which depends on identifiersToUpper. But in readIdentifierWithSchema(String)
schemaName.equalsIgnoreCase(database.getShortName()) was replaced by
equalsToken(schemaName, database.getShortName()). So queries like select * from
"Test"."schema"."T"; worked before and now don't.
Every database system has a way to give arbitrary names to databases : in
postgresql one always can, in H2 until recently I thought it worked like pg,
and in MySQL they have lower_case_table_names.
> While not directly related to your problem, there is also the problem that the
> file system is case insensitive in Windows.
I know, see lower_case_table_names in
http://dev.mysql.com/doc/refman/5.0/en/identifier-case-sensitivity.html .
There's a warning saying index corruption can occur under specific
circumstances but I as a developer can take responsability. Further I
understand the problem but it's an implementation detail, a database should
completely abstract everything underneath it.
> For me, this is not a bug but a request for a new feature. A bug would be a
deviation
> from the specification or documentation, but using the database name in the
query is
> not a fully supported feature (it's also not documented). And so far I don't
think
> it's a feature I would like to add.
I didn't realize that ; coming from Postgresql, I connected to a url like
jdbc:h2:Test , tested my queries using "Test"."schema"."T" and they worked.
Since I quoted the database name it seemed that internally H2 did retain the
case as Postgresql did. And now I have customers with existing queries, so it
would be greatly appreciated if you could add a property (even undocumented)
like in the attached small patch so I can upgrade their H2.
Original comment by ilm.info...@gmail.com
on 8 Jun 2010 at 10:44
Attachments:
> > What framework do you use?
> One we built :-)
In this case it's in your control to set the jdbc URL. I suggest to use the
uppercase database name in the database URL in this case.
> We can't
Why not? The database URL is in not related to the scripts.
By the way, the user name is also case insensitive. You can login using 'SA',
'sa', 'Sa' or 'sA'.
Original comment by thomas.t...@gmail.com
on 12 Jun 2010 at 11:05
Implementing your request will break backward compatibility.
Original comment by thomas.t...@gmail.com
on 12 Jun 2010 at 11:06
> The database URL is in not related to the scripts.
the URL is not but the database name is : select * from "Test"."schema"."T";
> Implementing your request will break backward compatibility.
How so ? h2.databaseToUpper is true by default, so parseDatabaseShortName()
will return the same value it always have.
Thanks for your time.
Original comment by ilm.info...@gmail.com
on 14 Jun 2010 at 1:50
> h2.databaseToUpper is true by default, so parseDatabaseShortName() will
return the same value it always have.
You are right, I didn't see that. Sorry.
The patch looks easy, I will try to add it. If there are no problems with other
tools, it could be made the default behavior with H2 version 1.3
Original comment by thomas.t...@gmail.com
on 14 Jun 2010 at 6:33
I committed you patch.
Original comment by thomas.t...@gmail.com
on 14 Jun 2010 at 7:04
Great ! Thanks a lot.
Original comment by ilm.info...@gmail.com
on 15 Jun 2010 at 4:58
This is implemented in version 1.2.138, but not enabled by default (for
compatibility with old version of H2). To test it, enable the system property
h2.databaseToUpper. This property will be enabled by default in version 1.3.x
Original comment by thomas.t...@gmail.com
on 28 Jun 2010 at 4:50
I'm setting the issue to 'fixed', even if the setting not yet enabled by
default. Please add a comment if it still doesn't work for you (or doesn't work
as expected) even when the system property is enabled.
Original comment by thomas.t...@gmail.com
on 28 Jun 2010 at 6:53
Original issue reported on code.google.com by
ilm.info...@gmail.com
on 3 Jun 2010 at 8:14