简体   繁体   English

使用 Objectify + google appengine 的不区分大小写的过滤器查询

[英]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)?有没有一种简单的方法可以使用 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.基本上这就是我想要做的,除了我需要 email 上的过滤器不区分大小写。

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

You need to store your email address in a normalized (lowercase or uppercase, for instance) form in the datastore, and query on that.您需要将 email 地址以规范化(例如,小写或大写)形式存储在数据存储中,并对其进行查询。 If you also need the original unmodified email address, you should store both separately.如果您还需要原始未修改的 email 地址,则应分别存储。

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.我不确定这是否适用于 Objectify,您可以尝试一下。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM