diff --git a/gluon/dal.py b/gluon/dal.py index 50331218..aab001c3 100644 --- a/gluon/dal.py +++ b/gluon/dal.py @@ -1767,12 +1767,17 @@ class BaseAdapter(ConnectionPool): sql_w = ' WHERE ' + self.expand(query) if query else '' if inner_join and not left: - sql_t = ', '.join([self.table_alias(t) + # Wrap table references with parenthesis (approach 1) + # sql_t = ', '.join([self.table_alias(t) + # for t in iexcluded + itables_to_merge.keys()]) + # sql_t = '(%s)' % sql_t + # or approach 2: Use 'JOIN' instead comma: + sql_t = ' JOIN '.join([self.table_alias(t) for t in iexcluded + itables_to_merge.keys()]) for t in ijoinon: sql_t += ' %s %s' % (icommand, t) elif not inner_join and left: - sql_t = ', '.join([self.table_alias(t) + sql_t = ' JOIN '.join([self.table_alias(t) for t in excluded + tables_to_merge.keys()]) if joint: sql_t += ' %s %s' % (command, @@ -1785,7 +1790,7 @@ class BaseAdapter(ConnectionPool): tables_in_joinon = set(joinont + ijoinont) tables_not_in_joinon = \ all_tables_in_query.difference(tables_in_joinon) - sql_t = ','.join([self.table_alias(t) for t in tables_not_in_joinon]) + sql_t = ' JOIN '.join([self.table_alias(t) for t in tables_not_in_joinon]) for t in ijoinon: sql_t += ' %s %s' % (icommand, t) if joint: