H2 views - created with uppercase tablenames even with DATABASE_TO_UPPER=FALSE

1,084 views
Skip to first unread message

engrun

unread,
Apr 14, 2016, 7:36:00 AM4/14/16
to H2 Database
Hi

We are using the flag DATABASE_TO_UPPER=FALSE to prevent all table names being converted to uppercase. 
This works for tables. 

However, when creating views the SQL statements are created with uppercase table names. 

E.g.

CREATE VIEW [kjoptfra] (Animal_Id, Reason, kjonn, OriginMarking)
AS (
SELECT
Animal_Id,
Reason,
BirthInfo.gender,
Animal.OriginMarking
FROM [AnimalHistory], [BirthInfo], Animal
WHERE Reason IN ('InFromUncontrolledHerd_2', 'InFromOwnHerd_1')
AND Animal_Id = [Animal].Id
AND [Animal].Id = Birthinfo.id
AND [BirthInfo].Gender = 'Female');


The db is created successfully with schema and views, however, when running the query "select * from "kjoptfra";
 it fails with the following error

[2016-04-14 10:50:26] [90109][90109] View "PUBLIC.""kjoptfra""" is invalid: "Column ""BIRTHINFO.Gender"" not found [42122-191]";


As you can see, the sql statements now uses uppercase table names, and therefore fails.
Is there a workaround for this?
We are also using the IGNORECASE=true flag, but this seems to apply to columns only


[2016-04-14 10:50:26] [90109][90109] View "PUBLIC.""kjoptfra""" is invalid: "Column ""BIRTHINFO.Gender"" not found [42122-191]"; SQL statement:
select * from "kjoptfra" [90109-191]
[42S22][42122] Column "BIRTHINFO.Gender" not found; SQL statement:
CREATE FORCE VIEW PUBLIC."kjoptfra"(Animal_Id, Reason, kjonn, OriginMarking) AS

SELECT
    "Animal_Id",
    "Reason",
    BIRTHINFO."Gender",
    ANIMAL."OriginMarking"
FROM PUBLIC."AnimalHistory"
INNER JOIN PUBLIC."BirthInfo"
    ON 1=1
INNER JOIN PUBLIC."Animal"
    ON 1=1
WHERE (BIRTHINFO."Gender" = 'Female')
    AND ((ANIMAL."Id" = BIRTHINFO."Id")
    AND (("Reason" IN('InFromUncontrolledHerd_2', 'InFromOwnHerd_1'))
    AND ("Animal_Id" = ANIMAL."Id")))  [42122-191]




Noel Grandin

unread,
Apr 14, 2016, 7:50:37 AM4/14/16
to h2-da...@googlegroups.com
I can't reproduce this with a simple case like:

create view view1 as select id from [test] where [id] = 1;
select * from [view1];

But if you can create a standalone test case that exhibits the problem, I can take a look at it.

engrun

unread,
Apr 14, 2016, 9:47:48 AM4/14/16
to H2 Database
My bad!

I used the following flags when creating the DB
;FILE_LOCK=NO;MODE=MSSQLServer;DB_CLOSE_ON_EXIT=FALSE;IGNORECASE=TRUE;DATABASE_TO_UPPER=FALSE;MV_STORE=false;MVCC=false;

However, when connecting from my db-client (Intellij), I had forgotten to specify it exactly the same. 

So when adding IGNORECASE=TRUE;DATABASE_TO_UPPER=FALSE; as driver properties, it works!
Reply all
Reply to author
Forward
0 new messages