commit or rollback transaction with errors
on engine.begin().
+- sqlite
+ - [bug] Fixed bug in C extensions whereby
+ string format would not be applied to a
+ Numeric value returned as integer; this
+ affected primarily SQLite which does
+ not maintain numeric scale settings.
+ [ticket:2432]
+
- mssql
- [feature] Added support for MSSQL INSERT,
UPDATE, and DELETE table hints, using
if (value == Py_None)
Py_RETURN_NONE;
- if (PyFloat_CheckExact(value)) {
- /* Decimal does not accept float values directly */
- args = PyTuple_Pack(1, value);
- if (args == NULL)
- return NULL;
+ args = PyTuple_Pack(1, value);
+ if (args == NULL)
+ return NULL;
- str = PyString_Format(self->format, args);
- Py_DECREF(args);
- if (str == NULL)
- return NULL;
+ str = PyString_Format(self->format, args);
+ Py_DECREF(args);
+ if (str == NULL)
+ return NULL;
- result = PyObject_CallFunctionObjArgs(self->type, str, NULL);
- Py_DECREF(str);
- return result;
- } else {
- return PyObject_CallFunctionObjArgs(self->type, value, NULL);
- }
+ result = PyObject_CallFunctionObjArgs(self->type, str, NULL);
+ Py_DECREF(str);
+ return result;
}
static void
metadata.drop_all()
@testing.emits_warning(r".*does \*not\* support Decimal objects natively")
- def _do_test(self, type_, input_, output, filter_ = None):
+ def _do_test(self, type_, input_, output, filter_=None, check_scale=False):
t = Table('t', metadata, Column('x', type_))
t.create()
t.insert().execute([{'x':x} for x in input_])
#print result
#print output
eq_(result, output)
+ if check_scale:
+ eq_(
+ [str(x) for x in result],
+ [str(x) for x in output],
+ )
def test_numeric_as_decimal(self):
self._do_test(
numbers
)
+ def test_numeric_no_decimal(self):
+ numbers = set([
+ decimal.Decimal("1.000")
+ ])
+ self._do_test(
+ Numeric(precision=5, scale=3),
+ numbers,
+ numbers,
+ check_scale=True
+ )
+
class NumericRawSQLTest(fixtures.TestBase):
"""Test what DBAPIs and dialects return without any typing
information supplied at the SQLA level.