On Mon, Apr 29, 2019 at 1:13 PM mdob <[email protected]> wrote: > > Just out of curiosity, why it was decided that MySQL DOUBLE, which is > approximation, will be presented in ORM as Decimal by default instead of > float? > > MySQL DOUBLE - > https://dev.mysql.com/doc/refman/5.5/en/floating-point-types.html > SQLAlchemy DOUBLE - > https://docs.sqlalchemy.org/en/13/dialects/mysql.html#sqlalchemy.dialects.mysql.DOUBLE
no idea, lets do a git blame it looks like the issue to first add Decimal support was: https://github.com/sqlalchemy/sqlalchemy/issues/646 it appears to refer to a no longer tracked SVN changeset, the merge can be seen at https://github.com/sqlalchemy/sqlalchemy/commit/ed4fc64bb0ac61c27bc4af32962fb129e74a36bf, where quite arbitrarily the asdecimal flag is True for DOUBLE even though the superclass is Float. That's all 12 years ago. Let's try to blame for the ".. note" that was added, since someone seems to have noticed this was wrong about six years ago, seems like it was in https://github.com/sqlalchemy/sqlalchemy/commit/6b79d2ea7951abc2bb6083b541db0fbf71590dd3 where we made it a lot more explicit how the float coercion occurs. All we have is a guess. It would have been that I either observed or guessed that Python's float, at least the "ten digits" that was coming out by default back on my cPython 2.3 interpreter on my PowerPC mac at the time, was not accurate enough to represent the values coming back from a double-precision floating point value. Trying to see what the likely floating point representation is for cPython is ...a ha we can do this: >>> import sys >>> sys.float_info sys.float_info(max=1.7976931348623157e+308, max_exp=1024, max_10_exp=308, min=2.2250738585072014e-308, min_exp=-1021, min_10_exp=-307, dig=15, mant_dig=53, epsilon=2.220446049250313e-16, radix=2, rounds=1) I have no idea what would have been happening at that time, it was likely to preserve round trips for the additional digits, but this was shortsighted because the driver at the time MySQLdb was likely returning floats anyway, current branch of it does: https://github.com/PyMySQL/mysqlclient-python/blob/master/MySQLdb/converters.py#L107 so seems like a careless oversight. Sorry! > > Thanks, > Michal > > -- > SQLAlchemy - > The Python SQL Toolkit and Object Relational Mapper > > http://www.sqlalchemy.org/ > > To post example code, please provide an MCVE: Minimal, Complete, and > Verifiable Example. See http://stackoverflow.com/help/mcve for a full > description. > --- > You received this message because you are subscribed to the Google Groups > "sqlalchemy" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at https://groups.google.com/group/sqlalchemy. > For more options, visit https://groups.google.com/d/optout. -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper http://www.sqlalchemy.org/ To post example code, please provide an MCVE: Minimal, Complete, and Verifiable Example. See http://stackoverflow.com/help/mcve for a full description. --- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.
