Opened 8 years ago

Closed 8 years ago

#5558 closed (invalid)

istartswith lookup fails with ORACLE in r6393

Reported by: frank.hoffsummer@… Owned by: mboersma
Component: Database layer (models, ORM) Version: master
Severity: Keywords: Oracle oracle db backend startswith istartswith
Cc: ian.g.kelly@… Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description (last modified by ubernostrum)

I have an Oracle9i database and access that from a PowerPC Mac using the latest cx_Oracle 4.3.1 and python 2.5.1
filtering a queryset with startswith or istartswith returns the following oracle error
(this seems to be model independent, and not related to my code)

In [27]: JobStatus.objects.filter(channel__name__istartswith="a")
Out[27]: ---------------------------------------------------------------------------
<class 'cx_Oracle.DatabaseError'>         Traceback (most recent call last)

/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/mcc/<ipython console> in <module>()

/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/IPython/Prompts.py in __call__(self, arg)
    521 
    522             # and now call a possibly user-defined print mechanism
--> 523             manipulated_val = self.display(arg)
    524 
    525             # user display hooks can change the variable to be stored in

/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/IPython/Prompts.py in _display(self, arg)
    545         """
    546 
--> 547         return self.shell.hooks.result_display(arg)
    548 
    549     # Assign the default display method:

/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/IPython/hooks.py in __call__(self, *args, **kw)
    132             #print "prio",prio,"cmd",cmd #dbg
    133             try:
--> 134                 ret = cmd(*args, **kw)
    135                 return ret
    136             except ipapi.TryNext, exc:

/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/IPython/hooks.py in result_display(self, arg)
    160 
    161     if self.rc.pprint:
--> 162         out = pformat(arg)
    163         if '\n' in out:
    164             # So that multi-line strings line up with the left column of

/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/pprint.py in pformat(self, object)
    109     def pformat(self, object):
    110         sio = _StringIO()
--> 111         self._format(object, sio, 0, 0, {}, 0)
    112         return sio.getvalue()
    113 

/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/pprint.py in _format(self, object, stream, indent, allowance, context, level)
    127             self._readable = False
    128             return
--> 129         rep = self._repr(object, context, level - 1)
    130         typ = _type(object)
    131         sepLines = _len(rep) > (self._width - 1 - indent - allowance)

/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/pprint.py in _repr(self, object, context, level)
    193     def _repr(self, object, context, level):
    194         repr, readable, recursive = self.format(object, context.copy(),
--> 195                                                 self._depth, level)
    196         if not readable:
    197             self._readable = False

/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/pprint.py in format(self, object, context, maxlevels, level)
    205         and whether the object represents a recursive construct.
    206         """
--> 207         return _safe_repr(object, context, maxlevels, level)
    208 
    209 

/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/pprint.py in _safe_repr(object, context, maxlevels, level)
    290         return format % _commajoin(components), readable, recursive
    291 
--> 292     rep = repr(object)
    293     return rep, (rep and not rep.startswith('<')), False
    294 

/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/db/models/query.py in __repr__(self)
    106 
    107     def __repr__(self):
--> 108         return repr(self._get_data())
    109 
    110     def __len__(self):

/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/db/models/query.py in _get_data(self)
    480     def _get_data(self):
    481         if self._result_cache is None:
--> 482             self._result_cache = list(self.iterator())
    483         return self._result_cache
    484 

/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/db/backends/oracle/base.py in iterator(self)
    120 
    121                 cursor = connection.cursor()
--> 122                 cursor.execute(full_query, params)
    123 
    124                 fill_cache = self._select_related

/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/db/backends/util.py in execute(self, sql, params)
     17         start = time()
     18         try:
---> 19             return self.cursor.execute(sql, params)
     20         finally:
     21             stop = time()

/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/db/backends/oracle/base.py in execute(self, query, params)
    468             query = query[:-1]
    469         query = smart_str(query, self.charset) % tuple(args)
--> 470         return Database.Cursor.execute(self, query, params)
    471 
    472     def executemany(self, query, params=None):

<class 'cx_Oracle.DatabaseError'>: ORA-01425: escape character must be character string of length 1

Change History (6)

comment:1 Changed 8 years ago by mboersma

  • Needs documentation unset
  • Needs tests unset
  • Owner changed from nobody to mboersma
  • Patch needs improvement unset
  • Status changed from new to assigned

comment:2 Changed 8 years ago by mboersma

  • Cc ian.g.kelly@… added

comment:3 follow-up: Changed 8 years ago by ikelly

  • Keywords oracle db backend startswith istartswith added

It works for me. Frank, can you find out for us what query is actually being executed?

comment:4 Changed 8 years ago by ubernostrum

  • Description modified (diff)

(fixing formatting in description)

comment:5 in reply to: ↑ 3 ; follow-up: Changed 8 years ago by anonymous

Replying to ikelly:

It works for me. Frank, can you find out for us what query is actually being executed?

the problem is, ever since updating django to latest trunk (with unicode-branch changes) I cannot get my debug view up
as soon as I have a mistake somewhere, I get a UnicodeDecodeError.
I described that problem here: http://groups.google.se/group/django-developers/browse_thread/thread/54bf180fca0cd124/188ab761ec6411de
but have not manage to solve it unfortunately.

So to move things forward in my project in any case, I debugged my view on the python prompt, doing step-by-step execution of my code.

Thats how I got to this oracle error...

comment:6 in reply to: ↑ 5 Changed 8 years ago by anonymous

  • Resolution set to invalid
  • Status changed from assigned to closed

Replying to anonymous:

Replying to ikelly:

It works for me. Frank, can you find out for us what query is actually being executed?

the problem is, ever since updating django to latest trunk (with unicode-branch changes) I cannot get my debug view up
as soon as I have a mistake somewhere, I get a UnicodeDecodeError.
I described that problem here: http://groups.google.se/group/django-developers/browse_thread/thread/54bf180fca0cd124/188ab761ec6411de
but have not manage to solve it unfortunately.

So to move things forward in my project in any case, I debugged my view on the python prompt, doing step-by-step execution of my code.

Thats how I got to this oracle error...

ok I figured it out now.

the problems with me not getting the Debug view to work were related to Ticket 5588 that I just filed.

with that change in place (and the Django Debug view reinstated), I cannot reproduce this problems

sorry for filing this ticket prematurely, and thanks for bringing Oracle support to django (and making it work so well)!

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