[ http://issues.apache.org/jira/browse/DDLUTILS-106?page=comments#action_12383278 ]
Thomas Dudziak commented on DDLUTILS-106: ----------------------------------------- DdlUtils already contains a decent algorithm for generating a foreign key name that leads to good results. The problem is that it is next to impossible to generate unique foreign key names that are reproducable (otherwise you simply could use some GUID algorithm). So, you should always specify a foreign key name to avoid issues like this. I can however add a simple check which tests that no other foreign key within the model would produce the same name. Everything else (e.g. checking against the database) is not much of an option because the SQL written to a file is required to be the same as the SQL executed against the database. > Long similar foreign key names are shortened to conflicting names > ----------------------------------------------------------------- > > Key: DDLUTILS-106 > URL: http://issues.apache.org/jira/browse/DDLUTILS-106 > Project: DdlUtils > Type: Bug > Components: Core > Reporter: Christoffer Hammarström > Assignee: Thomas Dudziak > > In my generated sql for Oracle, i find the following two conflicting > statements: > ALTER TABLE doc_permission_sets > ADD CONSTRAINT doc_permission_ermission_sets FOREIGN KEY (set_id) > REFERENCES permission_sets (set_id); > and > ALTER TABLE doc_permission_sets_ex > ADD CONSTRAINT doc_permission_ermission_sets FOREIGN KEY (set_id) > REFERENCES permission_sets (set_id); > The tables have similar names, and the foreign key names conflict. > Oracle gives the following error when trying to run the sql: > ORA-02264: name already used by an existing constraint > Maybe SqlBuilder.shortenName() could use some kind of counter for conflicting > names? -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira
