#The weirdest bug I've ever seen

5 messages · Page 1 of 1 (latest)

dire igloo
#

Ok so get this.

I have an object "DiscountCode", with a CharField "code".
I have a specific discount code in my SQLite3 database.

The error is that when I write DiscountCode.objects.get(code=thecode), I get a DoesNotExist error.

And yet, it exists.

If I replace the get(code=thecode) with get(code__startswith=thecode), it succeeds.
if I run discount_code.code == thecode, I get True.

They are THE SAME.

I looked into my database.
The code is correctly formatted when I look at it in text mode or binary mode. No weird special characters or invisible whitespaces.
No other discountcode is affected. I can find all the other ones.

I have NO IDEA how to go forward from here.
If you have an idea, I am all ears.

deep mirage
wanton obsidian
#

exactly

deep mirage
#

I would check that the queries from your example do the same thing. If this is local only, I'd uninstall django and reinstall it in case you changed a file in your site-packages/ directory

vernal oasis
#

If you have an index on your field it might be corrupted (potential SQLite bug) and the code = ? lookup tries to use it while it's not used for the code LIKE ? lookup.

Another thing at play might be collations but it doesn't look like you're using a special one here?