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
DATABASES= {
"default": {
"ENGINE": "mssql",
"NAME": os.getenv("DB_NAME"),
"USER": os.getenv("DB_USER"),
"PASSWORD": os.getenv("DB_PASSWORD"),
"HOST": os.getenv("DB_HOST", "127.0.0.1"),
"PORT": int(os.getenv("DB_PORT", "1433")),
"OPTIONS": {
# This database doesn't have any triggers so can use return# rows from bulk insert feature"return_rows_bulk_insert": True
},
}
}
Problem description and steps to reproduce
The UUID column gets created using a CHAR(24) column, and gets a corresponding primary key index, also in CHAR(24).
When executing a query filtering on that column, using Foobar.objects.get(reference=uuid.UUID(...)), the uuid gets passed as an NCHAR to the database. This makes MSSQL do a full index scan, converting all index values to NCHAR to compare them.
Expected behavior and actual behavior
I would expect the UUID to be passed as CHAR values, in order to have parameters match the index and column types without conversion.
Any other details that can be helpful
The workaround we found for our most used queries is to do them manually and insert the uuid directly into the query string, taking care to ensure only valid UUIDs can be inserted at that point to avoid SQL injection. But that approach is not scalable to all queries.
The text was updated successfully, but these errors were encountered:
There are some features which are not supported yet. Please check the Limitations first to see if your bug is listed.
Software versions
Table schema and Model
Database Connection Settings
Problem description and steps to reproduce
The UUID column gets created using a
CHAR(24)
column, and gets a corresponding primary key index, also in CHAR(24).When executing a query filtering on that column, using
Foobar.objects.get(reference=uuid.UUID(...))
, the uuid gets passed as an NCHAR to the database. This makes MSSQL do a full index scan, converting all index values to NCHAR to compare them.Expected behavior and actual behavior
I would expect the UUID to be passed as CHAR values, in order to have parameters match the index and column types without conversion.
Any other details that can be helpful
The workaround we found for our most used queries is to do them manually and insert the uuid directly into the query string, taking care to ensure only valid UUIDs can be inserted at that point to avoid SQL injection. But that approach is not scalable to all queries.
The text was updated successfully, but these errors were encountered: