Commits

Kirill Simonov committed 44016dc

Normalize Boolean values produced by SQLite.

Comments (0)

Files changed (1)

src/htsql_sqlite/connect.py

 from htsql.connect import Connect, Normalize, DBError
 from htsql.adapter import adapts, find_adapters
 from htsql.context import context
-from htsql.domain import StringDomain
+from htsql.domain import BooleanDomain, StringDomain
 # In Python 2.6, the `sqlite3` module is built-in, but
 # for Python 2.5, we need to import a third-party module.
 try:
         return super(SQLiteConnect, self).normalize_error(exception)
 
 
+class NormalizeSQLiteBoolean(Normalize):
+
+    adapts(BooleanDomain)
+
+    def __call__(self, value):
+        if value is None:
+            return None
+        return (value != 0)
+
+
 class NormalizeSQLiteString(Normalize):
 
     adapts(StringDomain)