From: huuyafwww Date: Fri, 4 Oct 2024 18:45:40 +0000 (+0900) Subject: fix: Add test cases X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=abaf0c74a6b53c057ec13d1de728263a8160d2c3;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git fix: Add test cases --- diff --git a/test/dialect/mysql/test_compiler.py b/test/dialect/mysql/test_compiler.py index 189390659a..d9ccc6c4da 100644 --- a/test/dialect/mysql/test_compiler.py +++ b/test/dialect/mysql/test_compiler.py @@ -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))