django-data-browser icon indicating copy to clipboard operation
django-data-browser copied to clipboard

Postgres's InetAddressField

Open JasperWallace opened this issue 4 years ago • 3 comments

Using DDB with a database with an InetAddressField prints:

DDB: FBReport.source_ip unsupported type InetAddressField

When the initial migration is run and on every url request.

JasperWallace avatar Nov 10 '20 21:11 JasperWallace

After getting the model to be visible the fields contents are displayed and filtering gives isNull as an option, so DDB copes but dosn't have the nicer queries.

JasperWallace avatar Nov 10 '20 21:11 JasperWallace

Are they otherwise available in the ORM? If so you probably want to map a filter lookup, if not you might be able to hack it with a function subfield, similar to how the is_null subfield (as oppose to the filter lookup) is done.

For filter lookups you need a custom type in types.py (which is also where you can handle custom formatting). New lookups also need to be covered in orm_fields.py _get_django_lookup where the data browser lookup is mapped to the Django one.

For aggregates and functions it's all in orm_fields.py but you will still need a dedicated type in types.py because type subfields are currently overly bound to the types, aka I can't have different sets of subfields for the same type in different contexts.

For functions they are declared in _TYPE_FUNCTIONS and translated to django in _get_django_function. You can see the is_null thing I mentioned by looking for the IsNull function in that file.

For completeness aggregates are handled in a similar way with _TYPE_AGGREGATES and _get_django_aggregate.

tolomea avatar Nov 11 '20 09:11 tolomea

I want to make all of this more pluggable somehow, I also need to improve separation through here in as part of the whole sql alchemy thing.

tolomea avatar Nov 11 '20 09:11 tolomea