Sai
Sai

Reputation: 3957

Case insensitive filter query with Objectify + google appengine

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

Upvotes: 4

Views: 2310

Answers (2)

Nick Johnson
Nick Johnson

Reputation: 101149

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.

Upvotes: 7

kensen john
kensen john

Reputation: 5519

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

select * from account where upper(email) = upper('[email protected]');

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.

Upvotes: 0

Related Questions