]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
fix: Add test cases
authorhuuyafwww <huuya1234fwww@gmail.com>
Fri, 4 Oct 2024 18:45:40 +0000 (03:45 +0900)
committerhuuyafwww <huuya1234fwww@gmail.com>
Fri, 4 Oct 2024 18:45:40 +0000 (03:45 +0900)
test/dialect/mysql/test_compiler.py

index 189390659add8df9c39b465ed5a9ae652895543e..d9ccc6c4da2f8ed87822be4006ba223175f4c691 100644 (file)
@@ -25,6 +25,7 @@ from sqlalchemy import Index
 from sqlalchemy import INT
 from sqlalchemy import Integer
 from sqlalchemy import Interval
+from sqlalchemy import JSON
 from sqlalchemy import LargeBinary
 from sqlalchemy import literal
 from sqlalchemy import MetaData
@@ -406,6 +407,24 @@ class CompileTest(ReservedWordFixture, fixtures.TestBase, AssertsCompiledSQL):
             "PRIMARY KEY (data) USING btree)",
         )
 
+    def test_create_server_default_with_function_using(self):
+        m = MetaData()
+        tbl = Table(
+            "testtbl",
+            m,
+            Column("time", DateTime, server_default=func.current_timestamp()),
+            Column("name", String(255), server_default="some str"),
+            Column("description", String(255), server_default=func.lower("hi")),
+            Column("data", JSON, server_default=func.json_object()),
+        )
+        self.assert_compile(
+            schema.CreateTable(tbl),
+            "CREATE TABLE testtbl (time DATETIME DEFAULT (CURRENT_TIMESTAMP), "
+            "name VARCHAR(255) DEFAULT 'some str', "
+            "description VARCHAR(255) DEFAULT (lower('hi')), "
+            "data JSON DEFAULT (json_object()))",
+        )
+
     def test_create_index_expr(self):
         m = MetaData()
         t1 = Table("foo", m, Column("x", Integer))