@@ -40,6 +40,18 @@ def complete_event():
4040 return Mock ()
4141
4242
43+ def test_escape_name (completer ):
44+
45+ for name , expected_name in [# Upper case name shouldn't be escaped
46+ ("BAR" , "BAR" ),
47+ # This name is escaped and should start with back tick
48+ ("2025todos" , "`2025todos`" ),
49+ # normal case
50+ ("people" , "people" ),
51+ # table name with _underscore should not be escaped
52+ ("django_users" , "django_users" )]:
53+ assert completer .escape_name (name ) == expected_name
54+
4355def test_empty_string_completion (completer , complete_event ):
4456 text = ""
4557 position = 0
@@ -302,7 +314,7 @@ def test_auto_escaped_col_names(completer, complete_event):
302314 result = list (completer .get_completions (Document (text = text , cursor_position = position ), complete_event ))
303315 assert result == [
304316 Completion (text = "*" , start_position = 0 ),
305- Completion (text = "` ABC` " , start_position = 0 ),
317+ Completion (text = "ABC" , start_position = 0 ),
306318 Completion (text = "`insert`" , start_position = 0 ),
307319 Completion (text = "id" , start_position = 0 ),
308320 ] + list (map (Completion , completer .functions )) + [Completion (text = "select" , start_position = 0 )] + list (
@@ -317,7 +329,7 @@ def test_un_escaped_table_names(completer, complete_event):
317329 assert result == list (
318330 [
319331 Completion (text = "*" , start_position = 0 ),
320- Completion (text = "` ABC` " , start_position = 0 ),
332+ Completion (text = "ABC" , start_position = 0 ),
321333 Completion (text = "`insert`" , start_position = 0 ),
322334 Completion (text = "id" , start_position = 0 ),
323335 ]
0 commit comments