django-sqlserver
django-sqlserver copied to clipboard
Support case sensitive/case insensitive comparisons
There is a similar ticket for django-mssql: https://bitbucket.org/Manfre/django-mssql/issue/36/support-case-sensitive-comparisons
We get database collation by checking:
SELECT DATABASEPROPERTYEX('
If the database collation is case sensitive (Latin1_General_BIN) and django tries to do case insensitive filtration such as icontains can we append the corresponding case insensitive collation (Latin1_General_CI_AS) just behind column name ?
The sql query will look like:
select * from
That is not reliable, it is possible for a table or even a column to have a collation different from the database collation.
Can we check column collation ?
You can, but I think this would be a performance hit if you do it on every request. One way you can do it is by adding an extension function here https://bitbucket.org/Manfre/django-mssql/src/1d8da0ee6dd4c1f1e32d29bf405dd8c7e682fba8/extras/sqlserver/regex_clr/REGEXP_LIKE.cs?at=master
You can call functions CS_LIKE and CI_LIKE for case sensitive and case insensitive kinds.