You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

46 lines
993 B

  1. from django.db.models import Lookup, Transform
  2. class PostgresSimpleLookup(Lookup):
  3. def as_sql(self, qn, connection):
  4. lhs, lhs_params = self.process_lhs(qn, connection)
  5. rhs, rhs_params = self.process_rhs(qn, connection)
  6. params = lhs_params + rhs_params
  7. return '%s %s %s' % (lhs, self.operator, rhs), params
  8. class DataContains(PostgresSimpleLookup):
  9. lookup_name = 'contains'
  10. operator = '@>'
  11. class ContainedBy(PostgresSimpleLookup):
  12. lookup_name = 'contained_by'
  13. operator = '<@'
  14. class Overlap(PostgresSimpleLookup):
  15. lookup_name = 'overlap'
  16. operator = '&&'
  17. class HasKey(PostgresSimpleLookup):
  18. lookup_name = 'has_key'
  19. operator = '?'
  20. class HasKeys(PostgresSimpleLookup):
  21. lookup_name = 'has_keys'
  22. operator = '?&'
  23. class HasAnyKeys(PostgresSimpleLookup):
  24. lookup_name = 'has_any_keys'
  25. operator = '?|'
  26. class Unaccent(Transform):
  27. bilateral = True
  28. lookup_name = 'unaccent'
  29. function = 'UNACCENT'