qwc-services / qwc-data-service

QWC Data service
MIT License
5 stars 10 forks source link

Fix "UUID is not json serializable" error #7

Closed marioba closed 3 years ago

marioba commented 4 years ago

Having an id field with type UUID causes a "UUID is not json serializable" error. This patch fixes this error by casting the UUID to string.

Let me know if you think a different approach should be used.

marioba commented 4 years ago

I just noticed that this change solves the problem with creating new features, but there are problems with getting features if the id is a UUID, and if I cast it to string I get something like this: flask_restx.fields.MarshallingError: Unable to marshal field "id" value "a57a8ca6-0fe7-11eb-93a6-0242c0a8d004": invalid literal for int() with base 10: 'a57a8ca6-0fe7-11eb-93a6-0242c0a8d004'

@pka I'm not at all a Flask expert, would you mind giving me some tips on how to implement full UUID ids support?

pka commented 4 years ago

AFAIK UUID fields did already work in the past. @mwa Any hints for this?

mwa commented 4 years ago

UUID fields as attributes are still working.

If the primary key is a UUID, the Data Service does not return it as the GeoJSON feature ID but casts it as an integer (e.g. "id": 115649878869388305235834891892572684293). This results in errors when editing features, as the ID won't match.

The Data Service API is currently designed to use integer feature IDs only.