Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions dtable_events/tests/sql/sql_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
sys.path.append(sys.path.append(d(d(d(d(__file__))))))
from sql.column_reference import TEST_COLUMNS, TABLES, LINK_COLUMN
from sql.test_reference import TEST_CONDITIONS, TEST_CONDITIONS_LINK
from dtable_events import filter2sql, linkRecords2sql
from dtable_events import filter2sql, linkRecords2sql, statistic2sql
from dtable_events.utils.constants import StatisticType
from dtable_events.utils.sql_generator import pre_filter_to_filter_term

class SqlTest(unittest.TestCase):
Expand Down Expand Up @@ -49,8 +50,25 @@ def test_equal(self):
record_ids = condition_l.get('row_ids')
sql_link = linkRecords2sql(current_table, link_column, record_ids, tables)
self.assertEqual(sql_link, expected_sql_link)


def test_include_me_with_hyphenated_creator_column(self):
username = '87d485c2281a42adbddb137a1070f395@auth.local'
table = {
'name': self.table_name,
'columns': [{'key': '_creator', 'type': 'creator', 'name': 'Creator-Name'}],
}
statistic = {
'summary_type': 'count',
'filters': [{'column_key': '_creator', 'filter_predicate': 'include_me', 'filter_term': []}],
}

sql, error = statistic2sql(table, StatisticType.BASIC_NUMBER_CARD, statistic, username=username)

self.assertIsNone(error)
self.assertEqual(
sql,
"SELECT COUNT(*) FROM `Table1` WHERE (`Creator-Name` = '%s') LIMIT 0, 5000" % username,
)


def test_user_filter_normalization(self):
Expand Down
2 changes: 1 addition & 1 deletion dtable_events/utils/sql_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -1107,7 +1107,7 @@ def op_include_me(self):
if not isinstance(select_collaborators, list):
select_collaborators = [select_collaborators, ]
creator = select_collaborators[0] if select_collaborators else ''
return "%s %s '%s'" % (
return "`%s` %s '%s'" % (
self.column_name,
'=',
creator
Expand Down
Loading