Case insensitive filter query with Objectify + google appengine

杀马特。学长 韩版系。学妹 提交于 2019-12-06 04:16:21

问题


Is there an easy way to do a case insensitive filter query with Objectify + google appengine (Java)? Essentially this is what I am trying to do except that I need the filter on email to be case insensitive.

Objectify objectifyService = ObjectifyService.begin();
objectifyService.query(AppUser.class).filter("email", email).get();

回答1:


You need to store your email address in a normalized (lowercase or uppercase, for instance) form in the datastore, and query on that. If you also need the original unmodified email address, you should store both separately.




回答2:


In case of queries we convert everything to a similar case and then do the comparison.

select * from account where upper(email) = upper('test@gmail.com');

In your case you could try.

objectifyService.query(AppUser.class).filter("upper(email)", email.toUpperCase()).get();

I am not sure if this will work with Objectify, you could give it a try.



来源:https://stackoverflow.com/questions/6201082/case-insensitive-filter-query-with-objectify-google-appengine

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!