Exemplo n.º 1
0
 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")
Exemplo n.º 2
0
 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))
Exemplo n.º 3
0
 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))
Exemplo n.º 4
0
def compile_decimal(compile, expr, state):
    state.parameters.append(DecimalVariable(expr))
    return "?"
Exemplo n.º 5
0
 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")
Exemplo n.º 6
0
 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])