Skip to content

Commit

Permalink
Merge pull request #621 from dbliefernicht/h2plugin-sequence-fix
Browse files Browse the repository at this point in the history
H2Plugin seems to initialize sequences with wrong sequence number (off by one)
  • Loading branch information
darkv committed Dec 11, 2014
2 parents f8db539 + f9687a3 commit 59c5cd8
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,7 @@ public NSArray<EOSQLExpression> primaryKeySupportStatementsForEntityGroup(NSArra
String attributeName = result.sqlStringForAttribute(priKeyAttribute);
String tableName = result.sqlStringForSchemaObjectName(entity.externalName());

sql = "CREATE SEQUENCE " + sequenceName + " START WITH (SELECT MAX(" + attributeName + ") FROM " + tableName + ")";
sql = "CREATE SEQUENCE " + sequenceName + " START WITH (SELECT MAX(" + attributeName + ") + 1 FROM " + tableName + ")";
results.addObject(createExpression(entity, sql));

sql = "ALTER TABLE " + tableName + " ALTER COLUMN " + attributeName + " SET DEFAULT nextval('" + sequenceName + "')";
Expand Down

0 comments on commit 59c5cd8

Please sign in to comment.