Skip to content

Conversation

@SuperJarek
Copy link
Contributor

No description provided.

}

public List<Child> getFilteredByFullName(String fullName) {
String[] splited = fullName.split("\\s+");
Copy link
Contributor

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(); 

?

Copy link
Contributor Author

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?

Copy link
Contributor

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?

Copy link
Contributor Author

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

Copy link
Contributor

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);
Copy link
Contributor

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)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What do you mean?

Copy link
Contributor

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(){
Copy link
Contributor

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));
Copy link
Contributor

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 ?

Copy link
Contributor

@malsolec malsolec left a 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 :)

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

Successfully merging this pull request may close these issues.

2 participants