sagarswathi / h2database

Automatically exported from code.google.com/p/h2database
0 stars 1 forks source link

Escaped table names are case sensitive in MSSQLServer mode #396

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago

Steps to Reproduce:

1. Run the HelloWorld sample at http://pastebin.com/ssBpHVbJ

What is the expected output? What do you see instead?

I expected the output to be 'Hello'.

Instead I saw an exception.

org.h2.jdbc.JdbcSQLException: Table "test" not found; SQL statement:
select * from [test] [42102-149]

Version of h2

1.3.149

What is your use case, meaning why do you need this feature?

I am trying to run some integration tests. The code normally talks to a MSSQL 
Database but to speed up the tests I would like to use h2 in memory.

How important/urgent is the problem for you?

It is not critical, but it would be nice to have fixed. The workaround 
 involves manually updating a bunch of queries to use upper case names whenever escaping is used.

Original issue reported on code.google.com by as.da...@gmail.com on 27 Apr 2012 at 9:27

GoogleCodeExporter commented 8 years ago
The problem is that quoted identifiers are case sensitive (lowercase here), and 
unquoted identifiers are converted to uppercase.

The quoting is inconsistent, that means sometimes the table is quotes and 
sometimes not:

-- not quoted
create table test(id int primary key, name varchar(255));

-- quoted
select * from [test];

Why don't you use:
create table [test](id int primary key, name varchar(255));

Original comment by thomas.t...@gmail.com on 10 May 2012 at 7:48

GoogleCodeExporter commented 8 years ago
I had already started down the workaround you suggested. In the end though the 
gain's were outweighed by the pains. The legacy MSSQL database I was trying to 
mimic is accessed via JPA and a whole bunch of hand crafted SQL.

Cheers.

Original comment by as.da...@gmail.com on 10 May 2012 at 8:43