Skip to content
This repository has been archived by the owner on Apr 17, 2018. It is now read-only.

Raise error in Repository#read if query is not valid; resolve #16 #295

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Raise error in Repository#read if query is not valid; resolve #16 #295

wants to merge 2 commits into from

Conversation

tpitale
Copy link
Member

@tpitale tpitale commented May 24, 2016

No description provided.

@tpitale
Copy link
Member Author

tpitale commented May 24, 2016

@mbj Does this seem like a half-decent approach to that problem? I still have to write specs 😉

@mbj
Copy link
Member

mbj commented May 24, 2016

@tpitale Its more decent, yes.

begin
query.repository.read(query).first
rescue Query::InvalidConditionsError
nil
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Required because the checks for invalid query do not actually represent an invalid query.

One such example: Article.first(id: nil) Should immediately return nil, nobody expects this to raise an error.

This checks validity by asking the property Article.properties[:id].valid?(nil). Obviously this is invalid (given this property is Serial/key).

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

Successfully merging this pull request may close these issues.

2 participants