agronholm/sqlacodegen

Not picking up unsigned number fields properly

robvdl opened this issue · 6 comments

Things to check first

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

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

Sqlacodegen version

3.0.0rc5

SQLAlchemy version

2.0.34

RDBMS vendor

MySQL (or compatible)

What happened?

I generated models from an existing MySQL database and wherever "unsigned int" was used, sqlacodegen incorrectly translated it to INTEGER rather than INTEGER(unsigned=True).

There was even an unsigned decimal in the source schema that can happen too, that needed to become DECIMAL(3, 9, unsigned=True) for example.

Sorry I can't really release the source schema, customer database.

Database schema for reproducing the bug

No response

This version of SQLAlchemy is not supported. I suggest you try with SQLAlchemy 2.x.

Oh somehow I mistyped that, it was meant to be 2.0.34, I'll fix it.

If I have to create an example, I can probably craft something up over the weekend.

Basically I've found that wherever UNSIGNED is used, sqlacodegen is not picking that part up and just interpreting it as INTEGER rather than INTEGER(unsiged=True). This is using the MySQL specific INTEGER field in SQLAlchemy.

What sqlacodegen seems to have done is it has used the right field type wherever UNSIGNED is used it seems to have picked the MySQL specific field. It's just lacking unsigned=True as the args.

Is SQLAlchemy's reflection picking up the unsigned? If not, there's nothing I can do.

Understood. I'lll have to have a look.

Closing due to no activity in months, and likely not an sqlacodegen issue.