Opened 16 years ago

Closed 16 years ago

Last modified 16 years ago

#3239 closed defect (fixed)

Get database error when using CAST( .. AS ..) syntax

Reported by: nicolasm@… Owned by: Emilien Klein
Priority: normal Component: TicketModifiedFilesPlugin
Severity: normal Keywords:
Cc: Trac Release: 0.11


I get this error after installing this plugin:

11:08:47 Trac[__init__] ERROR: near "as": syntax error
Traceback (most recent call last):
  File "/usr/lib/python2.4/site-packages/Trac-0.11-py2.4.egg/trac/web/", line 423, in _dispatch_request
  File "/usr/lib/python2.4/site-packages/Trac-0.11-py2.4.egg/trac/web/", line 219, in dispatch
    data, content_type)
  File "/usr/lib/python2.4/site-packages/Trac-0.11-py2.4.egg/trac/web/", line 690, in render_template
    stream |= self._filter_stream(req, method, filename, stream, data)
  File "/usr/lib/python2.4/site-packages/Genshi-0.5-py2.4-linux-i686.egg/genshi/", line 128, in __or__
  File "/usr/lib/python2.4/site-packages/Trac-0.11-py2.4.egg/trac/web/", line 789, in inner
  File "build/bdist.linux-i686/egg/ticketmodifiedfiles/", line 78, in filter_stream
  File "build/bdist.linux-i686/egg/ticketmodifiedfiles/", line 137, in __process_ticket_request
  File "/usr/lib/python2.4/site-packages/Trac-0.11-py2.4.egg/trac/db/", line 51, in execute
    return self.cursor.execute(sql)
  File "/usr/lib/python2.4/site-packages/sqlite/", line 244, in execute = self.con.db.execute(SQL)
DatabaseError: near "as": syntax error

I have fixed it temporarily with:

Line 137:
-            cursor.execute("SELECT change_type FROM node_change WHERE path='" + file + "' ORDER BY CAST(rev as integer) DESC LIMIT 1")
+            cursor.execute("SELECT change_type FROM node_change WHERE path='" + file + "' ORDER BY 1*rev DESC LIMIT 1")

I think I have new enough sqlite installed, but who knows...

Attachments (0)

Change History (4)

comment:1 Changed 16 years ago by Emilien Klein

Status: newassigned

Yes, this happens if you use SQLite < 3.2.3 (the CAST operator has been added to SQLite 3.2.3) Which version do you use?

Anyway, I am going to use your hack, as it seems that Trac itself uses 1*column.

comment:2 Changed 16 years ago by Emilien Klein

Resolution: fixed
Status: assignedclosed

fixed in r3891.

comment:3 Changed 16 years ago by nicolasm@…

$ dpkg -l sqlite
| Status=Not/Installed/Config-files/Unpacked/Failed-config/Half-installed
|/ Err?=(none)/Hold/Reinst-required/X=both-problems (Status,Err: uppercase=bad)
||/ Name                              Version                           Description
ii  sqlite                            2.8.17-2                          command line interface for SQLite

stock debian

thanks ;)

comment:4 Changed 16 years ago by nicolasm@…

stock debian etch that is

Modify Ticket

Change Properties
Set your email in Preferences
as closed The owner will remain Emilien Klein.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment

E-mail address and name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.