def test_get_decimal_variable_to_str_column(self): variable = DecimalVariable() variable.set("40.5", from_db=True) self.connection.execute("INSERT INTO test VALUES (40, ?)", (variable, )) result = self.connection.execute("SELECT title FROM test WHERE id=40") self.assertEquals(result.get_one()[0], "40.5")
def parse_set(self, value, from_db): # XXX: We cannot reduce the precision when converting to currency, since # sometimes we need a cost of a product to have more than 2 digits return currency(DecimalVariable.parse_set(value, from_db))
def compile_decimal(compile, expr, state): state.parameters.append(DecimalVariable(expr)) return "?"
def test_get_decimal_variable_to_str_column(self): variable = DecimalVariable() variable.set("40.5", from_db=True) self.connection.execute("INSERT INTO test VALUES (40, ?)", (variable,)) result = self.connection.execute("SELECT title FROM test WHERE id=40") self.assertEquals(result.get_one()[0], "40.5")
def test_set_decimal_variable_from_str_column(self): self.connection.execute("INSERT INTO test VALUES (40, '40.5')") variable = DecimalVariable() result = self.connection.execute("SELECT title FROM test WHERE id=40") result.set_variable(variable, result.get_one()[0])