MCPcopy
hub / github.com/dbcli/pgcli / extend_foreignkeys

Method extend_foreignkeys

pgcli/pgcompleter.py:268–286  ·  view source on GitHub ↗
(self, fk_data)

Source from the content-addressed store, hash-verified

266 }
267
268 def extend_foreignkeys(self, fk_data):
269 # fk_data is a list of ForeignKey namedtuples, with fields
270 # parentschema, childschema, parenttable, childtable,
271 # parentcolumns, childcolumns
272
273 # These are added as a list of ForeignKey namedtuples to the
274 # ColumnMetadata namedtuple for both the child and parent
275 meta = self.dbmetadata["tables"]
276
277 for fk in fk_data:
278 e = self.escaped_names
279 parentschema, childschema = e([fk.parentschema, fk.childschema])
280 parenttable, childtable = e([fk.parenttable, fk.childtable])
281 childcol, parcol = e([fk.childcolumn, fk.parentcolumn])
282 childcolmeta = meta[childschema][childtable][childcol]
283 parcolmeta = meta[parentschema][parenttable][parcol]
284 fk = ForeignKey(parentschema, parenttable, parcol, childschema, childtable, childcol)
285 childcolmeta.foreignkeys.append(fk)
286 parcolmeta.foreignkeys.append(fk)
287
288 def extend_datatypes(self, type_data):
289 # dbmetadata['datatypes'][schema_name][type_name] should store type

Callers 2

get_completerMethod · 0.95
refresh_tablesFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected