Ticket #29009

PATCH Improve compatibility with PostgreSQL and other DB

오픈 날짜: 2012-07-16 07:56 마지막 업데이트: 2013-04-26 23:40

Reporter:
(Anonymous)
소유자:
(None)
Type:
Status:
Closed
Component:
MileStone:
(None)
Priority:
9 - Highest
Severity:
5 - Medium
Resolution:
Fixed
File:
None

Details

. 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)

ASC Syntax is included implicitly by default.
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:

Ticket History (2/2 Histories)

2012-07-16 07:56 Updated by: None
  • New Ticket "PATCH Improve compatibility with PostgreSQL and other DB" created
2013-04-26 23:40 Updated by: jun66j5
  • Resolution Update from None to Fixed
  • Status Update from Open to Closed
  • Ticket Close date is changed to 2013-04-26 23:40
댓글 올리기

Applied in r836 and r837. Thanks for the report and the patch!

Attachment File List

No attachments

Edit

Please login to add comment to this ticket » Login