PATCH Improve compatibility with PostgreSQL and other DB
. Fixed: Cannot operate on a closed cursor (BitNami Trac Stack / PySqlite on UNIX/LINUX environment)
. Fixed: syntax error at or near "asc" (PostgreSQL <= 8.2)
Index: ganttcalendar/admin.py =================================================================== --- ganttcalendar/admin.py (revision 827) +++ ganttcalendar/admin.py (working copy) @@ -34,14 +34,18 @@ yield ('ganttcalendar', u'Ganttcalendar', 'holiday', _('Holiday Setting')) def render_admin_panel(self, req, cat, page, path_info): - tbl_chk = True + + def tbl_exist( exist=True ): + db = self.env.get_db_cnx() + cursor = db.cursor() + try: cursor.execute("SELECT count(*) from holiday") + except: exist = False + return exist + ######################## + + tbl_chk = tbl_exist() db = self.env.get_db_cnx() cursor = db.cursor(); - sql = "SELECT count(*) from holiday" - try: - cursor.execute(sql) - except: - tbl_chk = False if req.method == 'POST': if req.args.get('add'): @@ -89,10 +93,10 @@ db_type = self.config['trac'].get('database').split(':')[0].lower() if db_type != 'mysql': # SQLite, PostgreSQL - sql = "CREATE UNIQUE INDEX idx_holiday ON holiday(date ASC)" + sql = "CREATE UNIQUE INDEX idx_holiday ON holiday (date)" else: # MySQL - sql = "CREATE UNIQUE INDEX idx_holiday ON holiday(date(10) ASC)" + sql = "CREATE UNIQUE INDEX idx_holiday ON holiday (date(10))" cursor.execute(sql) db.commit() for h in holidays_tbl.keys(): Index: ganttcalendar/complete_by_close.py =================================================================== --- ganttcalendar/complete_by_close.py (revision 827) +++ ganttcalendar/complete_by_close.py (working copy) @@ -38,7 +38,8 @@ return old_values[field] # for INSERT: save_ticket_change else: - cursor = self.env.get_db_cnx().cursor() + db = self.env.get_db_cnx() + cursor = db.cursor() cursor.execute("SELECT * FROM ticket_custom where ticket=%s and name=%s" , (ticket.id, field)) val = cursor.fetchone() if val:
Applied in r836 and r837. Thanks for the report and the patch!
. Fixed: Cannot operate on a closed cursor (BitNami Trac Stack / PySqlite on UNIX/LINUX environment)
. Fixed: syntax error at or near "asc" (PostgreSQL <= 8.2)