Closed phildebrand closed 13 years ago
This is a strange problem. I can reproduce it with scalaquery-examples but the exact same CREATE TABLE statement with the exact same driver, connection string and Hsqldb version works perfectly in the ScalaQuery test suite. It also works with Hsqldb 2.0 instead of the ancient 1.8.0.7. Anyway, it seems to be caused by not adhering to the correct order for the column options as specified in the Hsqldb documentation. I have committed a bug fix to ScalaQuery ( https://github.com/szeiger/scala-query/commit/bea9fdd4984df192686d57234926aab7789470c0 ).
I tried the example code "FirstExample" with Hsqldb instead of H2. So I replaced the H2 import with:
import org.scalaquery.ql.extended.HsqldbDriver.Implicit._
and the Database.forUrl line with:
Database.forURL("jdbc:hsqldb:mem:example", user ="sa", password="", driver = "org.hsqldb.jdbcDriver") withSession {
If I try to run it I get the following exception:
Exception in thread "main" java.sql.SQLException: Unexpected token: NOT in statement [CREATE TABLE "SUPPLIERS" ("SUP_ID" INTEGER PRIMARY KEY NOT] at org.hsqldb.jdbc.Util.throwError(Unknown Source) at org.hsqldb.jdbc.jdbcPreparedStatement.execute(Unknown Source) at org.scalaquery.ql.DDL$$anonfun$create$1$$anonfun$apply$mcV$sp$1$$anonfun$apply$1.apply(DDL.scala:23) at org.scalaquery.ql.DDL$$anonfun$create$1$$anonfun$apply$mcV$sp$1$$anonfun$apply$1.apply(DDL.scala:23) at org.scalaquery.session.Session$class.withPreparedStatement(Session.scala:53) at org.scalaquery.session.BaseSession.withPreparedStatement(Session.scala:92) at org.scalaquery.ql.DDL$$anonfun$create$1$$anonfun$apply$mcV$sp$1.apply(DDL.scala:23) at org.scalaquery.ql.DDL$$anonfun$create$1$$anonfun$apply$mcV$sp$1.apply(DDL.scala:22) at scala.collection.Iterator$class.foreach(Iterator.scala:651) at scala.collection.Iterator$$anon$19.foreach(Iterator.scala:343) at org.scalaquery.ql.DDL$$anonfun$create$1.apply$mcV$sp(DDL.scala:22) at org.scalaquery.ql.DDL$$anonfun$create$1.apply(DDL.scala:22) at org.scalaquery.ql.DDL$$anonfun$create$1.apply(DDL.scala:22) at org.scalaquery.session.BaseSession.withTransaction(Session.scala:127) at org.scalaquery.ql.DDL$class.create(DDL.scala:21) at org.scalaquery.ql.DDL$$anon$1.create(DDL.scala:42) at nl.paulhildebrand.scalaquery.FirstExample$$anonfun$main$1.apply$mcV$sp(Example.scala:55) at nl.paulhildebrand.scalaquery.FirstExample$$anonfun$main$1.apply(Example.scala:50) at nl.paulhildebrand.scalaquery.FirstExample$$anonfun$main$1.apply(Example.scala:50) at scala.util.DynamicVariable.withValue(DynamicVariable.scala:57) at org.scalaquery.session.Database$$anonfun$withSession$1.apply(Database.scala:44) at org.scalaquery.session.Database$$anonfun$withSession$1.apply(Database.scala:44) at org.scalaquery.session.Database.withSession(Database.scala:36) at org.scalaquery.session.Database.withSession(Database.scala:44) at nl.paulhildebrand.scalaquery.FirstExample$.main(Example.scala:50) at nl.paulhildebrand.scalaquery.FirstExample.main(Example.scala)
Looks like the NOT NULL part in the CREATE TABLE statement is not coming through correctly.
I am using scalaquery_2.9.0.RC1-0.9.2.jar with hsqldb-1.8.0.7.jar