def test_binary_ascii(self): """Some databases like pysqlite2 may return unicode for strings.""" self.connection.execute("INSERT INTO bin_test VALUES (10, 'Value')") result = self.connection.execute("SELECT b FROM bin_test") variable = RawStrVariable() # If the following doesn't raise a TypeError we're good. result.set_variable(variable, result.get_one()[0]) self.assertEquals(variable.get(), "Value")
def test_binary_ascii(self): """Some databases like pysqlite2 may return unicode for strings.""" self.connection.execute("INSERT INTO bin_test VALUES (10, 'Value')") result = self.connection.execute("SELECT b FROM bin_test") variable = RawStrVariable() # If the following doesn't raise a TypeError we're good. result.set_variable(variable, result.get_one()[0]) self.assertEquals(variable.get(), "Value")
def test_binary(self): """Ensure database works with high bits and embedded zeros.""" value = "\xff\x00\xff\x00" self.connection.execute("INSERT INTO bin_test (b) VALUES (?)", (value,)) result = self.connection.execute("SELECT b FROM bin_test") variable = RawStrVariable() result.set_variable(variable, result.get_one()[0]) self.assertEquals(variable.get(), value)
def test_binary(self): """Ensure database works with high bits and embedded zeros.""" value = "\xff\x00\xff\x00" self.connection.execute("INSERT INTO bin_test (b) VALUES (?)", (value, )) result = self.connection.execute("SELECT b FROM bin_test") variable = RawStrVariable() result.set_variable(variable, result.get_one()[0]) self.assertEquals(variable.get(), value)
def test_none_on_string_variable(self): """ Verify that the logic to enforce fix E''-styled strings isn't breaking on NULL values. """ variable = RawStrVariable(value=None) result = self.connection.execute(Select(variable)) self.assertEquals(result.get_one(), (None, ))
def compile_str(compile, expr, state): state.parameters.append(RawStrVariable(expr)) return "?"