Commits

Anonymous committed 4e005ed

Fix check for when adaptation is required.

  • Participants
  • Parent commits ef317a3

Comments (0)

Files changed (1)

File Statement.cs

 
         private bool needsAdaptation(CodeContext context, object value)
         {
-            object proto = DynamicHelpers.GetPythonTypeFromType(typeof(PythonSQLite.PrepareProtocol));
-            object type = DynamicHelpers.GetPythonType(value);
-
-            object key = new PythonTuple(new[] { type, proto });
-
             // TODO The check for primitive types could probably be cached like pysqlite does
-
-            return PythonSQLite.adapters.ContainsKey(key) ||
-                !(value == null ||
+            if(value == null ||
                 value is int ||
                 value is bool ||
                 value is long ||
                 value is double ||
                 value is string ||
                 value is byte[] ||
-                value is PythonBuffer);
+                value is PythonBuffer)
+            {
+                object proto = DynamicHelpers.GetPythonTypeFromType(typeof(PythonSQLite.PrepareProtocol));
+                object type = DynamicHelpers.GetPythonType(value);
+
+                object key = new PythonTuple(new[] { type, proto });
+
+                return PythonSQLite.adapters.ContainsKey(key);
+            }
+            else
+            {
+                return true;
+            }
         }
 
         private object adaptValue(CodeContext context, object value)
                 }
             }
 
-            throw new PythonSQLite.ProgrammingError("can't adapt");
+            return value;
         }
 
         public int RawStep()