Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to ignore case in an NDB/DB query

This seems like a simple question, but I don't see anything in the class definition.

If I have the query

Video.query(Video.tags.IN(topics))

topics are coming in as lowercase unicode strings, but Video.tags are mostly capitalized. I can loop through topics and capitalize them before querying with them, but is there a way to ignore case altogether?

like image 349
mehulkar Avatar asked Dec 11 '22 16:12

mehulkar


1 Answers

It's not possible to ignore case in a query.

Typically if you know you want to do a case insensitive search, you may store a "denormalized" duplicate of the data in lower case. Whenever you want to query, you would lowercase the text before querying.

To reduce write costs, you probably only want to index the lowercased version, and you probably wouldn't need to index the actual case-sensitive data.

like image 139
dragonx Avatar answered Jan 09 '23 04:01

dragonx