kvesteri / wtforms-alchemy

Tools for creating wtforms from sqlalchemy models
Other
245 stars 59 forks source link

adds support for postgresql array and JSON field types #145

Closed havok2063 closed 3 years ago

havok2063 commented 5 years ago

This PR adds support for the Postgresql ARRAY and JSON data field types.

If possible, I'd like to get this merged in as I don't want to maintain a separate fork for these small changes and risk getting out of sync with general improvements. I'm happy to add more to get this into a state able to be merged.

havok2063 commented 3 years ago

Any possibility of getting this merged in.

kvesteri commented 3 years ago

Why would it be a sane default that PostgreSQL JSON and ARRAY types would use DecimalField? For me it doesn't make any sense.

havok2063 commented 3 years ago

@kvesteri It doesn't have to be. It's the type I needed when I made these changes. If you have a preferred type, please suggest it.

kvesteri commented 3 years ago

I don't think the default type map should contain database specific types (as there would be myriad of those, just think of SQLAlchemy and all of it's supported drivers). You can easily override the type map and give it your own defaults.

havok2063 commented 3 years ago

Well I'm happy to add support for the rest of the postgres-specific types if that helps this PR get approved and merged. There aren't a lot of database-specific types out there that aren't already covered by the defaults I think that would need to be added. Since sqlalchemy can connect to these databases, I think it's worth adding that support to the wtforms-alchemy package.

kvesteri commented 3 years ago

I think this is simply out of the scope of this package. User may add the types in a base class and then re-use that base class. However this package should not add default support for all different databases. Even if you added support for all PostgreSQL types that would leave the door open for adding types for other databases (MySQL, MSSQL, Oracle etc.)