Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

joData does not support query urls that have parameters #2

Open
asmarkis opened this issue Dec 1, 2015 · 4 comments
Open

joData does not support query urls that have parameters #2

asmarkis opened this issue Dec 1, 2015 · 4 comments

Comments

@asmarkis
Copy link

asmarkis commented Dec 1, 2015

I did a lot of research on what developers prefer and are saying about the oData standard. It seems like some feel that oData encourages leaky abstraction, which is not the best design principle.

I was looking through joData to see if there was any functionality that could add parameters to the query outside of oData. Either I couldn't find a proper way to do this, or it seems like it is unsupported.

For example, if I want to filter a query on:
/odata/EntityTables

Like so:
/odata/EntityTables?$filter=id eq 10

But have a parameter:
/odata/EntityTables?type=1&$filter=id eq 10

With joData, it will result in the incorrect uri:
/odata/EntityTables?type=1?$filter=id eq 10

So, the current workaround that I am using for this problem is adding the normal parameters on after the jodata filtering, which works, but is not ideal:
jodatauri = /odata/EntityTables?$filterTables?$filter=id eq 10
get(jodatauri.toString() + "&type=1");

Am I missing something, or is there missing functionality?

@asmarkis asmarkis changed the title joData does not support query url's with parameters joData does not support query urls that have parameters Dec 1, 2015
@druttka
Copy link
Collaborator

druttka commented Dec 1, 2015

It's been a long time since I looked at this project, and it looks like it has even evolved since the last time I did. The readme seems to indicate that custom query options are not currently supported.

I could imagine something like joData.raw('type=1') might be an interesting enhancement to support a scenario of adding any additional parameters to the generated query.

@druttka
Copy link
Collaborator

druttka commented Dec 1, 2015

As I thought about it more, what is this type parameter? Is it not something that could be part of a filter expression?

@druttka
Copy link
Collaborator

druttka commented Dec 1, 2015

One final thought. joData could look at the base to see if it already contains a ?, in which case it could use a leading & instead. Note that these comments were quite off-the-cuff and, again, based on a fairly outdated memory of what joData is doing =)

@asmarkis
Copy link
Author

asmarkis commented Dec 2, 2015

My "type" was an example parameter. So, "?exampleparameter=9000" would be part of the query but not part of the OData query parameters, for example.

Why I brought up "Leaky Abstraction" is because of the concern for the OData standard and its support in the long term. If you were to migrate the API to a different platform, these 'custom' parameters would still work, but 'OData' ones may not. You also don't want the applications to do their own query logic, the API should handle that, and the client should simply request the different commands the API is meant to support ;) So, yes,
"?$filter=type eq 1 "
would work as well, but maybe it is a parameter I want the API to require.

joData.raw('type=1') sounds like a good feature, but I think checking for an existing '?' after the final slash might also be good in the compatibility sense.

Thanks for the quick replies and insight on this issue!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants