summaryrefslogtreecommitdiff
path: root/test/dialect/test_sqlite.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2022-04-03 13:44:57 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2022-04-03 14:47:52 -0400
commitccadbec82555c53eefa889160510f5af1e224709 (patch)
tree959b4309fcc26191ef791034bda76e6fda0d1bdb /test/dialect/test_sqlite.py
parent1dffb7cedeb009ca6c532db558bd0588dd846957 (diff)
downloadsqlalchemy-ccadbec82555c53eefa889160510f5af1e224709.tar.gz
use .fromisoformat() for sqlite datetime, date, time parsing
SQLite datetime, date, and time datatypes now use Python standard lib ``fromisoformat()`` methods in order to parse incoming datetime, date, and time string values. This improves performance vs. the previous regular expression-based approach, and also automatically accommodates for datetime and time formats that contain either a six-digit "microseconds" format or a three-digit "milliseconds" format. Fixes: #7029 Change-Id: I67aab4fe5ee3055e5996050cf4564981413cc221
Diffstat (limited to 'test/dialect/test_sqlite.py')
-rw-r--r--test/dialect/test_sqlite.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/test/dialect/test_sqlite.py b/test/dialect/test_sqlite.py
index 9658fec83..8e7632c90 100644
--- a/test/dialect/test_sqlite.py
+++ b/test/dialect/test_sqlite.py
@@ -117,7 +117,7 @@ class TestTypes(fixtures.TestBase, AssertsExecutionResults):
]:
assert_raises_message(
ValueError,
- "Couldn't parse %s string." % disp,
+ "Invalid isoformat string:",
lambda: connection.execute(
text("select 'ASDF' as value").columns(value=typ)
).scalar(),
@@ -166,7 +166,7 @@ class TestTypes(fixtures.TestBase, AssertsExecutionResults):
# 2004-05-21T00:00:00
storage_format="%(year)04d-%(month)02d-%(day)02d"
"T%(hour)02d:%(minute)02d:%(second)02d",
- regexp=r"(\d+)-(\d+)-(\d+)T(\d+):(\d+):(\d+)",
+ regexp=r"^(\d+)-(\d+)-(\d+)T(\d+):(\d+):(\d+)$",
)
t = Table("t", self.metadata, Column("d", sqlite_date))
self.metadata.create_all(connection)
@@ -195,7 +195,7 @@ class TestTypes(fixtures.TestBase, AssertsExecutionResults):
sqlite_date = sqlite.DATETIME(
storage_format="%(year)04d%(month)02d%(day)02d"
"%(hour)02d%(minute)02d%(second)02d",
- regexp=r"(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})",
+ regexp=r"^(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})$",
)
t = Table("t", self.metadata, Column("d", sqlite_date))
self.metadata.create_all(connection)