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

Check properties existence in PathBuilder #79

Closed
tbruyelle opened this issue Jan 11, 2012 · 6 comments
Closed

Check properties existence in PathBuilder #79

tbruyelle opened this issue Jan 11, 2012 · 6 comments

Comments

@tbruyelle
Copy link

@tbruyelle tbruyelle commented Jan 11, 2012

The PathBuilder constructor doesn't check the existence of the property in parameter. It would be nice if an exception is throwed in case of unknow property.

@timowest
Copy link
Member

@timowest timowest commented Jan 11, 2012

You mean to check if a Java Bean Property exists in the class?

@tbruyelle
Copy link
Author

@tbruyelle tbruyelle commented Jan 11, 2012

Oups I mean to check the properties existence in getter, not in PathBuilder constructor.

If I have a generated class with QUser.user.name then

 new PathBuilder(User.class).get("name") // OK
 new PathBuilder(User.class).get("foo") // throw exception because QUser.user.foo doesn't exists

@timowest
Copy link
Member

@timowest timowest commented Jan 11, 2012

This logic implicates a coupling between PathBuilder and the Q-type. The following behaviour would be better :

new PathBuilder(User.class).get("name") // OK, if User.getName() exists
new PathBuilder(User.class).get("foo") // throw exception because User.getFoo() doesn't exist

QUser might not be available, and it might not be QUser, but something else.

Is this ok with you?

@timowest
Copy link
Member

@timowest timowest commented Jan 14, 2012

I added a template method for validation. Subclasses can now define their own validation logic. I didn't put Bean property validation directly into PathBuilder, since typesafe usage is already possible via Q-type generation and because the existence of a Bean property doesn't implicate that the property is valid for querying. Sometimes Q-type properties are also generated from fields without Java Bean accessors.

@tbruyelle
Copy link
Author

@tbruyelle tbruyelle commented Jan 15, 2012

Thanks Timo I will try to implement a validation on property existence as soon as I have enough time.

@timowest
Copy link
Member

@timowest timowest commented Feb 7, 2012

released in 2.3.1

@timowest timowest closed this Feb 7, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants