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
2 changes: 1 addition & 1 deletion dtable_events/tests/sql/column_reference.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{'key': '0000', 'name': '名称', 'type': 'text', 'width': 126, 'editable': True, 'resizable': True},
{'key': 'r1A1', 'type': 'date', 'name': 'Time2d', 'editable': True, 'width': 135, 'resizable': True, 'draggable': True, 'data': {'format': 'YYYY-MM-DD HH:mm'}, 'permission_type': '', 'permitted_users': [], 'editor': {'key': None, 'ref': None, 'props': {}, '_owner': None, '_store': {}}, 'formatter': {'key': None, 'ref': None, 'props': {}, '_owner': None, '_store': {}}},
{'key': '_ctime', 'type': 'ctime', 'name': 'createTime', 'editable': True, 'width': 172, 'resizable': True, 'draggable': True, 'data': None, 'permission_type': '', 'permitted_users': []},
{'key': 'PQ7r', 'type': 'single-select', 'name': 'Sing', 'editable': True, 'width': 117, 'resizable': True, 'draggable': True, 'data': {'options': [{'name': 'a', 'color': '#FFFCB5', 'textColor': '#202428', 'borderColor': '#E8E79D', 'id': '63347'}, {'name': 'b', 'color': '#F4667C', 'textColor': '#FFFFFF', 'borderColor': '#DC556A', 'id': '905189'}, {'name': 'c', 'color': '#9860E5', 'textColor': '#FFFFFF', 'borderColor': '#844BD2', 'id': '506341'}]}, 'permission_type': '', 'permitted_users': []},
{'key': 'PQ7r', 'type': 'single-select', 'name': 'Sing', 'editable': True, 'width': 117, 'resizable': True, 'draggable': True, 'data': {'options': [{'name': 'a', 'color': '#FFFCB5', 'textColor': '#202428', 'borderColor': '#E8E79D', 'id': '63347'}, {'name': 'b', 'color': '#F4667C', 'textColor': '#FFFFFF', 'borderColor': '#DC556A', 'id': '905189'}, {'name': 'c', 'color': '#9860E5', 'textColor': '#FFFFFF', 'borderColor': '#844BD2', 'id': '506341'}, {'name': "d'quote", 'color': '#FFD9C8', 'textColor': '#202428', 'borderColor': '#EFBAA3', 'id': '99999'}]}, 'permission_type': '', 'permitted_users': []},
{'key': 'OhXJ', 'type': 'multiple-select', 'name': 'Mul', 'editable': True, 'width': 143, 'resizable': True, 'draggable': True, 'data': {'options': [{'name': 'aa', 'color': '#FFD9C8', 'textColor': '#202428', 'borderColor': '#EFBAA3', 'id': '885435'}, {'name': 'bb', 'color': '#EAA775', 'textColor': '#FFFFFF', 'borderColor': '#D59361', 'id': '764614'}, {'name': 'cc', 'color': '#9F8CF1', 'textColor': '#FFFFFF', 'borderColor': '#8F75E2', 'id': '418530'}, {'name': 'dd', 'color': '#ADDF84', 'textColor': '#FFFFFF', 'borderColor': '#9CCF72', 'id': '634546'}]}, 'permission_type': '', 'permitted_users': []},
{'key': 'Dhi2', 'type': 'rate', 'name': 'rate', 'editable': True, 'width': 200, 'resizable': True, 'draggable': True, 'data': {'rate_max_number': 5, 'rate_style_color': '#FF8000'}, 'permission_type': '', 'permitted_users': []},
{'key': 'W1lp', 'type': 'collaborator', 'name': 'Colla', 'editable': True, 'width': 200, 'resizable': True, 'draggable': True, 'data': {'enable_send_notification': False}, 'permission_type': '', 'permitted_users': []},
Expand Down
44 changes: 44 additions & 0 deletions dtable_events/tests/sql/test_reference.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,50 @@ def get_expected_sql_for_modifier(filter_modifier, column_name):
"expected_sql": "SELECT * FROM `Table1` WHERE (`Sing` = 'a') LIMIT 0, 100",
"by_group": False,
},
{
"filter_conditions": {
"filters": [
{'column_name': 'Sing', 'filter_predicate': 'is', 'filter_term': '99999'}
],
"filter_predicate": 'And',
"sorts":[],
},
"expected_sql": "SELECT * FROM `Table1` WHERE (`Sing` = 'd''quote') LIMIT 0, 100",
"by_group": False,
},
{
"filter_conditions": {
"filters": [
{'column_name': 'Sing', 'filter_predicate': 'is_not', 'filter_term': '99999'}
],
"filter_predicate": 'And',
"sorts":[],
},
"expected_sql": "SELECT * FROM `Table1` WHERE (`Sing` <> 'd''quote') LIMIT 0, 100",
"by_group": False,
},
{
"filter_conditions": {
"filters": [
{'column_name': 'Sing', 'filter_predicate': 'is_any_of', 'filter_term': ['99999']}
],
"filter_predicate": 'And',
"sorts":[],
},
"expected_sql": "SELECT * FROM `Table1` WHERE (`Sing` in ('d''quote')) LIMIT 0, 100",
"by_group": False,
},
{
"filter_conditions": {
"filters": [
{'column_name': 'Sing', 'filter_predicate': 'is_none_of', 'filter_term': ['99999']}
],
"filter_predicate": 'And',
"sorts":[],
},
"expected_sql": "SELECT * FROM `Table1` WHERE (`Sing` not in ('d''quote')) LIMIT 0, 100",
"by_group": False,
},
{
"filter_conditions": {
"filters": [
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 @@ -391,7 +391,7 @@ def op_is(self):
return "`%s` %s '%s'" % (
self.column_name,
'=',
filter_term
self.escape_string(filter_term)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Warning] 缺少单引号回归测试

Why this matters:
本次修复专门处理选项名称中的单引号,但 PR 没有覆盖该场景;以后调整 op_is 或转义规则时,French a'c 仍可能再次生成无法解析的 SQL 并在图表中变成 500。

Suggested fix: 为 SingleSelectOperator.op_is 增加含一个及多个单引号的测试,断言 SQL 字面量使用 '',例如 French a''c

)

def op_is_not(self):
Expand Down
Loading