Giter Club home page Giter Club logo

Comments (4)

stebunovd avatar stebunovd commented on August 30, 2024

hey @caleb15,

The ~ comparison operator translates into __icontains, that means case-insensitive comparison with SQL like operator. Direct strings comparison via = should be case-sensitive or case-insensitive depending on your database collation settings. Just in case if you're using SQLite - please note that SQLite is unable to do a case-insensitive comparison of Unicode strings at all.

thanks,

Denis

from djangoql.

caleb15 avatar caleb15 commented on August 30, 2024

Ah, I tested it and you're right, ~ is case-insensitive. Thanks for the tip.

We are not using SQLlite, but that's good to know.

from djangoql.

pandichef avatar pandichef commented on August 30, 2024

Which database would be case sensitive for =? I'm using MySQL and it's case insensitive for both ~ and =... which I don't love. For future development, I'd suggest going case insensitive everywhere and adding functions like lower(), upper(), startswith(), and endswith(). So if you prefer case insensitive, you can use lower(county)~"germany".

from djangoql.

stebunovd avatar stebunovd commented on August 30, 2024

Which database would be case sensitive for =?

it depends on the collation for a particular column in a table. Database engines have different collations, both case-sensitive and case-insensitive, that can be set on different levels (database, table, or column). Here is the explanation for MySQL.

DjangoQL = operator is translated to a direct comparison in Django ORM, i.e. name = "John" on User model becomes User.objects.filter(name="John"). The latter is translated to an SQL query like select * from auth_user where name = "John", and the database engine itself performs string comparisons that are case-sensitive or case-insensitive depending on the collation for name column in auth_user table.

In theory, Django provides an abstraction over this in the form of __exact and __iexact comparison operators, but unfortunately it doesn't work for MySQL.

from djangoql.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.