LukeSavefrogs

Untitled

Aug 6th, 2026
31
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.71 KB | None | 0 0
  1. json.dumps(
  2.     {
  3.         "tables": {
  4.             f'"{model.schema}"."{model.table}"': {
  5.                 "columns": model.columns,
  6.                 "relations": {
  7.                     "explicit": [
  8.                         {
  9.                             "source": str(rel.source),
  10.                             "destination": str(rel.destination),
  11.                         }
  12.                         for rel in (
  13.                             model.explicit_relations
  14.                             if args.output_direction == "foreign-to-primary"
  15.                             else [
  16.                                 rel
  17.                                 for related_model in schema.tables
  18.                                 for rel in related_model.explicit_relations
  19.                                 if rel.destination == model
  20.                             ]
  21.                         )
  22.                     ],
  23.                     "implicit": [
  24.                         {
  25.                             "source": str(rel.source),
  26.                             "destination": str(rel.destination),
  27.                         }
  28.                         for rel in (
  29.                             model.implicit_relations
  30.                             if args.output_direction == "foreign-to-primary"
  31.                             else [
  32.                                 rel
  33.                                 for related_model in schema.tables
  34.                                 for rel in related_model.implicit_relations
  35.                                 if rel.destination == model
  36.                             ]
  37.                         )
  38.                     ],
  39.                 },
  40.             }
  41.             for model in schema.tables
  42.         }
  43.     }
  44. )
Advertisement
Add Comment
Please, Sign In to add comment