Skip to content

Commit

Permalink
fix: nested orderBy working with DSL
Browse files Browse the repository at this point in the history
  • Loading branch information
0xMochan committed May 17, 2023
1 parent 4fbc3fc commit 7e320e8
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions subgrounds/subgraph/fieldpath.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ def fieldpaths_of_object(
yield subgraph.__getattribute__(object_.name).__getattribute__(
fmeta.name
).id

case _:
yield subgraph.__getattribute__(object_.name).__getattribute__(
fmeta.name
Expand Down Expand Up @@ -456,13 +457,11 @@ def fmt_arg(name, raw_arg):
case ("where", [Filter(), *_] as filters):
return Filter.to_dict(filters)
case ("orderBy", FieldPath() as fpath):
match fpath._leaf:
case TypeMeta.FieldMeta() as fmeta:
return fmeta.name
case _:
raise Exception(
f"Cannot use non field {fpath} as orderBy argument"
)
if paths := fpath._name_path():
return "__".join(paths)
raise Exception(
f"Cannot use empty paths as orderBy argument {fpath}"
)
case _:
return raw_arg

Expand Down

0 comments on commit 7e320e8

Please sign in to comment.