| 31 | | super(WhereNode, self).add(data, connector) |
|---|
| 32 | | return |
|---|
| | 31 | return super(WhereNode, self).add(data, connector) |
|---|
| | 32 | alias, col, field, lookup_type, value = data |
|---|
| | 33 | if not hasattr(field, "_geom"): |
|---|
| | 34 | # Not a geographic field, so call `WhereNode.add`. |
|---|
| | 35 | return super(GeoWhereNode, self).add(data, connector) |
|---|
| | 36 | else: |
|---|
| | 37 | # `GeometryField.get_db_prep_lookup` returns a where clause |
|---|
| | 38 | # substitution array in addition to the parameters. |
|---|
| | 39 | where, params = field.get_db_prep_lookup(lookup_type, value) |
|---|
| 34 | | alias, col, field, lookup_type, value = data |
|---|
| 35 | | # Do we have a geographic field? |
|---|
| 36 | | geo_field = hasattr(field, '_geom') |
|---|
| 37 | | if field: |
|---|
| 38 | | if geo_field: |
|---|
| 39 | | # `GeometryField.get_db_prep_lookup` returns a where clause |
|---|
| 40 | | # substitution array in addition to the parameters. |
|---|
| 41 | | where, params = field.get_db_prep_lookup(lookup_type, value) |
|---|
| 42 | | else: |
|---|
| 43 | | params = field.get_db_prep_lookup(lookup_type, value) |
|---|
| 44 | | db_type = field.db_type() |
|---|
| 45 | | else: |
|---|
| 46 | | # This is possible when we add a comparison to NULL sometimes (we |
|---|
| 47 | | # don't really need to waste time looking up the associated field |
|---|
| 48 | | # object). |
|---|
| 49 | | params = Field().get_db_prep_lookup(lookup_type, value) |
|---|
| 50 | | db_type = None |
|---|
| 51 | | |
|---|
| 52 | | if geo_field: |
|---|
| 58 | | elif isinstance(value, datetime.datetime): |
|---|
| 59 | | annotation = datetime.datetime |
|---|
| 60 | | else: |
|---|
| 61 | | annotation = bool(value) |
|---|
| 62 | | |
|---|
| 63 | | super(WhereNode, self).add((alias, col, db_type, lookup_type, |
|---|
| 64 | | annotation, params), connector) |
|---|
| | 46 | return super(WhereNode, self).add((alias, col, field.db_type(), lookup_type, |
|---|
| | 47 | annotation, params), connector) |
|---|