aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/insert_all_test.rb
Commit message (Collapse)AuthorAgeFilesLines
* handle passing in primary key to unique_by, and handle primary keys missing ↵Lachlan Sylvester2019-08-051-0/+18
| | | | indexes
* Enable `Layout/EmptyLinesAroundAccessModifier` copRyuta Kamizono2019-06-131-1/+0
| | | | | | | | | | | We sometimes say "✂️ newline after `private`" in a code review (e.g. https://github.com/rails/rails/pull/18546#discussion_r23188776, https://github.com/rails/rails/pull/34832#discussion_r244847195). Now `Layout/EmptyLinesAroundAccessModifier` cop have new enforced style `EnforcedStyle: only_before` (https://github.com/rubocop-hq/rubocop/pull/7059). That cop and enforced style will reduce the our code review cost.
* Merge pull request #35892 from ryohashimoto/bulk_insert_logsEileen M. Uchitelle2019-04-081-0/+49
|\ | | | | Improve log messages for #insert_all` / `#upsert_all` etc. methods
| * Improve log messages for #insert_all` / `#upsert_all` / `#insert` / `#upsert ↵Ryo Hashimoto2019-04-081-0/+49
| | | | | | | | | | | | | | | | etc. methods In #35077, `#insert_all` / `#upsert_all` / `#insert` / `#upsert` etc. methods are added. But Active Record logs only “Bulk Insert” log messages when they are invoked. This commit improves the log messages to use collect words for how invoked them.
* | When skipping duplicates in bulk insert on MySQL, avoid assigning id when ↵Bob Lail2019-04-081-0/+38
|/ | | | | | | | | | | not specified If `id` is an `AUTONUMBER` column, then my former strategy here of assigning `no_op_column` to an arbitrary column would fail in this specific scenario: 1. `model.columns.first` is an AUTONUMBER column 2. `model.columns.first` is not assigned in the insert attributes I added three tests: the first test covers the actual error; the second test documents that this _isn't_ a problem when a value is given for the AUTONUMBER column and the third test ensures that this no-op strategy isn't secretly doing an UPSERT.
* Extract insert test case from #35686Kasper Timm Hansen2019-03-311-0/+14
|
* Bulk Insert: Reuse indexes for unique_byKasper Timm Hansen2019-03-201-3/+33
| | | | | | | | | | | I found `:unique_by` with `:columns` and `:where` inside it tough to grasp. The documentation only mentioned indexes and partial indexes. So why duplicate a model's indexes in an insert_all/upsert_all call when we can just look it up? This has the added benefit of raising if no index is found, such that people can't insert thousands of records without relying on an index of some form.
* Raise UnknownAttributeError when unknown column is passed to insert_all and ↵Josef Šimánek2019-03-161-0/+6
| | | | friends.
* Add some whitespace for readability.Kasper Timm Hansen2019-03-061-0/+12
|
* Fix test case name after file extractionKasper Timm Hansen2019-03-061-1/+1
| | | | | Although the old name had a certain persistence, this ain't the kind of file we're in now.
* Handle blank inserts like update_all; raise upfront.Kasper Timm Hansen2019-03-061-1/+1
|
* Add insert_all to ActiveRecord models (#35077)Bob Lail2019-03-051-0/+127
Adds a method to ActiveRecord allowing records to be inserted in bulk without instantiating ActiveRecord models. This method supports options for handling uniqueness violations by skipping duplicate records or overwriting them in an UPSERT operation. ActiveRecord already supports bulk-update and bulk-destroy actions that execute SQL UPDATE and DELETE commands directly. It also supports bulk-read actions through `pluck`. It makes sense for it also to support bulk-creation.