developmentseed / tipg

Simple and Fast Geospatial OGC Features and Tiles API for PostGIS.
https://developmentseed.org/tipg/
MIT License
150 stars 22 forks source link

fix function based collections without params #96

Closed jackharrhy closed 1 year ago

jackharrhy commented 1 year ago

What I am changing

How I did it

How you can test it

Create the following function

CREATE OR REPLACE FUNCTION public.test() RETURNS TABLE(foo integer, location geometry)
AS 'SELECT 1, ST_MakePoint(0,0);' LANGUAGE SQL;

Currently

Launching tipg will fail when it goes to create an instance of Collection based off of this function due to a validation error

After this PR

Launching tipg will work as expected without any validation errors

jackharrhy commented 1 year ago

@vincentsarago if you'd like a test for this let me know and i can do that as well :)

vincentsarago commented 1 year ago

Thanks @jackharrhy

if you'd like a test for this let me know and i can do that as well :)

Yes please 🙏

bitner commented 1 year ago

I might be missing something, but I don't see how this is doing anything differently than parameters=table.get("parameters", [])?

vincentsarago commented 1 year ago

@bitner because I guess table can have parameters=None.

Maybe this tell us there is a bug and that parameters should always default to [] or not be set in table if empty

vincentsarago commented 1 year ago

@bitner

Maybe this tell us there is a bug and that parameters should always default to [] or not be set in table if empty

This is what table look like

{'name': 'test', 'entity': 'Function', 'schema': 'public', 'parameters': None, 'properties': [{'name': 'foo', 'type': 'integer'}, {'name': 'location', 'type': 'geometry', 'geometry_type': 'Geometry'}]}

You can see that tipg_catalog function returns None for parameters

vincentsarago commented 1 year ago

I have updated the code and added tests. @bitner I think we don't need to change the tipg_catalog SQL code to return [] by default for now!

jackharrhy commented 1 year ago

Thanks for taking this over and getting it sorted!