You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When our database is case and accent insensitive, search functionality does not work.
Software versions
Django: 5.0
mssql-django: 1.5
python: 3.12
SQL Server: 15.0.4390
OS: Windows
The root case is the function sqlserver_replace in functions.py. In that method, there is a replace where that changes CI by CS. If the default collation is SQL_Latin1_General_CP1_CI_AI, the result is SQL_Latin1_General_CP1_CS_AI which does not exist.
The exception is as follows:
django.db.utils.ProgrammingError: ('42000', "[42000] [Microsoft][ODBC Driver 18 for SQL Server][SQL Server]Invalid collation 'SQL_Latin1_General_CP1_CS_AI'. (448) (SQLExecDirectW); [42000] [Microsoft][ODBC Driver 18 for SQL Server][SQL Server]Statement(s) could not be prepared. (8180)")
My suggestion is to replace the current line: current_collation = default_collation.replace('_CI', '_CS')
by current_collation = default_collation.replace('_CI', '_CS') if default_collation.endswith('_AS') else default_collation
The text was updated successfully, but these errors were encountered:
When our database is case and accent insensitive, search functionality does not work.
Software versions
The root case is the function
sqlserver_replace
infunctions.py
. In that method, there is a replace where that changes CI by CS. If the default collation is SQL_Latin1_General_CP1_CI_AI, the result is SQL_Latin1_General_CP1_CS_AI which does not exist.The exception is as follows:
My suggestion is to replace the current line:
current_collation = default_collation.replace('_CI', '_CS')
by
current_collation = default_collation.replace('_CI', '_CS') if default_collation.endswith('_AS') else default_collation
The text was updated successfully, but these errors were encountered: