From 515e284c22cc5a65985969478f5b7fdba27c9083 Mon Sep 17 00:00:00 2001 From: mdipierro Date: Thu, 28 Mar 2013 14:44:32 -0500 Subject: [PATCH] issue 1412, common_filters and joins, thanks Felipe Merelles --- VERSION | 2 +- gluon/dal.py | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/VERSION b/VERSION index a81a7f9b..222a5c01 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -Version 2.4.5-stable+timestamp.2013.03.25.15.26.55 +Version 2.4.5-stable+timestamp.2013.03.28.14.43.50 diff --git a/gluon/dal.py b/gluon/dal.py index 22ebd294..e614f389 100644 --- a/gluon/dal.py +++ b/gluon/dal.py @@ -1503,6 +1503,7 @@ class BaseAdapter(ConnectionPool): raise SyntaxError('invalid select attribute: %s' % key) args_get = attributes.get tablenames = tables(query) + tablenames_for_common_filters = tablenames for field in fields: if isinstance(field, basestring) \ and REGEX_TABLE_DOT_FIELD.match(field): @@ -1566,6 +1567,8 @@ class BaseAdapter(ConnectionPool): dict.fromkeys(tables(t))) for t in joinon] joinont = [t.first._tablename for t in joinon] [tables_to_merge.pop(t) for t in joinont if t in tables_to_merge] + tablenames_for_common_filters = [t for t in tablenames + if not t in joinont ] important_tablenames = joint + joinont + tables_to_merge.keys() excluded = [t for t in tablenames if not t in important_tablenames ] @@ -1573,7 +1576,7 @@ class BaseAdapter(ConnectionPool): excluded = tablenames if use_common_filters(query): - query = self.common_filter(query,excluded) + query = self.common_filter(query,tablenames_for_common_filters) sql_w = ' WHERE ' + self.expand(query) if query else '' def alias(t):