问题
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