From ad77d36a555fef7c953f91f43ab44ce0abe39322 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 14 Jul 2026 14:48:28 +0000 Subject: [PATCH] Fix _decode_default_value returning float for negative integer defaults Python's str.isdigit() returns False for negative numbers like "-5", causing DEFAULT -5 in SQLite to be decoded as -5.0 (float) instead of -5 (int). Switch to re.fullmatch to handle the leading minus sign. --- sqlite_utils/db.py | 2 +- tests/test_introspect.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/sqlite_utils/db.py b/sqlite_utils/db.py index e97b7d9cb..dff55b0dc 100644 --- a/sqlite_utils/db.py +++ b/sqlite_utils/db.py @@ -5214,7 +5214,7 @@ def _decode_default_value(value: str) -> object: if value.startswith("'") and value.endswith("'"): # It's a string return value[1:-1] - if value.isdigit(): + if re.fullmatch(r"-?\d+", value): # It's an integer return int(value) if value.startswith("X'") and value.endswith("'"): diff --git a/tests/test_introspect.py b/tests/test_introspect.py index 8b6765d86..6f2edf349 100644 --- a/tests/test_introspect.py +++ b/tests/test_introspect.py @@ -309,6 +309,7 @@ def test_table_strict(fresh_db, create_table, expected_strict): "value", ( 1, + -5, 1.3, "foo", True,