From 5ca00b71acec3116bc9a0336686e55204f248d7c Mon Sep 17 00:00:00 2001 From: Pablo Rodriguez Mira <36644554+PabloRMira@users.noreply.github.com> Date: Fri, 30 Apr 2021 23:29:23 +0200 Subject: [PATCH] [FIX] Table names that include the substring select in them break subsequent formatting (#167) --- docs/additional_tests.html | 101 ++++++++++++++++++++++++++++++++++ docs/utils.html | 38 ++++++------- nbs/00_core.ipynb | 15 +---- nbs/02_utils.ipynb | 7 ++- nbs/99_additional_tests.ipynb | 90 +++++++++++++++++++++++++++++- sql_formatter/core.py | 4 +- sql_formatter/utils.py | 6 +- 7 files changed, 223 insertions(+), 38 deletions(-) diff --git a/docs/additional_tests.html b/docs/additional_tests.html index 4ac6f9c..64fd8f3 100644 --- a/docs/additional_tests.html +++ b/docs/additional_tests.html @@ -119,6 +119,107 @@
assert_and_print(
+ format_sql(
+"""SELECT var
+ FROM table_selection as a
+ LEFT JOIN table2 as b ON a.id = b.id
+ LEFT JOIN table3 as c ON a.id = c.id
+ ORDER BY 1
+"""),
+"""
+SELECT var
+FROM table_selection as a
+ LEFT JOIN table2 as b
+ ON a.id = b.id
+ LEFT JOIN table3 as c
+ ON a.id = c.id
+ORDER BY 1
+""".strip()
+)
+
assert_and_print(
+ split_query("select var from table_selection"),
+ [{"string": "select var ", "comment": False, "quote": False, "select": True},
+ {"string": "from table_selection", "comment": False, "quote": False, "select": False}]
+)
+
split_query
-split_apply_concat
[source]+
split_apply_concat
(s
,f
)
split_apply_concat
[source]
split_apply_concat
(s
,f
)Split query
@@ -1330,7 +1330,7 @@s
, apply functionf
and concatenate stringsSplit by comment / no