| 710 | | if value is not None: |
|---|
| 711 | | path = kwarg.split(LOOKUP_SEPARATOR) |
|---|
| 712 | | # Extract the last elements of the kwarg. |
|---|
| 713 | | # The very-last is the lookup_type (equals, like, etc). |
|---|
| 714 | | # The second-last is the table column on which the lookup_type is |
|---|
| 715 | | # to be performed. If this name is 'pk', it will be substituted with |
|---|
| 716 | | # the name of the primary key. |
|---|
| 717 | | # If there is only one part, or the last part is not a query |
|---|
| 718 | | # term, assume that the query is an __exact |
|---|
| 719 | | lookup_type = path.pop() |
|---|
| 720 | | if lookup_type == 'pk': |
|---|
| 721 | | lookup_type = 'exact' |
|---|
| 722 | | path.append(None) |
|---|
| 723 | | elif len(path) == 0 or lookup_type not in QUERY_TERMS: |
|---|
| 724 | | path.append(lookup_type) |
|---|
| 725 | | lookup_type = 'exact' |
|---|
| 726 | | |
|---|
| 727 | | if len(path) < 1: |
|---|
| 728 | | raise TypeError, "Cannot parse keyword query %r" % kwarg |
|---|
| 729 | | |
|---|
| 730 | | joins2, where2, params2 = lookup_inner(path, lookup_type, value, opts, opts.db_table, None) |
|---|
| 731 | | joins.update(joins2) |
|---|
| 732 | | where.extend(where2) |
|---|
| 733 | | params.extend(params2) |
|---|
| | 710 | path = kwarg.split(LOOKUP_SEPARATOR) |
|---|
| | 711 | # Extract the last elements of the kwarg. |
|---|
| | 712 | # The very-last is the lookup_type (equals, like, etc). |
|---|
| | 713 | # The second-last is the table column on which the lookup_type is |
|---|
| | 714 | # to be performed. If this name is 'pk', it will be substituted with |
|---|
| | 715 | # the name of the primary key. |
|---|
| | 716 | # If there is only one part, or the last part is not a query |
|---|
| | 717 | # term, assume that the query is an __exact |
|---|
| | 718 | lookup_type = path.pop() |
|---|
| | 719 | if lookup_type == 'pk': |
|---|
| | 720 | lookup_type = 'exact' |
|---|
| | 721 | path.append(None) |
|---|
| | 722 | elif len(path) == 0 or lookup_type not in QUERY_TERMS: |
|---|
| | 723 | path.append(lookup_type) |
|---|
| | 724 | lookup_type = 'exact' |
|---|
| | 725 | |
|---|
| | 726 | if len(path) < 1: |
|---|
| | 727 | raise TypeError, "Cannot parse keyword query %r" % kwarg |
|---|
| | 728 | |
|---|
| | 729 | if value is None: |
|---|
| | 730 | # Interpret '__exact=None' as the sql '= NULL'; otherwise, reject |
|---|
| | 731 | # all uses of None as a query value. |
|---|
| | 732 | if lookup_type != 'exact': |
|---|
| | 733 | raise ValueError, "Cannot use None as a query value" |
|---|
| | 734 | |
|---|
| | 735 | joins2, where2, params2 = lookup_inner(path, lookup_type, value, opts, opts.db_table, None) |
|---|
| | 736 | joins.update(joins2) |
|---|
| | 737 | where.extend(where2) |
|---|
| | 738 | params.extend(params2) |
|---|