Skip to content

Commit

Permalink
Feat: add support for Chr in tsql and sqlite (#4566)
Browse files Browse the repository at this point in the history
* char vs chr and char(100 using utf8mb4) by default for mysql

* removed default encoding for mysql

* Revert MySQL

* Revert tests

---------

Co-authored-by: Jo <[email protected]>
  • Loading branch information
pruzko and georgesittas authored Jan 8, 2025
1 parent 1687a31 commit 9def0b7
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions sqlglot/dialects/sqlite.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ class Generator(generator.Generator):
TRANSFORMS = {
**generator.Generator.TRANSFORMS,
exp.AnyValue: any_value_to_max_sql,
exp.Chr: rename_func("CHAR"),
exp.Concat: concat_to_dpipe_sql,
exp.CountIf: count_if_to_sum,
exp.Create: transforms.preprocess([_transform_create]),
Expand Down
1 change: 1 addition & 0 deletions sqlglot/dialects/tsql.py
Original file line number Diff line number Diff line change
Expand Up @@ -906,6 +906,7 @@ class Generator(generator.Generator):
exp.AnyValue: any_value_to_max_sql,
exp.ArrayToString: rename_func("STRING_AGG"),
exp.AutoIncrementColumnConstraint: lambda *_: "IDENTITY",
exp.Chr: rename_func("CHAR"),
exp.DateAdd: date_delta_sql("DATEADD"),
exp.DateDiff: date_delta_sql("DATEDIFF"),
exp.CTE: transforms.preprocess([qualify_derived_table_outputs]),
Expand Down
2 changes: 2 additions & 0 deletions tests/dialects/test_mysql.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,8 @@ def test_canonical_functions(self):
write={
"mysql": "CHAR(10)",
"presto": "CHR(10)",
"sqlite": "CHAR(10)",
"tsql": "CHAR(10)",
},
)

Expand Down

0 comments on commit 9def0b7

Please sign in to comment.