Kirill Simonov avatar 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)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.