-
-
Notifications
You must be signed in to change notification settings - Fork 115
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't create a table with float columns in strict mode #644
Comments
Fixing this is going to be a bit of a pain, because there are a whole bunch of test suites in both Options:
|
I'm going to go with option 1 for the moment (use |
Applying this change breaks a bunch of tests: diff --git a/sqlite_utils/db.py b/sqlite_utils/db.py
index 51987b8..3d89ce6 100644
--- a/sqlite_utils/db.py
+++ b/sqlite_utils/db.py
@@ -178,7 +178,7 @@ class Default:
DEFAULT = Default()
COLUMN_TYPE_MAPPING = {
- float: "FLOAT",
+ float: "REAL",
int: "INTEGER",
bool: "INTEGER",
str: "TEXT",
@@ -192,19 +192,21 @@ COLUMN_TYPE_MAPPING = {
datetime.date: "TEXT",
datetime.time: "TEXT",
datetime.timedelta: "TEXT",
- decimal.Decimal: "FLOAT",
+ decimal.Decimal: "REAL",
None.__class__: "TEXT",
uuid.UUID: "TEXT",
# SQLite explicit types
"TEXT": "TEXT",
"INTEGER": "INTEGER",
- "FLOAT": "FLOAT",
+ "FLOAT": "REAL",
+ "REAL": "REAL",
"BLOB": "BLOB",
"text": "TEXT",
"str": "TEXT",
"integer": "INTEGER",
"int": "INTEGER",
- "float": "FLOAT",
+ "float": "REAL",
+ "real": "REAL",
"blob": "BLOB",
"bytes": "BLOB",
}
|
Thanks for the fix! |
Trying to create a table with float columns fails when strict mode is enabled.
Running this snippet:
Causes this error:
According to sqlite doc, the type for floats should be
REAL
. To verify this I modified db.py so thatCOLUMN_TYPE_MAPPING
would return"REAL"
forfloat
. With this modification the example snippet runs.The text was updated successfully, but these errors were encountered: