PostgREST / postgrest

REST API for any Postgres database
https://postgrest.org
MIT License
23.27k stars 1.02k forks source link

Follow odata v4 specifications? #1398

Closed FGRibreau closed 3 years ago

FGRibreau commented 4 years ago

We might want to follow that in postgrest for pagination, field expansion, field selection etc... https://www.odata.org/documentation/

Just posting it here because I did not see any discussion around it :)

steve-chavez commented 4 years ago

What would be the advantages of adopting those specifications?

FGRibreau commented 4 years ago

Instead of postgrest own way of declaring filter operators and pagination we can rely on a standardized way to do things.

Thus promoting standard instead of doing/maintaining our own ^^'

steve-chavez commented 4 years ago

I had a glimpse of that spec. It uses url unsafe characters(the query string contains slashes and lots of spaces) which implies not being url friendly and needing to urlencode to share. The usage of $ makes the url harder to read too. Overall that spec doesn't look like an improvement to what we have.

Also I don't think of it as a standard — since that would imply it's normally used/accepted — because I haven't seen any API in the wild following that spec(unlike, say, graphql apis).

Now, we do follow several standards. For example, for pagination, we follow RFC 7233. The query string syntax does follow our own way.

Instead of being caught up in the Fire and Motion of trying to comply with other specs, what I think we should do is to properly document our query string syntax(some advances in https://github.com/PostgREST/postgrest-docs/issues/228) and do a draft spec in our docs.

I say this(and think it's worth doing) because PostgREST has influenced REST implementations(blockapps API) and possibly other specs.

That would be much more easier to do and maintain for us.

ako commented 4 years ago

Benefit of odata is that there are a number of useful tools that already have odata support built in.

OData is used heavily by SAP and Microsoft to expose data. On the consuming side you have tools like PowerBI, Excel, Tableau, Lyncpad, Microsoft SSIS (ETL) that can directly read odata. Odata provides users the option to do analytics on data where the database is not directly available.

steve-chavez commented 4 years ago

Realistically speaking, if compatibility with another spec is desired, the best way to do it would be translating the request at the proxy layer. In a simillar manner to what ppKrauss/PostgREST-writeAPI does.

wolfgangwalther commented 3 years ago

It seems like the result of this discussion is the goal to better document the existing query string syntax. https://github.com/PostgREST/postgrest-docs/issues/228 is still open for that, so I am closing this here.

shayneoneill commented 1 year ago

Was this going to be a wont-do ? Theres an integration I have that needs odata but the closest to a solution I've found is one of those awful random cloud offerings where they wont even tell you a price unless you talk to a salesman (Thats an instant "NOPE" from me. hidden prices means something to hide.)

steve-chavez commented 1 year ago

Theres an integration I have that needs odata but the closest to a solution I've found is one of those awful random cloud offerings where they wont even tell you a price unless you talk to a salesman

Yeah, I see those too. No true OSS alternative. Also now some products offer OData integrations.

Nowadays we have better separation of concerns in our codebase. We have ASTs for the different operations:

https://github.com/PostgREST/postgrest/blob/60fe59c3fb1e62eefc0262ed661acaf3ce381647/src/PostgREST/Plan/ReadPlan.hs#L30-L48

https://github.com/PostgREST/postgrest/blob/60fe59c3fb1e62eefc0262ed661acaf3ce381647/src/PostgREST/Plan/MutatePlan.hs#L19-L46

And the query string parsing is done on

https://github.com/PostgREST/postgrest/blob/60fe59c3fb1e62eefc0262ed661acaf3ce381647/src/PostgREST/ApiRequest.hs#L143

In theory we could have an external Haskell library that translates the query string into that AST.

Likely I miss some details, but overall it seems more feasible now.

HoldYourWaffle commented 14 hours ago

I would love to have an OData interface to PostgreSQL for similar reasons as @ako. Excel's "native" support is dreadful, OData tends to be more pleasant to use.

In theory we could have an external Haskell library that translates the query string into that AST.

@steve-chavez is this still the current state of things? I haven't touched Haskell before, but contributing in this area sounds much more fun than writing and maintaining my own custom solution :)