google-code-export / h2database

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

DATABASE_TO_UPPER=FALSE causes double quotes to appear around column names in aggregates #326

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Before submitting a bug, please check the FAQ:
http://www.h2database.com/html/faq.html

What steps will reproduce the problem?
(simple SQL scripts or simple standalone applications are preferred)
1. open a new database with h2 console and specify DATABASE_TO_UPPER=FALSE
2. in h2 console run 
DROP TABLE IF EXISTS TEST;
CREATE TABLE TEST(id INT PRIMARY KEY,
   NAME VARCHAR(255));
INSERT INTO TEST VALUES(1, 'Hello');
INSERT INTO TEST VALUES(2, 'World');
SELECT MAX(id) FROM TEST;

What is the expected output? What do you see instead?
Actual:
MAX("id")  
2

Expected:
MAX(id)  
2
NOTE: also expect to be able to write select max(id) from TEST;
but get an error 
select max(id) from TEST;
Function "max" not found; SQL statement:
select max(id) from TEST [90022-156] 90022/90022 (Help)

What version of the product are you using? On what operating system, file
system, and virtual machine?
V1.3.155, OSX 10.6.7, 1.6.0_24

Do you know a workaround?
No

What is your use case, meaning why do you need this feature?
To write queries that can be run against many databases

How important/urgent is the problem for you?
Urgent

Please provide any additional information below.

Original issue reported on code.google.com by smith7...@gmail.com on 27 Jun 2011 at 1:25

GoogleCodeExporter commented 9 years ago
temporary work around would be to use
select MAX(id) as max_id from TEST;

Original comment by smith7...@gmail.com on 27 Jun 2011 at 1:30

GoogleCodeExporter commented 9 years ago
I think another occurrence of this issue is shown by this:

  jdbc:h2:mem:;DATABASE_TO_UPPER=FALSE

  drop table test if exists;
  create table test( a int, b varchar(255) );
  insert into test (a, b) values (1, 'foo' );
  insert into test (a, b) values (2, 'bar' );

  select SUM(a), b as c from test group by c;

which fails with

  Column "c" not found; SQL statement:
  select SUM(a), b as c from test group by c [42122-157] 42S22/42122

i.e. the column alias is not recognized when checking against the group by list.

Original comment by bentm...@sonatype.com on 30 Jun 2011 at 12:18

GoogleCodeExporter commented 9 years ago

Original comment by thomas.t...@gmail.com on 10 Jul 2011 at 12:44

GoogleCodeExporter commented 9 years ago
"select max(id) as max_id from ..." now works in H2 version 1.3.158.

"select b as c from test group by c" doesn't work yet.

Original comment by thomas.t...@gmail.com on 17 Jul 2011 at 12:14

GoogleCodeExporter commented 9 years ago
Fixed in version 1.3.162

Original comment by thomas.t...@gmail.com on 26 Nov 2011 at 12:55