#14441: Oracle list limit exceeded with __in filters
--------------------------------------------+-------------------------------
   Reporter:  DavidMAM                      |                Owner:  nobody    
     Status:  new                           |            Milestone:            
  Component:  Database layer (models, ORM)  |              Version:  1.1       
   Keywords:  Oracle                        |                Stage:  Unreviewed
  Has_patch:  0                             |           Needs_docs:  0         
Needs_tests:  0                             |   Needs_better_patch:  0         
--------------------------------------------+-------------------------------
 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(namefield__in=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.

-- 
Ticket URL: <http://code.djangoproject.com/ticket/14441>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-upda...@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.

Reply via email to