-
Notifications
You must be signed in to change notification settings - Fork 130
Returning ids/rows after bulk insert #107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 12 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
d0e2148
Implement can_return_rows_from_bulk_insert feature, returning ids or …
jean-frenette-optel 28411f7
Since mssql-django supports Django 2.2, we also need the pre-Django 3…
marcperrinoptel 7581cd1
My alternative changes on SQLInsertCompiler.as_sql.
marcperrinoptel fddb1fa
Don't try to use the OUTPUT clause when inserting without fields
marcperrinoptel eff9939
Actually we don't really have to offer the feature for Django 2.2, so…
marcperrinoptel a790db9
Tentative fix: when there are returning fields, but no fields (which …
marcperrinoptel cdc7560
Using MERGE INTO to support Bulk Insertion of multiple rows into a ta…
jean-frenette-optel c437f2c
Merge branch 'bulk-insert-ids-mpe' into dev
jean-frenette-optel 82ee55b
Add a link to a reference web page.
jean-frenette-optel 464b4e3
Attempt to make Django 2.2 tests pass
jean-frenette-optel 41899b4
Get back to a lighter diff of as_sql function vs. original
marcperrinoptel 8f39ec3
Merge pull request #1 from optelgroup/tweak-bulk-insert
jean-frenette-optel 0706960
Use a query to generate sequence of numbers instead of using the mast…
jean-frenette-optel a7a4d2c
Update mssql/operations.py
jean-frenette-optel 78f496a
Merge branch 'microsoft:dev' into dev
jean-frenette-optel 2a8bb82
Merge branch 'microsoft:dev' into dev
jean-frenette-optel 06af269
Simplification & refactoring
marcperrinoptel d8fd8b5
Merge pull request #4 from optelgroup/tweak-bulk-again
marcperrinoptel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A little bit of context to explain why we resort to a weird workaround to achieve bulk insertion in the case where there are no
self.query.fields
(but there are "returning fields"):INSERT...DEFAULT VALUES
won't help us: yes it is compatible withOUPUT INSERTED
, but it is limited to inserting a single row. It's fine to continue to "fake bulk" like this when no returning fields are desired, but it won't help us here (as there is only onecursor.fetchall()
to get all the returning values - unless we start overriding more stuff e.g.execute_sql
, which isn't appealing at all)INSERT
despite the absence ofself.query.fields
and using valueDEFAULT
for every column (x every row) isn't an option either, because that column list would basically be: all fields minus auto fields; but having only auto fields is certainly possible (cf. the infamousbulk_create.tests.BulkCreateTests.test_empty_model
), which leaves that list empty, and that does not work