New Topic: ForeignKeys Set in Database Snapshot is incomplete

View: New views
1 Messages — Rating Filter:   Alert me  

New Topic: ForeignKeys Set in Database Snapshot is incomplete

by LiquiBase Community Forum :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

A new topic, 'ForeignKeys Set in Database Snapshot is incomplete', has been made on a board you are watching.

You can see it at
http://liquibase.org/forum/index.php?topic=207.new#new

The text of the topic is shown below:

I'm attempting to use the set of Foreign Keys available in the DatabaseSnapshot and noticed something that is probably a bug, but is at least a little confusing.

It appears that each ForeignKey object in the set has all of the column names for all FKs that reference the PK table's primary key column names. There are the correct number of ForeignKey objects in the set for all the FKs in my database but not all of the FK constraint names or FK table names are represented.

For example, if I have 3 tables: Person, Cat, Dog and both Cat and Dog have an ownerId that references the Person table there are two FKs in my database. These FKs would be represented as:

FK1:
  name: FK_CAT_OWNER
  fk_table: Cat
  fk_columns: ownerId, ownerId
  pk_table: Person
  pk_column: id, id
FK2:
  name: FK_CAT_OWNER
  fk_table: Cat
  fk_columns: ownerId, ownerId
  pk_table: Person
  pk_column: id, id

The set would contain two duplicate FK objects both representing the FK on the Cat table pointing to the Person table. I believe this is because of the way that the set is constructed: it's using the same FK object over and over, but changing it's contents effectively changing the hashcode of the object and leading to duplicates in the set (see SqlDatabaseSnapshot lines 368-370 in readForeignKeyInformation).

This creates two problems for me:
1. Not all FK names are represented meaning that if I used DatabaseSnapshot.getForeignKey(String foreignKeyName) there's a chance that a valid FK constraint would not be returned
2. Even though all the columns are listed in the FK object, you can't match up the correct column name with the correct table name as you only have the last added FK table name even though the FK column names could be coming from multiple tables.

Am I understanding this correctly?

Unsubscribe to new topics from this board by clicking here: http://liquibase.org/forum/index.php?action=notifyboard;board=1.0

Regards,
The LiquiBase Community Forum Team.
------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Liquibase-user mailing list
Liquibase-user@...
https://lists.sourceforge.net/lists/listinfo/liquibase-user