diff options
author | Marko Kreen | 2013-05-26 19:55:38 +0000 |
---|---|---|
committer | Marko Kreen | 2013-05-26 19:55:38 +0000 |
commit | 46d6db36a03967dfab96b0dc035a9f1c5088d134 (patch) | |
tree | cd9bce0824097b67ada8f9e9a85e97357ede2ddc | |
parent | d3a7501f653a5cd6c0d535423ff6e8005325f6e8 (diff) |
querybuilder: show list of missing arguments on KeyError
-rwxr-xr-x | python/skytools/querybuilder.py | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/python/skytools/querybuilder.py b/python/skytools/querybuilder.py index c2eead2d..9930daab 100755 --- a/python/skytools/querybuilder.py +++ b/python/skytools/querybuilder.py @@ -319,8 +319,11 @@ class PLPyQuery: arg_list = [arg_dict.get(k) for k in self.arg_map] return plpy.execute(self.plan, arg_list) except KeyError: - plpy.error("Missing argument: QUERY: %s ARGS: %s VALUES: %s" % ( - repr(self.sql), repr(self.arg_map), repr(arg_dict))) + need = set(self.arg_map) + got = set(arg_dict.keys()) + missing = list(need.difference(got)) + plpy.error("Missing arguments: [%s] QUERY: %s" % ( + ','.join(missing), repr(self.sql))) def __repr__(self): return 'PLPyQuery<%s>' % self.sql @@ -341,7 +344,7 @@ def plpy_exec(gd, sql, args, all_keys_required = True): >>> res = plpy_exec(GD, "select {arg1}, {arg2:int4}, {arg1}", {'arg1': '3', 'arg2': '4'}) DBG: plpy.execute(('PLAN', 'select $1, $2, $3', ['text', 'int4', 'text']), ['3', '4', '3']) >>> res = plpy_exec(GD, "select {arg1}, {arg2:int4}, {arg1}", {'arg1': '3'}) - DBG: plpy.error("Missing argument: QUERY: 'select {arg1}, {arg2:int4}, {arg1}' ARGS: ['arg1', 'arg2', 'arg1'] VALUES: {'arg1': '3'}") + DBG: plpy.error("Missing arguments: [arg2] QUERY: 'select {arg1}, {arg2:int4}, {arg1}'") >>> res = plpy_exec(GD, "select {arg1}, {arg2:int4}, {arg1}", {'arg1': '3'}, False) DBG: plpy.execute(('PLAN', 'select $1, $2, $3', ['text', 'int4', 'text']), ['3', None, '3']) """ |