SQLInsertCompiler and DatabaseOperations.return_insert_id for non standard backends
|Reported by:||manfre||Owned by:||nobody|
|Component:||Database layer (models, ORM)||Version:||1.4|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
I ran in to a problem with SQLInsertCompiler while trying to allow django-mssql to have can_return_id_from_insert = True. The problem is that SQLInsertCompiler requires that an SQL fragment (returned by ops.return_insert_id) is appended to the end of the insert statement, but the fragment must also accept the full quoted table and column name.
The problem for mssql, is that the OUTPUT clause doesn't conform to these two requirements and is better served by mangling the SQL query in its own SQLInsertCompiler. To make this possible (in a backwards compatible way), the output of return_insert_id needs to be checked and ignored if r_fmt is None.
Change History (3)
comment:1 Changed 4 years ago by aaugustin
- Needs documentation unset
- Needs tests unset
- Patch needs improvement unset
- Triage Stage changed from Unreviewed to Accepted
- Type changed from Uncategorized to Cleanup/optimization