Hi all,
I have noticed that the DECIMAL type is not rendered with precision or scale:
>>> sa.__version__
'0.7.9'
>>> import sqlalchemy as sa
>>> print sa.NUMERIC(6, 4)
NUMERIC(6, 4)
>>> print sa.DECIMAL(6, 4)
DECIMAL
This causes problems in eg alembic where a table definition that uses
DECIMAL(x, y) will silently lose the scale and precision eg an upgrade script
such as
def upgrade():
op.create_table("x",
sa.Column("x", sa.DECIMAL(6, 4)))
produces:
CREATE TABLE x (
x DECIMAL NULL
);
To have precision you must use the NUMERIC type.
I'm mainly encountering this issue when generating the sql for an existing
database where I reflect the metadata and then issue a create_all via a mock
engine ... it then renders all of the DECIMAL columns in the existing model
(that I have no control over) without their scale or precision.
Is there a reason for this or is it a bug? Currently I am monkey patching
sqlalchemy.sql.compiler.GenericTypeCompiler.visit_DECIMAL in order to get what
I view as "correct" output.
Cheers,
d.
--
E-Mail sent with anti-spam site TrashMail.net!
Free disposable email addresses: http://www.trashmail.net
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en.