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

empty result instead of timeout #31

Open
ro70 opened this issue Feb 19, 2016 · 6 comments
Open

empty result instead of timeout #31

ro70 opened this issue Feb 19, 2016 · 6 comments
Assignees

Comments

@ro70
Copy link

ro70 commented Feb 19, 2016

A load$ query to a non-existing entity ends up in a timeout. It should better return an empty object {}, shouldn't it?

@mcdonnelldean
Copy link
Contributor

@ro70 Agreed. @mihaidma @mirceaalexandru @geek Thoughts on this?

@mirceaalexandru
Copy link
Collaborator

I think that we should return error because we should signal that there is setup issue, not just that there is not a matching entity in DB.

We should also check what is the behavior of the drivers we are using for each DB engine, as one can return error, others can return {}, so might not have a consistent API across our stores.

This problem do not exist for MongoDb as it will just create the collection if necessary, but for Postgres/Mysql there is another case, there should be created manually - but I don't know the response from their drivers for this scenario.

@mirceaalexandru
Copy link
Collaborator

@ro70 I understood that this problem appear when the table do not exists yes?

@mihaidma
Copy link
Contributor

The spec for this case is this: https://github.com/senecajs/seneca-store-test/blob/master/store-test.js#L111
return null for non existing entity

@mirceaalexandru let's open a discussion about returned value for list and load when nothing matches.
I'll let this issue open to investigate the timeout, it shouldn't give timeout. I'll get to it in the next few days as I am currently working on mysql store.

@mihaidma mihaidma self-assigned this Feb 20, 2016
@ro70
Copy link
Author

ro70 commented Feb 21, 2016

@mirceaalexandru , @mihaidma The table does exist. Imagine the following use case: There's a table 'PlayersPoints' with the fields 'id', 'player_id' and 'points'. As long as a player has zero points, there's no entity with its player_id. If I'd like to know how many points a specific player has, I do playerEntity.load$({player_id: id}...). The resulting set may be empty (or null if you want). It even is alright to throw a (nothing found) error in this case, but waiting for a timeout is not the best solution in my opinion.

@mirceaalexandru
Copy link
Collaborator

@ro70 , sorry I understood that table do not exists, my comment was for that scenario.

In this case the result should be null in my opinion, and timeout is a bug that needs to be fixed.

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

No branches or pull requests

4 participants