sqlnbfmt 0.3.1__tar.gz → 0.3.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sqlnbfmt
3
- Version: 0.3.1
3
+ Version: 0.3.2
4
4
  Summary: A tool to format SQL code in Jupyter notebooks.
5
5
  Author-email: Qing <qingye779@gmail.com>
6
6
  License: MIT
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "sqlnbfmt"
3
- version = "0.3.1"
3
+ version = "0.3.2"
4
4
  description = "A tool to format SQL code in Jupyter notebooks."
5
5
  authors = [
6
6
  { name = "Qing", email = "qingye779@gmail.com" }
@@ -10,7 +10,7 @@ from typing import Set, Optional, Dict, Union, Tuple
10
10
 
11
11
  import nbformat
12
12
  import yaml
13
- from sqlglot import parse_one, errors
13
+ from sqlglot import parse, errors
14
14
 
15
15
  DEFAULT_SQL_KEYWORDS = frozenset(
16
16
  {
@@ -206,10 +206,18 @@ def format_sql_code(
206
206
  temp_sql = temp_sql.strip()
207
207
 
208
208
  # Parse and format SQL
209
- parsed = parse_one(temp_sql, read=dialect)
210
- formatted_sql = parsed.sql(
211
- pretty=not force_single_line, indent=config.indent_width, dialect=dialect
212
- )
209
+ statements = parse(temp_sql, read=dialect)
210
+ formatted_parts = []
211
+ for stmt in statements:
212
+ formatted_parts.append(
213
+ stmt.sql(
214
+ pretty=not force_single_line,
215
+ indent=config.indent_width,
216
+ dialect=dialect,
217
+ )
218
+ )
219
+ separator = "; " if force_single_line else ";\n"
220
+ formatted_sql = separator.join(formatted_parts)
213
221
 
214
222
  # Apply formatting based on context
215
223
  if is_magic_command and not is_cell_magic:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sqlnbfmt
3
- Version: 0.3.1
3
+ Version: 0.3.2
4
4
  Summary: A tool to format SQL code in Jupyter notebooks.
5
5
  Author-email: Qing <qingye779@gmail.com>
6
6
  License: MIT
File without changes
File without changes
File without changes
File without changes
File without changes