I can confirm that this is a bug, and that the problem is most likely in org.h2.expression.ExpressionColumn.
Beyond that, I don't know, perhaps Thomas will take a look.

unit test code looks like:

    private void testColumnResultSetMeta2() throws SQLException {
        stat = conn.createStatement();
stat.executeUpdate("create table A (ID bigint not null, primary key (ID))"); stat.executeUpdate("create table B (A_ID bigint not null, primary key (A_ID), foreign key (A_ID) references A (ID))"); ResultSet rs = stat.executeQuery("select * from A left outer join B on A.ID=B.A_ID");
        ResultSetMetaData rsMeta = rs.getMetaData();
assertEquals(ResultSetMetaData.columnNoNulls, rsMeta.isNullable(1)); // ID assertEquals(ResultSetMetaData.columnNullable, rsMeta.isNullable(2)); // A_ID
        rs.next();
        stat.executeUpdate("drop table A");
        stat.executeUpdate("drop table B");
    }


On 2012-12-18 20:20, [email protected] wrote:
Hi,

I'm having some difficulties using H2 with the anorm framework; anorm makes heavy use of the ResultSetMetaData associated with a Query.

It seems that H2 inconsistently reports the isNullable property of a given column.

Please could my investigation below be checked to see if I've misunderstood / misused the API? I'm using SQuirrel to examine the ResultSetMetaData.

Thanks,
Stu.

-- test setup

    -- given a pair of joined tables, both with only non-nullable columns


create table A (ID bigint not null, primary key (ID));
create table B (A_ID bigint not null, primary key (A_ID), foreign key (A_ID) references A (ID));

    -- when a left outer join is made


select * from A left outer join B on A.ID=B.A_ID

    -- then we expect the ResultSetMetaData
    -- both to define "ID" as non-nullable
    -- and  to define "A_ID" as nullable


Unfortunately H2 appears to return both ID and A_ID as non-nullable.
On a similar note, a view appears to always return all columns as nullable.

    -- given a view is defined for our previous query


create view A_B as select * from A left outer join B on A.ID=B.A_ID;

    -- when the view is queried


select * from A_B

    -- then both A and A_ID are defined as nullable (which is directly
    contrary to the result from the equivalent query)



--
You received this message because you are subscribed to the Google Groups "H2 Database" group. To view this discussion on the web visit https://groups.google.com/d/msg/h2-database/-/pBLHgSGUWw4J.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/h2-database?hl=en.

--
You received this message because you are subscribed to the Google Groups "H2 
Database" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/h2-database?hl=en.

Reply via email to