--- /dev/null
+.. change::
+ :tags: bug, mysql
+ :tickets: 12648
+
+ Fixed yet another regression caused by by the DEFAULT rendering changes in
+ 2.0.40 :ticket:`12425`, similar to :ticket:`12488`, this time where using a
+ CURRENT_TIMESTAMP function with a fractional seconds portion inside a
+ textual default value would also fail to be recognized as a
+ non-parenthesized server default.
+
+
self.dialect._support_default_function
and not re.match(r"^\s*[\'\"\(]", default)
and not re.search(r"ON +UPDATE", default, re.I)
+ and not re.match(
+ r"\bnow\(\d+\)|\bcurrent_timestamp\(\d+\)",
+ default,
+ re.I,
+ )
and re.match(r".*\W.*", default)
):
colspec.append(f"DEFAULT ({default})")
DateTime,
server_default=text("now() ON UPDATE now()"),
),
+ Column(
+ "updated4",
+ DateTime,
+ server_default=text("now(3)"),
+ ),
+ Column(
+ "updated5",
+ DateTime,
+ server_default=text("nOW(3)"),
+ ),
+ Column(
+ "updated6",
+ DateTime,
+ server_default=text("notnow(1)"),
+ ),
+ Column(
+ "updated7",
+ DateTime,
+ server_default=text("CURRENT_TIMESTAMP(3)"),
+ ),
)
eq_(dialect._support_default_function, has_brackets)
"data JSON DEFAULT (json_object()), "
"updated1 DATETIME DEFAULT now() on update now(), "
"updated2 DATETIME DEFAULT now() On UpDate now(), "
- "updated3 DATETIME DEFAULT now() ON UPDATE now())",
+ "updated3 DATETIME DEFAULT now() ON UPDATE now(), "
+ "updated4 DATETIME DEFAULT now(3), "
+ "updated5 DATETIME DEFAULT nOW(3), "
+ "updated6 DATETIME DEFAULT (notnow(1)), "
+ "updated7 DATETIME DEFAULT CURRENT_TIMESTAMP(3))",
dialect=dialect,
)
else:
"data JSON DEFAULT json_object(), "
"updated1 DATETIME DEFAULT now() on update now(), "
"updated2 DATETIME DEFAULT now() On UpDate now(), "
- "updated3 DATETIME DEFAULT now() ON UPDATE now())",
+ "updated3 DATETIME DEFAULT now() ON UPDATE now(), "
+ "updated4 DATETIME DEFAULT now(3), "
+ "updated5 DATETIME DEFAULT nOW(3), "
+ "updated6 DATETIME DEFAULT notnow(1), "
+ "updated7 DATETIME DEFAULT CURRENT_TIMESTAMP(3))",
dialect=dialect,
)
from sqlalchemy import true
from sqlalchemy import update
from sqlalchemy.dialects.mysql import limit
+from sqlalchemy.dialects.mysql import TIMESTAMP
from sqlalchemy.testing import assert_raises
from sqlalchemy.testing import combinations
from sqlalchemy.testing import eq_
DateTime,
text("now() ON UPDATE now()"),
),
+ (
+ TIMESTAMP(fsp=3),
+ text("now(3)"),
+ testing.requires.mysql_fsp,
+ ),
+ (
+ TIMESTAMP(fsp=3),
+ text("CURRENT_TIMESTAMP(3)"),
+ testing.requires.mysql_fsp,
+ ),
argnames="datatype, default",
)
def test_create_server_defaults(