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

whereIsNotNull is not computing relation field name #134

Open
alez007 opened this issue Mar 22, 2017 · 0 comments
Open

whereIsNotNull is not computing relation field name #134

alez007 opened this issue Mar 22, 2017 · 0 comments

Comments

@alez007
Copy link

alez007 commented Mar 22, 2017

Hello,

First of all, thank you for this library ;)

Just a quick one that fortunately has a fix but can be added to future updates:

new RushSearch().startGroup().whereIsNotNull("user").and().whereEqual("user", user).endGroup().orderDesc("created").find(AssetModel.class);

is "user" is a relation and it happens to return null, let's say we saved AssetModel with a null user at some point, then whereIsNotNull is only searching for a table primitive named "user", the where statement looks like this:

WHERE (rush_uk_co_vicast_communityapp_model_AssetModel_rush_uk_co_vicast_communityapp_model_UserModel_user.child IS NOT NULL AND user='V8g95') and normally we should replace "user" with "rush_uk_co_vicast_communityapp_model_AssetModel_rush_uk_co_vicast_communityapp_model_UserModel_user.child" for the full query to work.

A fast fix would be to calculate the "user" relation field name in advance like this:

Map annotationCache = RushCore.getInstance().getAnnotationCache(); String userFieldName = ReflectionUtils.joinTableNameForClass(((AnnotationCache)annotationCache.get(AssetModel.class)).getTableName(), ((AnnotationCache)annotationCache.get(UserModel.class)).getTableName(), "user") + ".child";

and then insert it into the query replacing "user" to userFieldName variable.

Thank you,
Alex

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

1 participant