-
Notifications
You must be signed in to change notification settings - Fork 37
#297: Add child - search for child #320
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
base: master
Are you sure you want to change the base?
#297: Add child - search for child #320
Conversation
…into 297-add-child-search-for-child
| } | ||
|
|
||
| public List<Child> getFilteredByFullName(String fullName) { | ||
| String[] splited = fullName.split("\\s+"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found that Greendao supports like. What not write only:
return daoSession.getChildDao().queryBuilder()
.whereOr(Properties.Name.like("%" + fullName + "%"),
Properties.Surname.like("%" + fullName + "%"))
.list();
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, do you have an idea how to write "WHERE (name LIKE ? AND surname LIKE ?) OR (name LIKE ? AND surname LIKE ?)" this query using query builder?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why? What case are you trying to cover?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"WHERE (name LIKE firstWord AND surname secondWord ?) OR (name secondWord ? AND surname LIKE firstWord)" - line 43 in ChildRepository.java
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I didn't get your point. Sure, you need this case also.
code:
QueryBuilder childQueryBuilder = daoSession.getChildDao().queryBuilder();
childQueryBuilder.whereOr(childQueryBuilder.and(Properties.Name.like("%" + splited[0] + "%"),
Properties.Surname.like("%" + splited[1] + "%")),
childQueryBuilder.and(
Properties.Name.like("%" + splited[1] + "%"),
Properties.Surname.like("%" + splited[0] + "%"))
);
created sql ( you can see it in childQueryBuilder.build().sql):
SELECT T."_id",T."NAME",T."SURNAME",T."FONT_SIZE",T."PICTURE_SIZE",T."DISPLAY_MODE" FROM "CHILD" T
WHERE ((T."NAME" LIKE ? AND T."SURNAME" LIKE ?)
OR (T."NAME" LIKE ? AND T."SURNAME" LIKE ?))
| public boolean onCreateOptionsMenu(Menu menu) { | ||
| MenuInflater menuInflater = getMenuInflater(); | ||
| menuInflater.inflate(R.menu.plan_list_menu, menu); | ||
| MenuItem searchViewItem = menu.findItem(R.id.menu_search); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have you tried you use data binding here? (Similar to save data button)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you mean?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean data binding for keeping searchViewItem object without finding it by id or implement setOnQueryTextListener with managing this action by data binding not manually finding it. Like in PlanCreate but for menu it could be a little different.
| + testedChildPosition)))); | ||
| } | ||
| @Test | ||
| public void whenSearchForAChildWithFirstLettersOfNameAndSurnameExpectThatChildOnFirstPosition(){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I understand the tests search by first letter of surname and first of name eg. John Smith will be found after J S . I don't think this case should be covered. I think part of name or surname or both is enough. What do you think ?
| final int testedChildPosition = 3; | ||
| final int firstPosition = 0; | ||
| onView(withId(R.id.menu_search)).perform(typeText( | ||
| EXPECTED_LAST_NAME + testedChildPosition + " " + EXPECTED_FIRST_NAME)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This case is OK, but I think it will be enough to cover only NAME or SURNAME or NAME SURNAME or part of this. You don't need to worry about more, but it's nice you tried :) Could you please leave only tests that are covering these cases ?
malsolec
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! nice job :)I added few comments, please consider my comments :)
No description provided.