-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement lookups on values within composite types #9
Comments
+1 |
Hey, is there any active work being done on this, or is there any reference to how one will provide filtering in composite types. |
No, I've worked on this package on an as-needs basis only. So unfortunately if you want this feature you're going to have to work out how to make it work. It is possible to filter on the whole tuple (e.g. using structs as structured keys). If you wanted a quick solution, you could write a lookup function (class You could also consider Postgres' JSON field, the jsonpath support is quite robust now. |
Hi all, feedback welcome on PR linked above if you're still interested in this and have a chance to try it out. Or, if you prefer, the work-around for a single case I was using prior to working that up to cover all members was: class SomeType(CompositeType):
member = # ...
SomeField = SomeType.Field
@SomeField.register_lookup
class SomeMemberLookup(django.db.models.Transform):
lookup_name = "member"
col_name = next(
filter(
lambda af: af[1].attname == "member",
SomeType._meta.fields, # pylint: disable=protected-access
)
)[1].column
arity = 1
template = f'(%(expressions)s)."{col_name}"' |
It should be possible to do a lookup on a composite type:
The text was updated successfully, but these errors were encountered: