aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record
Commit message (Collapse)AuthorAgeFilesLines
* Merge pull request #30073 from yalab/fixture_binary_helperRafael França2017-08-141-0/+4
|\ | | | | Add `binary` helper method to fixtures.
| * Add `binary` helper method to fixtures.yalab2017-08-121-0/+4
| |
* | Merge pull request #30208 from kamipo/extract_primary_key_to_abstract_reflectionRafael França2017-08-141-8/+4
|\ \ | | | | | | Extract `primary_key` to `AbstractReflection`
| * | Extract `primary_key` to `AbstractReflection`Ryuta Kamizono2017-08-121-8/+4
| | |
* | | Merge pull request #27609 from kamipo/fix_association_primary_keyRafael França2017-08-142-4/+11
|\ \ \ | | | | | | | | Fix `reflection.association_primary_key` for `has_many` association
| * | | Fix `reflection.association_primary_key` for `has_many` associationsRyuta Kamizono2017-08-132-4/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It is incorrect to treat `options[:primary_key]` as `association_primary_key` if `has_many` associations because the `:primary_key` means the column on the owner record, not on the association record. It will break `ids_reader` and `ids_writer`. ```ruby people(:david).essay_ids # => ActiveRecord::StatementInvalid: Mysql2::Error: Unknown column 'essays.first_name' in 'field list': SELECT `essays`.first_name FROM `essays` WHERE `essays`.`writer_id` = 'David' ``` Fixes #14439.
* | | | Merge pull request #30229 from kamipo/allow_serialize_with_custom_coderRafael França2017-08-141-7/+4
|\ \ \ \ | | | | | | | | | | Allow `serialize` with a custom coder on `json` and `array` columns
| * | | | Allow `serialize` with a custom coder on `json` and `array` columnsRyuta Kamizono2017-08-131-7/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We already have a test case for `serialize` with a custom coder in `PostgresqlHstoreTest`. https://github.com/rails/rails/blob/v5.1.3/activerecord/test/cases/adapters/postgresql/hstore_test.rb#L316-L335
* | | | | Merge pull request #30214 from kirs/uniqueness-scope-validatorRafael França2017-08-141-0/+4
|\ \ \ \ \ | | | | | | | | | | | | Check :scope input in Uniqueness validator
| * | | | | Check :scope input in Uniqueness validatorKir Shatrov2017-08-131-0/+4
| | |_|/ / | |/| | |
* | | | | Merge pull request #30236 from padi/find-each-example-updateRafael França2017-08-141-1/+6
|\ \ \ \ \ | | | | | | | | | | | | Completes ActiveRecord::Batches.find_each example [ci skip]
| * | | | | Completes ActiveRecord::Batches.find_each example [ci skip]Marc Rendl Ignacio2017-08-131-1/+6
| | |_|/ / | |/| | | | | | | | | | | | | | | | | | The previous paragraph mentions that you can hand off the same processing queue to multiple workers. This completes the following example below it.
* | | | | Merge pull request #30231 from kamipo/remove_unused_source_type_infoRafael França2017-08-141-10/+7
|\ \ \ \ \ | | | | | | | | | | | | Remove unused `source_type_info` in `RuntimeReflection`
| * | | | | Remove unused `source_type_info` in `RuntimeReflection`Ryuta Kamizono2017-08-131-10/+7
| | |_|/ / | |/| | | | | | | | | | | | | | | | | | `source_type_info` is only used for `constraints` in `PolymorphicReflection`.
* / | | | Remove duplicated `join_id_for`Ryuta Kamizono2017-08-131-10/+2
|/ / / / | | | | | | | | | | | | The primary key on the owner record is abstracted as `join_foreign_key`.
* / / / Delegate to `Enumerable#find` for `CollectionProxy`Ryuta Kamizono2017-08-132-17/+14
|/ / / | | | | | | | | | | | | Since `Relation` includes `Enumerable`, it is enough to use `super` simply.
* / / Remove duplicated `table_name`Ryuta Kamizono2017-08-121-8/+0
|/ / | | | | | | It can use `AbstractReflection#table_name` simply.
* | Fix outdated comment for `Core::ClassMethods#===` [ci skip] (#30146)Ryuta Kamizono2017-08-121-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | This comment was added at 97849de, but `AssociationProxy` and `test_triple_equality` was removed at 1644663. Currently the `===` is used for `test_decorated_polymorphic_where` that added at #11945. So I updated "association proxies" to "decorated models". And also, currently `Core::ClassMethods` appears in the doc. http://api.rubyonrails.org/classes/ActiveRecord/Core/ClassMethods.html But it looks like that the methods in the module is not public API. So I also added `# :nodoc:` to the module.
* | Merge pull request #30126 from ↵Rafael França2017-08-113-12/+12
|\ \ | | | | | | | | | | | | chopraanmol1/support_for_has_many_and_has_one_for_where_relation Fixed query building when relation is passed for has one or has many association in where
| * | Changed join_fk private method to join_foreign_key public methodchopraanmol12017-08-093-15/+11
| | |
| * | Currently if relation object are passed to where condition for has one or ↵chopraanmol12017-08-082-3/+7
| | | | | | | | | | | | | | | | | | has many association wrong set of primary key and foreign key are selected. Changed code to use 'join' primary key and foreign key over 'association' primary key and foreign key.
* | | Merge pull request #30159 from allcentury/dump-temp-file-permissionsRafael França2017-08-111-1/+1
|\ \ \ | | | | | | | | Use copy to preserve file permissions
| * | | Use copy to preserve file permissionsAnthony Ross2017-08-091-1/+1
| | | |
* | | | Merge pull request #29720 from gaurish/ar_find_error_message_improvementRafael França2017-08-112-4/+6
|\ \ \ \ | | | | | | | | | | Return Not found Ids in ActiveRecord::NotFound
| * | | | Return Not found Ids in ActiveRecord::NotFoundGaurish Sharma2017-07-292-4/+6
| | | | | | | | | | | | | | | | | | | | | | | | | This builds on top of 15e2da656f41af0124f7577858536f3b65462ad5. now it also returns exact Ids which were not found which will be debugging simple.
* | | | | Merge pull request #30193 from zverok/robust-postgres-duplicate-dbRafael França2017-08-111-1/+1
|\ \ \ \ \ | | | | | | | | | | | | More robust PostgreSQL database duplication check
| * | | | | Update database duplication checkzverok2017-08-111-1/+1
| | | | | |
* | | | | | Specify `table.name` only when `scope.table` and `table` are different (#29058)Ryuta Kamizono2017-08-111-4/+12
| | | | | | | | | | | | | | | | | | Fixes #29045.
* | | | | | Fix RDoc formatting: `+` doesn't work with `@`ohbarye2017-08-112-6/+6
|/ / / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | refs: https://github.com/rails/rails/pull/30161 ``` $ echo "+@size+" | rdoc --pipe <p>+@size+</p> $ echo "<tt>@size</tt>" | rdoc --pipe <p><code>@size</code></p> ``` [ci skip]
* | | | | Start `@reaper.run` after connection pool initializedRyuta Kamizono2017-08-111-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Otherwise `ConnectionPool#reap` may run before `@connections` has initialized. https://travis-ci.org/rails/rails/jobs/263037427#L888-L890
* | | | | Merge pull request #30108 from yui-knk/require_concurrent_mapRafael França2017-08-081-0/+2
|\ \ \ \ \ | | | | | | | | | | | | Add missed `require`
| * | | | | Add missed `require`yui-knk2017-08-071-0/+2
| | |_|/ / | |/| | | | | | | | | | | | | | | | | | `ActiveRecord::ConnectionAdapters::QueryCache::ConnectionPoolConfiguration` depends on `Concurrent::Map`.
* | | | | Merge pull request #30142 from ↵Sean Griffin2017-08-081-4/+12
|\ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | yukideluxe/add-missing-bit-reload-associations-docs add missing collection.reload documentation [ci skip]
| * | | | | add missing collection.reload documentation [ci skip]Julia López2017-08-081-4/+12
| | | | | |
* | | | | | Document `ActiveRecord::AttributeMethods::Dirty`Sean Griffin2017-08-081-9/+9
|/ / / / / | | | | | | | | | | | | | | | | | | | | This module has behavior that is not present in `ActiveModel::Dirty`, which is intended to be public API.
* | | | | Merge pull request #30125 from yukideluxe/add-reload-to-associations-docsRafael França2017-08-081-0/+8
|\ \ \ \ \ | |_|_|/ / |/| | | | add reload_association to documentation
| * | | | add reload_association to documentation [ci skip]Julia López2017-08-071-0/+8
| |/ / /
* / / / [ci skip] Postgres --> PostgreSQLRyuta Kamizono2017-08-083-3/+3
|/ / /
* | | Merge pull request #29520 from kirs/serialize-vs-postgres-native-columnSean Griffin2017-08-041-0/+24
|\ \ \ | | | | | | | | Do not let use `serialize` on native JSON/array column
| * | | Do not let use `serialize` on native JSON/array columnKir Shatrov2017-08-041-0/+24
| |/ /
* | / Use `Concurrent::Map` than `Mutex` and `Mutex_m` for statement cachesRyuta Kamizono2017-08-042-10/+6
| |/ |/| | | | | | | Statement caches are used as a concurrent map. It will more clarify to using `Concurrent::Map`.
* | Fix all rubocop violationsRafael Mendonça França2017-08-031-2/+2
| |
* | Passing `klass` to `StatementCache.new`Ryuta Kamizono2017-08-045-24/+23
| | | | | | | | | | | | Actually `StatementCache#execute` is always passed the same klass that the owner klass of the connection when the statement cache is created. So passing `klass` to `StatementCache.new` will make more DRY.
* | Merge pull request #29914 from ↵Matthew Draper2017-08-022-19/+22
|\ \ | | | | | | | | | | | | kamipo/relation_merger_should_not_fill_empty_values `Relation::Merger` should not fill `values` with empty values
| * | `get_value` and `set_value` in `Relation` are no longer used externallyRyuta Kamizono2017-07-251-9/+10
| | |
| * | `Relation::Merger` should not fill `values` with empty valuesRyuta Kamizono2017-07-251-10/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | Currently `Relation#merge` will almost fill `values` with empty values (e.g. `other.order_values` is always true, it should be `other.order_values.any?`). This means that `Relation#merge` always changes `values` even if actually `values` is nothing changed. This behavior will makes `Relation#empty_scope?` fragile. So `Relation#merge` should avoid unnecessary changes.
* | | Merge pull request #29842 from kamipo/fix_find_by_with_rangeMatthew Draper2017-08-022-4/+8
|\ \ \ | | | | | | | | Fix `find_by` with range conditions
| * | | Fix `find_by` with range conditionsRyuta Kamizono2017-07-202-4/+8
| | | | | | | | | | | | | | | | | | | | `StatementCache` doesn't support range conditions. So we need to through the args to `FinderMethods#find_by` if range value is passed.
* | | | Merge pull request #29724 from eugeneius/sync_primary_keyMatthew Draper2017-08-023-2/+8
|\ \ \ \ | | | | | | | | | | Sync transaction state when accessing primary key
| * | | | Sync transaction state when accessing primary keyEugene Kenny2017-07-093-2/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If a record is modified inside a transaction, it must check the outcome of that transaction before accessing any state which would no longer be valid if it was rolled back. For example, consider a new record that was saved inside a transaction which was later rolled back: it should be restored to its previous state so that saving it again inserts a new row into the database instead of trying to update a row that no longer exists. The `id` and `id=` methods defined on the PrimaryKey module implement this correctly, but when a model uses a custom primary key, the reader and writer methods for that attribute must check the transaction state too. The `read_attribute` and `write_attribute` methods also need to check the transaction state when accessing the primary key.