示例#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")
示例#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))
示例#3
0
文件: properties.py 项目: romaia/stoq
 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))
示例#4
0
def compile_decimal(compile, expr, state):
    state.parameters.append(DecimalVariable(expr))
    return "?"
示例#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")
示例#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])