Warning: Can't synchronize with repository "(default)" (Unsupported version control system "svn": No module named svn). Look in the Trac log for more information.

Ticket #673 (closed defect: fixed)

Opened 12 years ago

Last modified 10 years ago

CatWalk creates Queries that PostgreSQL chokes on

Reported by: brakhane@… Owned by: anonymous
Priority: normal Milestone: 0.9a2
Component: Toolbox Version:
Severity: major Keywords:
Cc:

Description

When using CatWalk on an empty table with foreign keys, it creates Queries like this one:

SELECT tg_group_permission.permission_id, Count(tg_group_permission.group_id) FROM tg_group_permission WHERE tg_group_permission.permission_id IN() GROUP BY tg_group_permission.permission_id

PostgreSQL 8.1.3 chokes on the IN(). (empty set)

Now I do not know (nor do I care ;)) whether it's a bug in PostgreSQL's SQL parser or not. However, since this query results in an empty set anyway, I've patched browse.py to return instead of executing this query.

Patch follows:

Index: browse.py
===================================================================
--- browse.py   (revision 982)
+++ browse.py   (working copy)
@@ -100,6 +100,8 @@
     def relation_values(self,object_name,rows):
         obj = self.load_object(object_name)
         ids = rows.keys()
+        if not ids:
+            return []
         conn = obj._connection
         joins = {}
         for column in obj.sqlmeta.joins:
@@ -151,6 +153,8 @@
         return rows

     def foreign_key_query(self,column,alias,ids):
+        if not ids:
+            return []
         sql_object = self.load_object(column.foreignKey)
         conn = sql_object._connection
         query = conn.sqlrepr( Select( [ sql_object.q.id,getattr(sql_object.q,alias) ],

Change History

comment:1 Changed 12 years ago by ronald@…

  • Status changed from new to closed
  • Resolution set to fixed

Thanks for the patch! Fixed in r988

comment:2 Changed 12 years ago by kevin

  • Milestone set to 0.9a2
Note: See TracTickets for help on using tickets.