art1415926535 / graphene-sqlalchemy-filter

Filters for Graphene SQLAlchemy integration
https://pypi.org/project/graphene-sqlalchemy-filter/
MIT License
118 stars 34 forks source link

Support for MS SQL types #1

Closed katerinagreif closed 5 years ago

katerinagreif commented 5 years ago

Hi, would it be possible to include mssql types as well as potsgreSQL?When my data is in MS SQL database it throws an error using declerativebase in SQL alchemy if I try to make a filter on variable that isn't converted into SQLalchemy type. Here is the error:

File "\venv\lib\site-packages\graphene_sqlalchemy_filter\filters.py", line 359, in _generate_default_filters expressions = filters_map[column_type.__class__].copy() KeyError: <class 'sqlalchemy.sql.sqltypes.NVARCHAR'>

katerinagreif commented 5 years ago

Hi, Played with it and solved by adding:

types.VARCHAR: [EQ, NE, LIKE, ILIKE, REGEXP, IN, NOT_IN], types.NVARCHAR: [EQ, NE, LIKE, ILIKE, REGEXP, IN, NOT_IN], to filters.py, thinking of using this as a demo, can create branch, if you would like.

art1415926535 commented 5 years ago

I updated the algorithm works with ALLOWED_FILTERS. Now the column type can be a subclass of the existing types (ALLOWED_FILTERS keys). This made ALLOWED_FILTERS more simple.

The new variable EXTRA_ALLOWED_FILTERS also allows you to register new column types.

Check new version.

katerinagreif commented 5 years ago

Thanks, works.