Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate models got wrong types #67

Closed
vietvudanh opened this issue Jun 14, 2018 · 3 comments · Fixed by #75
Closed

Generate models got wrong types #67

vietvudanh opened this issue Jun 14, 2018 · 3 comments · Fixed by #75

Comments

@vietvudanh
Copy link

sqlalchemy: 1.2.8
sqlacodegen: 2.0.0

Backend: MySQL 5.6

Table:

+----------------------+-------------+------+-----+---------+----------------+
| Field                | Type        | Null | Key | Default | Extra          |
+----------------------+-------------+------+-----+---------+----------------+
| id                   | int(11)     | NO   | PRI | NULL    | auto_increment |

When generate models, the types used in the model are INTEGER instead of Integer.

from sqlalchemy import BIGINT, CHAR, Column, DateTime, Float, INTEGER,

results in the columns are:

id = Column(INTEGER(11), primary_key=True)

This will raise error as the INTEGER or BIGINT takes no params:

TypeError: object() takes no parameters

I have to reverted sqlacodgen to v1.1.6 to make it work again.

@n0tevii
Copy link

n0tevii commented Jul 30, 2018

the problem also refused me.

@nijm
Copy link
Contributor

nijm commented Aug 20, 2018

I've just raised a pull request that I think fixes this issue: #75

agronholm pushed a commit that referenced this issue Sep 9, 2018
* Import vendor-specific types when generic types cannot be used.

If a vendor-specific type cannot be adapted to a generic sqlalchemy then
import the vendor-specific type rather than the generic type. Some
vendor-specific types have different constructors. E.g., MySQL INTEGER,
which takes an optional display width.

* Bugfix for mysql TINYTEXT, MEDIUMTEXT, and LONGTEXT.

Don't adapt types further if they cannot be compiled.

Fixes #67.
@agronholm
Copy link
Owner

There's a new release out which fixes this.

Havoc24k pushed a commit to 7Linternational/sqlacodegen that referenced this issue Sep 12, 2018
…nholm#75)

* Import vendor-specific types when generic types cannot be used.

If a vendor-specific type cannot be adapted to a generic sqlalchemy then
import the vendor-specific type rather than the generic type. Some
vendor-specific types have different constructors. E.g., MySQL INTEGER,
which takes an optional display width.

* Bugfix for mysql TINYTEXT, MEDIUMTEXT, and LONGTEXT.

Don't adapt types further if they cannot be compiled.

Fixes agronholm#67.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants