Vanderhoof/PyDBML

Add reference type to TableReference object

kvaleev opened this issue · 2 comments

It'll be nice to have the type of reference link (<, >, -) stored in TableReference object.

The reason why TableRefrence object doesn't have a type attribute is that it can only be of one type. While in Reference objects the type determines which of the two pairs Table\Field references to the other, the TableReference object is created only for the referencing table.

Example:

Ref: "order_items"."product_id" > "products"."id"

TableReference will be added only to order_items table, referencing products table.

Ref: "products"."id" > "order_items"."product_id" 

TableReference will be added only to products table, referencing order_items table.

So it seems that TableReference doesn't need a type attribute, with one exception, there's no way to determine if the link was one-to-one, it will be rendered as a normal one-to-many reference in SQL (that's the behavior of DBML parser too).

If that's the reason why type attribut may be needed, I suggest two solutions:

  • add a one_to_one attribute to TableReference,
  • add a link to the original Reference object to TableReference.

What do you think?

After discussion in pm we've decided that the type attribute in the Reference object is sufficient