Quantcast

db-reverse-engineer multi column unique

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

db-reverse-engineer multi column unique

wdbetts
Grails 1.3.7
plugins.db-reverse-engineer=0.3

When I reverse engineer a table that has a multi-column unique constraint (index), I get the name of the column in the unique constraint instead of the name of the domain class properties (http://grails.org/doc/latest/ref/Constraints/unique.html).

Ex: I get

login(unique:['GROUP_ID','DEPARTMENT_ID'])
instead of

login(unique:['group','department'])

I am trying to modify the plugin to fix this, but in GrailsEntityPOJOClass:renderConstraints line 317 I cannot figure out how to get from the column name to the property name:

clazz.table.uniqueKeyIterator.each { UniqueKey key ->
if (key.columnSpan == 1 || key?.name == clazz.table.primaryKey?.name) return
if (key.columns[-1] == column) {
def otherNames = key.columns[0..-2].collect { "\"$it.name\"" }
values.unique = '[' + otherNames.reverse().join(', ') + ']'
}
}

Any thoughts on how to get the property of the unique constraint participants instead of the column name?

Thanks,
-- david
Loading...