Modify

Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#10978 closed defect (fixed)

"operator does not exist: bigint = timestamp with time zone" with Postgres

Reported by: dave@… Owned by: Russ Tyndall
Priority: normal Component: TimingAndEstimationPlugin
Severity: normal Keywords:
Cc: Trac Release: 1.0

Description

I'm not sure what triggers this, or what effect it has, but I'm getting a bunch of these in my trac.log:

2013-03-27 12:21:03,479 Trac[dbhelper] ERROR: There was a problem executing sql:DELETE FROM ticket_change  
             WHERE ticket=%s and author=%s and time=%s and field=%s 
     with parameters:(58138, u'dave', datetime.datetime(2013, 3, 27, 17, 21, 3, 277000, tzinfo=<FixedOffset "UTC" 0:00:00>), 'hours')
Exception:operator does not exist: bigint = timestamp with time zone
LINE 2: ...     WHERE ticket=58138 and author='dave' and time='2013-03-...
                                                             ^
HINT:  No operator matches the given name and argument type(s). You might need to add explicit type casts.
Traceback (most recent call last):
  File "build\bdist.win32\egg\timingandestimationplugin\dbhelper.py", line 59, in execute_in_trans
    @env.with_transaction()
  File "C:\Python27\lib\site-packages\trac-1.0.1-py2.7-win32.egg\trac\db\api.py", line 97, in transaction_wrapper
    fn(ldb)
  File "build\bdist.win32\egg\timingandestimationplugin\dbhelper.py", line 65, in fn
    cur.execute(sql, params)
  File "C:\Python27\lib\site-packages\trac-1.0.1-py2.7-win32.egg\trac\db\util.py", line 65, in execute
    return self.cursor.execute(sql_escape_percent(sql), args)
ProgrammingError: operator does not exist: bigint = timestamp with time zone
LINE 2: ...     WHERE ticket=58138 and author='dave' and time='2013-03-...
                                                             ^
HINT:  No operator matches the given name and argument type(s). You might need to add explicit type casts.

TimingAndEstimationPlugin 0.12 with permissions branch, Trac 1.0.1, PostgreSQL database.

Perhaps this is the fix?

  • timingandestimationplugin/ticket_daemon.py

     
    6969
    7070def delete_ticket_change( comp, ticket_id, author, change_time, field):
    7171    """ removes a ticket change from the database """
     72    if type(change_time) == datetime.datetime:
     73        change_time = to_timestamp(change_time)
    7274    sql = """DELETE FROM ticket_change 
    7375             WHERE ticket=%s and author=%s and time=%s and field=%s"""
    7476    dbhelper.execute_non_query(comp.env, sql, ticket_id, author, change_time, field)

Attachments (0)

Change History (4)

comment:1 Changed 4 years ago by Ryan J Ollos

I don't know anything about this change, but I would just add that a more common pattern I see in the Trac codebase is:

if isinstance(change_time, datetime.datetime)

... so I would assume that is the more Pythonic way to do a comparison.

comment:2 Changed 4 years ago by Russ Tyndall

(In [12828]) use ensure correct timestamp type in delete_ticket_change re #10978

comment:3 Changed 4 years ago by Russ Tyndall

Resolution: fixed
Status: newclosed

Thanks for the bug report and proposed fix! I am using the non-permissions branch primarily, so I definitely appreciate the help finding / fixing these bugs.

Cheers, Russ

comment:4 Changed 4 years ago by Russ Tyndall

(In [12829]) use isinstance instead of checking types eql re #10978

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Russ Tyndall.
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.