| 604 | |
| 605 | == Change Where node internals == |
| 606 | For anybody writing custom Q-like objects or advanced filter additions with the !QuerySet class, [7773] changed the information that is passed to the Where class by default. A standard leaf node in the Where class used to be |
| 607 | |
| 608 | {{{ |
| 609 | #!python |
| 610 | [table_alias, field_name, field_instance, lookup_type, value] |
| 611 | }}} |
| 612 | |
| 613 | This changeset removed the need to store any field instances (in `field_instance`) or model references (in the `value`). The new list in the leaf nodes is now |
| 614 | |
| 615 | {{{ |
| 616 | #!python |
| 617 | [table_alias, field_name, db_type, lookup_type, value_annotation, params] |
| 618 | }}} |
| 619 | |
| 620 | The `db_type` is the result of `field.db_type()` or `None` if `field` was None previously. The `value_annotation` is usually `bool(value)`, but it is `datetime.datetime` if the previous `value` was a datetime. Finally, `params` is the result of `value.db_prep_lookup()` or equivalent and must be a sequence (so if you're passing in a value directly, wrap it in a list or a tuple). |
| 621 | |
| 622 | Again, this will not affect most code, but people writing customised things will need to adjust. Fortunately, since the list is now one component longer, if you miss a change, your code will fail drastically so you will notice. |