Opened 10 years ago
Closed 10 years ago
#25843 closed Bug (worksforme)
Ampersands in icontains filter returns inconsistent results
| Reported by: | Gady Pitaru | Owned by: | nobody |
|---|---|---|---|
| Component: | Database layer (models, ORM) | Version: | 1.6 |
| Severity: | Normal | Keywords: | |
| Cc: | Triage Stage: | Unreviewed | |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
Ampersands in icontains filter returns inconsistent results based on if the ampersand is the last character or not. Replacing the ampersand character with & fixes the issue. The following examples illustrate the issue, assuming there is one record with field = 'Fish & Chips':
query1 = 'Fish &' Model.objects.filter(field__icontains=query1) # returns a result query2 = 'Fish & Chips' Model.objects.filter(field__icontains=query2) # returns no results query3 = 'Fish & Chips' Model.objects.filter(field__icontains=query3) # returns a result
Note:
See TracTickets
for help on using tickets.
Hi gadybadger,
Unfortunately I cannot reproduce against Django 1.6 (which is not supported anymore), 1.8 and master.
I suppose the data is actually saved as
'Fish & Chips'in your database in the first place.Are you sure you don't use some third party WYSIWYG editor on the front end that could be interfering here?