From ca4221595008a3344cfa69930e7b8ec8b3660453 Mon Sep 17 00:00:00 2001 From: Thierry Parmentelat Date: Mon, 4 Mar 2013 16:17:49 +0100 Subject: [PATCH] fix json'ing a manyfold query --- engine/manifoldquery.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/engine/manifoldquery.py b/engine/manifoldquery.py index b8f594e9..188a1d45 100644 --- a/engine/manifoldquery.py +++ b/engine/manifoldquery.py @@ -36,10 +36,13 @@ class ManifoldQuery: # xxx unique can be removed, but for now we pad the js structure unique=0 + aq = self.analyzed_query.to_json() if self.analyzed_query else 'null' # subqueries is a dictionary method:query - sq=", ".join ( [ "'%s':%s" % (method, subquery.to_json()) + if not self.subqueries: + sq="{}" + else: + sq=", ".join ( [ "'%s':%s" % (method, subquery.to_json()) for (method, subquery) in self.subqueries.iteritems()]) + sq="{%s}"%sq - aq = self.analyzed_query.to_json() if self.analyzed_query else 'null' - - return "new Query('%(a)s', '%(m)s', '%(t)s', %(f)s, %(p)s, %(c)s, %(unique)s, '%(uuid)s', %(aq)s, {{%(sq)s}})"%locals() + return """ new Query('%(a)s', '%(m)s', '%(t)s', %(f)s, %(p)s, %(c)s, %(unique)s, '%(uuid)s', %(aq)s, %(sq)s)"""%locals() -- 2.43.0