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

Comments

Projects
None yet
2 participants
@tbruyelle

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

This comment has been minimized.

Show comment
Hide comment
@timowest

timowest Jan 11, 2012

Member

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

Member

timowest commented Jan 11, 2012

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

@tbruyelle

This comment has been minimized.

Show comment
Hide comment
@tbruyelle

tbruyelle 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

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

This comment has been minimized.

Show comment
Hide comment
@timowest

timowest Jan 11, 2012

Member

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?

Member

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

This comment has been minimized.

Show comment
Hide comment
@timowest

timowest Jan 14, 2012

Member

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.

Member

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

This comment has been minimized.

Show comment
Hide comment
@tbruyelle

tbruyelle Jan 15, 2012

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

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

@timowest

This comment has been minimized.

Show comment
Hide comment
@timowest

timowest Feb 7, 2012

Member

released in 2.3.1

Member

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