flask-sqlacodegen
flask-sqlacodegen copied to clipboard
Add support for SET column type [wishlist]
sqlacodegen
seems to work fine with ENUM
types; SET
s are a different story.
If you attempt to run on a database with a SET
column type, such as the following:
CREATE TABLE `tools_datasets` (
`tool_id` int(11) NOT NULL,
`dataset_id` int(11) NOT NULL,
`status` SET('p','i','e') DEFAULT 'i,e',
PRIMARY KEY (`tool_id`,`dataset_id`),
);
you'll get an error like this:
$ flask-sqlacodegen --version
1.1.6.1
$ flask-sqlacodegen --tables tools_datasets $DBCONN
Traceback (most recent call last):
File "/Users/user/path/to/project/venv/bin/flask-sqlacodegen", line 11, in <module>
sys.exit(main())
File "/Users/user/path/to/project/venv/lib/python2.7/site-packages/sqlacodegen/main.py", line 59, in main
args.flask, ignore_cols, args.noclasses)
File "/Users/user/path/to/project/venv/lib/python2.7/site-packages/sqlacodegen/codegen.py", line 606, in __init__
model = ModelClass(table, links[table.name], inflect_engine, not nojoined)
File "/Users/user/path/to/project/venv/lib/python2.7/site-packages/sqlacodegen/codegen.py", line 309, in __init__
super(ModelClass, self).__init__(table)
File "/Users/user/path/to/project/venv/lib/python2.7/site-packages/sqlacodegen/codegen.py", line 248, in __init__
column.type = column.type.adapt(cls)
File "/Users/user/path/to/project/venv/lib/python2.7/site-packages/sqlalchemy/dialects/mysql/enumerated.py", line 310, in adapt
**kw
File "/Users/user/path/to/project/venv/lib/python2.7/site-packages/sqlalchemy/util/langhelpers.py", line 1045, in constructor_copy
return cls(*args, **kw)
TypeError: __init__() got an unexpected keyword argument 'retrieve_as_bitwise'
I know that the SET
column type is kind of out in the weeds (maybe it's better to just use a many-to-many relationship), but honestly, is ENUM
is kind of in that category, too , so maybe we could work to support SET
as well.
Thanks for creating the issue @ernstki
@ksindi Hi, I got the same issue.
I am using:
- flask-sqlacodegen 1.1.8
- SQLAlchemy 1.3.20
I found this issue has been fixed by the latest version of sqlacodegen library.
Here is the link https://github.com/agronholm/sqlacodegen/issues/85