sqlacodegen icon indicating copy to clipboard operation
sqlacodegen copied to clipboard

MySQL DOUBLE(11,2) is converted to Double(11, True)

Open luliangce opened this issue 8 months ago • 0 comments

Things to check first

  • [X] I have searched the existing issues and didn't find my bug already reported there

  • [X] I have checked that my bug is still present in the latest release

Sqlacodegen version

3.0.0rc5

SQLAlchemy version

2.0.29

RDBMS vendor

MySQL (or compatible)

What happened?

when generate from this table

CREATE TABLE `demo` (
  `type_double` double(11,2) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci

result below

from sqlalchemy import Column, Double, MetaData, Table

metadata = MetaData()


t_demo = Table(
    'demo', metadata,
    Column('type_double', Double(11, True)) # this code  absolutely not working
)

according the code, this is a hack for postgresql float , but didn't check dialect

https://github.com/agronholm/sqlacodegen/blob/3.0.0rc5/src/sqlacodegen/generators.py#L690

Database schema for reproducing the bug

CREATE TABLE demo ( type_double double(11,2) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci

luliangce avatar Jun 18 '24 10:06 luliangce