Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1106326

Browse files
zzzeekGerrit Code Review
authored and
Gerrit Code Review
committed
Merge "fix sqlite localtimestamp function" into main
2 parents 667a5d3 + d689e46 commit 1106326

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.. change::
2+
:tags: bug, sqlite
3+
:tickets: 12566
4+
5+
Fixed and added test support for a few SQLite SQL functions hardcoded into
6+
the compiler most notably the "localtimestamp" function which rendered with
7+
incorrect internal quoting.

lib/sqlalchemy/dialects/sqlite/base.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1360,7 +1360,7 @@ def visit_now_func(self, fn, **kw):
13601360
return "CURRENT_TIMESTAMP"
13611361

13621362
def visit_localtimestamp_func(self, func, **kw):
1363-
return 'DATETIME(CURRENT_TIMESTAMP, "localtime")'
1363+
return "DATETIME(CURRENT_TIMESTAMP, 'localtime')"
13641364

13651365
def visit_true(self, expr, **kw):
13661366
return "1"

test/dialect/test_sqlite.py

+11-1
Original file line numberDiff line numberDiff line change
@@ -780,6 +780,16 @@ def test_column_computed(self, text, persisted):
780780
" y INTEGER GENERATED ALWAYS AS (x + 2)%s)" % text,
781781
)
782782

783+
@testing.combinations(
784+
(func.localtimestamp(),),
785+
(func.now(),),
786+
(func.char_length("test"),),
787+
(func.aggregate_strings("abc", ","),),
788+
argnames="fn",
789+
)
790+
def test_builtin_functions_roundtrip(self, fn, connection):
791+
connection.execute(select(fn))
792+
783793

784794
class AttachedDBTest(fixtures.TablesTest):
785795
__only_on__ = "sqlite"
@@ -964,7 +974,7 @@ def test_is_distinct_from(self):
964974

965975
def test_localtime(self):
966976
self.assert_compile(
967-
func.localtimestamp(), 'DATETIME(CURRENT_TIMESTAMP, "localtime")'
977+
func.localtimestamp(), "DATETIME(CURRENT_TIMESTAMP, 'localtime')"
968978
)
969979

970980
def test_constraints_with_schemas(self):

0 commit comments

Comments
 (0)