Opened 14 years ago

Last modified 14 years ago

#14441 closed

Oracle list limit exceeded with __in filters — at Initial Version

Reported by: DavidMAM Owned by: nobody
Component: Database layer (models, ORM) Version: 1.1
Severity: Keywords: Oracle
Cc: Triage Stage: Design decision needed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Trying to retrieve a set of objects based on field values. I build the set of values as an array

namelist=[]

.. some code that does namelist.append(name) many times

obl=MyObject.objects.filter(namefieldin=namelist)

obl.count()
if namelist is longer than 1000 then Oracle throws an error
Traceback (most recent call last):

File "<console>", line 1, in <module>
File "/usr/local/lib/python2.6/site-packages/django/db/models/query.py", line 292, in count

return self.query.get_count()

File "/usr/local/lib/python2.6/site-packages/django/db/models/sql/query.py", line 376, in get_count

number = obj.get_aggregation()[None]

File "/usr/local/lib/python2.6/site-packages/django/db/models/sql/query.py", line 348, in get_aggregation

result = query.execute_sql(SINGLE)

File "/usr/local/lib/python2.6/site-packages/django/db/models/sql/query.py", line 2369, in execute_sql

cursor.execute(sql, params)

File "/usr/local/lib/python2.6/site-packages/django/db/backends/util.py", line 19, in execute

return self.cursor.execute(sql, params)

File "/usr/local/lib/python2.6/site-packages/django/db/backends/oracle/base.py", line 443, in execute

raise e

DatabaseError: ORA-01795: maximum number of expressions in a list is 1000

I don't know if there is an easy way to combine querysets as splitting them into batches of a suitable number would be no problem if they could be combined later.

Change History (0)

Note: See TracTickets for help on using tickets.
Back to Top