aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/insert_all.rb
Commit message (Collapse)AuthorAgeFilesLines
* Avoid new string instance creation in `InsertAll#execute`Ryuta Kamizono2019-04-221-3/+3
|
* There is no need to create `QueryAttribute` to just type cast a valueRyuta Kamizono2019-04-101-2/+1
|
* Merge pull request #35892 from ryohashimoto/bulk_insert_logsEileen M. Uchitelle2019-04-081-1/+4
|\ | | | | Improve log messages for #insert_all` / `#upsert_all` etc. methods
| * Improve log messages for #insert_all` / `#upsert_all` / `#insert` / `#upsert ↵Ryo Hashimoto2019-04-081-1/+4
| | | | | | | | | | | | | | | | 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-2/+2
|/ | | | | | | | | | | 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.
* Use accessors internally; remove needless validationKasper Timm Hansen2019-03-311-6/+2
|
* Mark InsertAll as private API. Easier to add later.Kasper Timm Hansen2019-03-311-1/+1
|
* Capture some join calls.Kasper Timm Hansen2019-03-311-4/+8
|
* Bulk Insert: Reuse indexes for unique_byKasper Timm Hansen2019-03-201-20/+31
| | | | | | | | | | | 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.
* Simplify values_list with more compositionKasper Timm Hansen2019-03-181-24/+30
| | | | This also prevents insert_all from leaking its attributes checks.
* Extract column check in values_listKasper Timm Hansen2019-03-181-14/+14
| | | | | | `values_list` is quite long and does far too many things. This also eagerly extract the keys in initialize instead of having to worry about calling them multiple times.
* Raise UnknownAttributeError when unknown column is passed to insert_all and ↵Josef Šimánek2019-03-161-0/+8
| | | | friends.
* Add some whitespace for readability.Kasper Timm Hansen2019-03-061-0/+2
|
* Handle blank inserts like update_all; raise upfront.Kasper Timm Hansen2019-03-061-6/+4
|
* Add insert_all to ActiveRecord models (#35077)Bob Lail2019-03-051-0/+153
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.