Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am martsberger on github.
  • I am bmartsberger (https://keybase.io/bmartsberger) on keybase.
  • I have a public key ASBMCwyy1IBaWXBKAEnUOPPwIwUrk2dzsvYhQRkjOna_2wo

To claim this, I am signing this object:

@martsberger
martsberger / risk_subquery.py
Created January 23, 2018 04:46
Azee Risk Subqueries
# You can put the EqualsAny class in a utility file somewhere, It's necessary
# in order to compare the result of ArrayAgg with a column
from django.db.models import Field
@Field.register_lookup
class EqualsAny(Lookup):
"""
Adds the `__any` lookup for generating SQL like:
Parent.objects.annotate(child_count=Count('child'))