Opened 17 years ago
Closed 17 years ago
#5367 closed (worksforme)
sqlite3+ManyToManyField: unable to link to 1000 (or more) objects.
Reported by: | Owned by: | nobody | |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | dev |
Severity: | 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
With DATABASE_ENGINE = 'sqlite3'
and the following foo/models.py
:
from django.db import models class Foo(models.Model): pass class Bar(models.Model): foos = models.ManyToManyField(Foo)
I try:
>>> from foo import models >>> models.Foo.objects.all().count() 1733 >>> bar = models.Bar(1) >>> bar.foos = models.Foo.objects.all()[:1000] Traceback (most recent call last): File "<console>", line 1, in ? File "/var/lib/python-support/python2.4/django/db/models/fields/related.py", line 460, in __set__ manager.add(*value) File "/var/lib/python-support/python2.4/django/db/models/fields/related.py", line 287, in add self._add_items(self.source_col_name, self.target_col_name, *objs) File "/var/lib/python-support/python2.4/django/db/models/fields/related.py", line 338, in _add_items [self._pk_val] + list(new_ids)) File "/var/lib/python-support/python2.4/django/db/backends/util.py", line 19, in execute return self.cursor.execute(sql, params) File "/var/lib/python-support/python2.4/django/db/backends/sqlite3/base.py", line 129, in execute return Database.Cursor.execute(self, query, params) OperationalError: too many SQL variables
Change History (3)
comment:1 by , 17 years ago
comment:2 by , 17 years ago
Worked without any problem
>>> from abc.models import * >>> for i in range(2000): Foo().save() >>> print Foo.objects.all().count() 2000 >>> bar = Bar(1) >>> bar.foos = Foo.objects.all()[:1000] >>> bar.save() >>>
I'd suggest you to post SQL queries fired by django.
comment:3 by , 17 years ago
Resolution: | → worksforme |
---|---|
Status: | new → closed |
Note:
See TracTickets
for help on using tickets.
This feels like a built-in limit of SQLite; you may need to break this up into multiple operations.