create table test(val varchar(1));
Connection c = getConnection();PreparedStatement s = c.prepareStatement("insert into test values (?)");s.setBoolean(1, true);s.executeUpdate(); // H2 fails heres = c.prepareStatement("select * from test");ResultSet rs = s.executeQuery();rs.next();System.out.println(rs.getString(1));
org.h2.jdbc.JdbcSQLException: Wert zu gross / lang für Feld "VAL VARCHAR(1)": "'TRUE' (4)"Value too long for column "VAL VARCHAR(1)": "'TRUE' (4)"; SQL statement:insert into test values (?) [22001-170]at org.h2.message.DbException.getJdbcSQLException(DbException.java:329)at org.h2.message.DbException.get(DbException.java:169)at org.h2.table.Column.validateConvertUpdateSequence(Column.java:315)at org.h2.table.Table.validateConvertUpdateSequence(Table.java:689)at org.h2.command.dml.Insert.insertRows(Insert.java:120)at org.h2.command.dml.Insert.update(Insert.java:84)at org.h2.command.CommandContainer.update(CommandContainer.java:75)at org.h2.command.Command.executeUpdate(Command.java:230)at org.h2.jdbc.JdbcPreparedStatement.executeUpdateInternal(JdbcPreparedStatement.java:156)at org.h2.jdbc.JdbcPreparedStatement.executeUpdate(JdbcPreparedStatement.java:142)at org.jooq.test._.testcases.EnumTests.testCustomEnums(EnumTests.java:140)
--
You received this message because you are subscribed to the Google Groups "H2 Database" group.
To unsubscribe from this group and stop receiving emails from it, send an email to h2-database...@googlegroups.com.
To post to this group, send email to h2-da...@googlegroups.com.
Visit this group at http://groups.google.com/group/h2-database.
For more options, visit https://groups.google.com/groups/opt_out.
Hi,Hm, I'm not sure. Why would you use a varchar(1) for a boolean, and not bit?
The following fails with PostgreSQL:drop table test;create table test(val varchar(1));insert into test(val) values(true); -- value too long for type character varying(1) 22001/0select * from test;It does work with MySQL. It doesn't work with Oracle, as Oracle doesn't understand "true" ("column not allowed here"). It sounds like for both MySQL and Oracle,
setBoolean(true) is kind of the same as setInt(1).
Now if PostgreSQL supports setBoolean(true) for varchar(1), then I think H2 should support it as well (I didn't test it yet).
6.13 <cast specification>[...]10) If TD is fixed-length character string, then let LTD be the length in characters of TD.[...]e) If SD is boolean, thenCase:i) If SV is True and LTD is not less than 4, then TV is 'TRUE' extended on the right by LTD–4<space>s.ii) If SV is False and LTD is not less than 5, then TV is 'FALSE' extended on the right by LTD–5<space>s.iii) Otherwise, an exception condition is raised: data exception — invalid character value for cast.
--
You received this message because you are subscribed to a topic in the Google Groups "H2 Database" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/h2-database/me_teu3Shbc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to h2-database+unsubscribe@googlegroups.com.
--
You received this message because you are subscribed to the Google Groups "H2 Database" group.
To unsubscribe from this group and stop receiving emails from it, send an email to h2-database...@googlegroups.com.
Hi,Hm, whatever we do, this will not be compatible with some databases. I would keep the current behavior, until somebody provides a patch to support both
(I wouldn't worry about Firebird compatibility).