Using postgresql with psycopg2 I was unable to reproduce the issue.
{{{
from django.db import models
class A(models.Model):
pass
class B(models.Model):
a = models.OneToOneField(A)
value = models.IntegerField()
def test():
A.objects.all().delete()
B.objects.all().delete()
A.objects.create()
assert A.objects.exclude(b__value=12345).count() == 1, "We expect to
get one A but got zero."
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/29315>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
Comment (by Tim Graham):
I can't reproduce the issue give what you provided. Can you do any further
investigation such as checking the query that Django generates? Not sure
if it could be a bug in your particular version of SQLite.
--
Ticket URL: <https://code.djangoproject.com/ticket/29315#comment:1>
Comment (by Raphael Kimmig):
I just tried reproducing the bug on Debian 9 and I can't.
I'm running mac os 10.12.6 on the affected machine.
The query produced looks fine:
{{{
SELECT "bar_a"."id" FROM "bar_a" LEFT OUTER JOIN "bar_b" ON ("bar_a"."id"
= "bar_b"."a_id") WHERE NOT ("bar_b"."value" = 12345 AND "bar_b"."value"
IS NOT NULL) LIMIT 21
}}}
sqlite version on the affected mac:
{{{
sqlite3.version
>>> '2.6.0'
sqlite3.sqlite_version
>>> '3.23.0'
}}}
Is there anything else that might be helpful?
--
Ticket URL: <https://code.djangoproject.com/ticket/29315#comment:2>
* status: new => closed
* resolution: => invalid
Comment:
I noticed "Fix two problems in the new LEFT JOIN strength reduction
optimization." in the [https://sqlite.org/changes.html#version_3_23_1
SQLite 3.23.1 release notes] which looks like it could be the cause.
--
Ticket URL: <https://code.djangoproject.com/ticket/29315#comment:3>