Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Major
-
Resolution: Duplicate
-
Affects Version/s: Grails-Database-Migration 1.1
-
Fix Version/s: None
-
Labels:None
-
Environment:Grails: 2.0.3
JVM: sun jdk1.6.0_31
DB: h2-1.3.164
OS: Debian GNU/Linux 6.0
Description
Given a domain object with a unique index on two fields - one of which is the object owner - I systematically get an error message executing the generated changelog on a h2 database. It complains: dbcSQLException: Syntax error in SQL statement "CREATE INDEX UNIQUE[*]-CHILD_POS ON FOO(PARENT_ID, CHILD_POS) "; expected "identifier"; SQL statement:
CREATE INDEX unique-child_pos ON foo(parent_id, child_pos) [42001-164]
Here's the relevant portion of the changelog
changelog.groovy
...
changeSet(author: "davide (generated)", id: "1337257962240-2") {
createIndex(indexName: "unique-child_pos", tableName: "foo") {
column(name: "parent_id")
column(name: "child_pos")
}
}
...
It seems like the plugin "somewhat misread" the 'unique' keyword, generating an invalid indexName (unique-child_pos). I guess it would be quoted when containing chars other than: A-Z>|_ (see h2 sql grammar).
The domain object code is
grails-app/domain/grails_test/Foo.groovy
package grails_test class Foo { int childPos = -1 static belongsTo = [parent: Foo] static mapping = { sort 'childPos' } static constraints = { parent (nullable: true) childPos (unique: ['parent'])//childPos is unique (given a certain parent) } }
Btw grails_test.zip
is a complete test project.
-
Hide
- grails_test.zip
- 17/May/12 6:19 AM
- 144 kB
- Davide Cavestro
-
- grails_test/application.properties 0.2 kB
- grails_test/target/stacktrace.log 89 kB
- grails_test/web-app/js/application.js 0.2 kB
- grails_test/web-app/.../leftnav_top.png 3 kB
- grails_test/web-app/.../apple-touch-icon.png 5 kB
- grails_test/web-app/.../skin/information.png 0.8 kB
- grails_test/web-app/.../database_table.png 0.7 kB
- grails_test/web-app/.../skin/sorted_asc.gif 0.8 kB
- grails_test/web-app/.../skin/house.png 0.8 kB
- grails_test/web-app/.../skin/shadow.jpg 0.3 kB
- grails_test/web-app/.../skin/sorted_desc.gif 0.8 kB
- grails_test/web-app/.../database_delete.png 0.6 kB
- grails_test/web-app/.../database_edit.png 0.7 kB
- grails_test/web-app/.../skin/exclamation.png 0.7 kB
- grails_test/web-app/.../database_add.png 0.6 kB
- grails_test/web-app/.../database_save.png 0.7 kB
- grails_test/web-app/images/favicon.ico 10 kB
- grails_test/web-app/.../springsource.png 9 kB
- grails_test/.../apple-touch-icon-retina.png 15 kB
- grails_test/web-app/images/spinner.gif 2 kB
- grails_test/web-app/.../grails_logo.png 10 kB
- grails_test/web-app/.../leftnav_btm.png 4 kB
- grails_test/.../leftnav_midstretch.png 3 kB
- grails_test/web-app/.../grails_logo.jpg 8 kB
- grails_test/web-app/WEB-INF/sitemesh.xml 0.6 kB
- grails_test/.../applicationContext.xml 1 kB
- grails_test/web-app/WEB-INF/tld/c.tld 16 kB
- grails_test/web-app/WEB-INF/tld/fmt.tld 19 kB
- grails_test/web-app/.../tld/grails.tld 18 kB
- grails_test/web-app/.../tld/spring.tld 7 kB
Activity
Show
Burt Beckwith
added a comment - Duplicate of GPDATABASEMIGRATION-48
Removed compiled files from test project