object SampleSchema extends Schema {
val categoryTable = table[Category]("category")
on(categoryTable) { t =>
declare {
t.id is (autoIncremented)
}
case class Category(id: Long, name: String) extends KeyedEntity[Long]
When I connect to an H2 database and create the schema with this command:
SampleSchema.create
It fails saying that there is an error in the SQL syntax. The SQL that Squeryl generates is:
create table category (
name varchar(128) not null,
id bigint primary key not null auto_increment
);
.... and it fails with this error:
[error] org.h2.jdbc.JdbcSQLException: Syntax error in SQL statement "CREATE TABLE CATEGORY (
[error] NAME VARCHAR(128) NOT NULL,
[error] ID BIGINT PRIMARY KEY NOT NULL AUTO_INCREMENT[*]
[error] ) "; expected "CHECK, REFERENCES, ,, )"; SQL statement:
I tried testing the generated CREATE TABLE statement out myself in my DBVisualizer pointing to an embedded H2 DB and it also fails. I find that I can make it work, by simply switching the order of "not null" and auto_increment so that the "not null" part is last. I guess H2 is extremely picky! I'm guessing this is a bug in Squeryl, but perhaps there is some config setting in h2 that I am not aware of? Any help would be appreciated.
Joe
Hi David,Thanks for the response. You are right, the "t.id is (autoIncremented)" was unnecessary. Unfortunately, removing it did not change the order of the fields. I am using Squeryl 0.9.5. Should I try with the latest 0.9.6 build?