File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed
text_2_sql/data_dictionary Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -53,6 +53,14 @@ def pivot(self):
5353
5454 def add_foreign_key (self , foreign_key : ForeignKeyRelationship ):
5555 """A method to add a foreign key to the entity relationship."""
56+
57+ for existing_foreign_key in self .foreign_keys :
58+ if (
59+ existing_foreign_key .column == foreign_key .column
60+ and existing_foreign_key .foreign_column == foreign_key .foreign_column
61+ ):
62+ return
63+
5664 self .foreign_keys .append (foreign_key )
5765
5866 @classmethod
@@ -328,6 +336,11 @@ def get_entity_relationships_from_graph(
328336 successors_not_visited = [
329337 successor for successor in successors if successor not in visited
330338 ]
339+
340+ if len (path ) == 1 and entity in successors :
341+ # We can do a self join on the entity in this case but we don't want to propagate this
342+ result .append (f"{ entity } -> { entity } " )
343+
331344 if len (successors_not_visited ) == 0 and len (path ) > 1 :
332345 # Add the complete path to the result as a string
333346 result .append (" -> " .join (path ))
You can’t perform that action at this time.
0 commit comments