aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
Commit message (Collapse)AuthorAgeFilesLines
...
* | Merge pull request #35006 from kddeisz/alias-case-nodesRyuta Kamizono2019-01-222-0/+12
|\ \ | | | | | | Alias case nodes
| * | Alias case nodesKevin Deisz2019-01-212-0/+12
| | | | | | | | | | | | When `Arel` was merged into `ActiveRecord` we lost the ability to alias case nodes. This adds it back.
* | | Fix year value when casting a multiparameter time hashAndrew White2019-01-211-0/+22
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When assigning a hash to a time attribute that's missing a year component (e.g. a `time_select` with `:ignore_date` set to `true`) then the year defaults to 1970 instead of the expected 2000. This results in the attribute changing as a result of the save. Before: event = Event.new(start_time: { 4 => 20, 5 => 30 }) event.start_time # => 1970-01-01 20:30:00 UTC event.save event.reload event.start_time # => 2000-01-01 20:30:00 UTC After: event = Event.new(start_time: { 4 => 20, 5 => 30 }) event.start_time # => 2000-01-01 20:30:00 UTC event.save event.reload event.start_time # => 2000-01-01 20:30:00 UTC
* | Fix type casting column default in `change_column`Ryuta Kamizono2019-01-204-28/+56
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Since #31230, `change_column` is executed as a bulk statement. That caused incorrect type casting column default by looking up the before changed type, not the after changed type. In a bulk statement, we can't use `change_column_default_for_alter` if the statement changes the column type. This fixes the type casting to use the constructed target sql_type. Fixes #34938.
* | Preparing for 6.0.0.beta1 releaseRafael Mendonça França2019-01-182-1/+3
| |
* | activerecord: Fix where nil condition on composed_of attributeDylan Thacker-Smith2019-01-182-4/+23
| |
* | Merge pull request #30000 from ↵Ryuta Kamizono2019-01-1814-37/+72
|\ \ | | | | | | | | | | | | kamipo/all_of_queries_should_return_correct_result All of queries should return correct result even if including large number
| * | Ensure `StatementCache#execute` never raises `RangeError`Ryuta Kamizono2019-01-187-19/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Since 31ffbf8d, finder methods no longer raise `RangeError`. So `StatementCache#execute` is the only place to raise the exception for finder queries. `StatementCache` is used for simple equality queries in the codebase. This means that if `StatementCache#execute` raises `RangeError`, the result could always be regarded as empty. So `StatementCache#execute` just return nil in that range error case, and treat that as empty in the caller side, then we can avoid catching the exception in much places.
| * | All of queries should return correct result even if including large numberRyuta Kamizono2019-01-187-18/+53
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently several queries cannot return correct result due to incorrect `RangeError` handling. First example: ```ruby assert_equal true, Topic.where(id: [1, 9223372036854775808]).exists? assert_equal true, Topic.where.not(id: 9223372036854775808).exists? ``` The first example is obviously to be true, but currently it returns false. Second example: ```ruby assert_equal topics(:first), Topic.where(id: 1..9223372036854775808).find(1) ``` The second example also should return the object, but currently it raises `RecordNotFound`. It can be seen from the examples, the queries including large number assuming empty result is not always correct. Therefore, This change handles `RangeError` to generate executable SQL instead of raising `RangeError` to users to always return correct result. By this change, it is no longer raised `RangeError` to users.
* | | Merge pull request #34969 from eileencodes/fix-error-message-for-multi-db-appsEileen M. Uchitelle2019-01-181-1/+20
|\ \ \ | |/ / |/| | Fix error message when adapter is not specified
| * | Fix error message when adapter is not specifiedEileen Uchitelle2019-01-171-1/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When we added support for multiple databases through a 3-tiered config and configuration objects this error message got a bit convoluted. Previously if you had an application with a missing configuation and multiple databases the error message would look like this: ``` 'doesnexist' database is not configured. Available: development, development, test, test, production, production (ActiveRecord::AdapterNotSpecified) ``` That's not very descriptive since it duplicates the environments (because there are multiple databases per environment for this application). To fix this I've constructed a bit more readable error message which now reads like this if you have a multi db app: ``` The `doesntexist` database is not configured for the `production` environment. (ActiveRecord::AdapterNotSpecified) Available databases configurations are: development: primary, primary_readonly test: primary, primary_readonly production: primary, primary_readonly ``` And like this if you have a single db app: ``` The `doesntexist` database is not configured for the `production` environment. (ActiveRecord::AdapterNotSpecified) Available databases configurations are: development test ``` This makes the error message more readable and presents the user all available options for the database connections.
* | | Use `unboundable?` rather than `boundable?`Ryuta Kamizono2019-01-184-14/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The `unboundable?` behaves like the `infinite?`. ```ruby inf = Topic.predicate_builder.build_bind_attribute(:id, Float::INFINITY) inf.infinite? # => 1 oob = Topic.predicate_builder.build_bind_attribute(:id, 9999999999999999999999999999999) oob.unboundable? # => 1 inf = Topic.predicate_builder.build_bind_attribute(:id, -Float::INFINITY) inf.infinite? # => -1 oob = Topic.predicate_builder.build_bind_attribute(:id, -9999999999999999999999999999999) oob.unboundable? # => -1 ```
* | | Merge pull request #34963 from ↵Rafael França2019-01-172-8/+13
|\ \ \ | | | | | | | | | | | | | | | | dylanahsmith/better-composed-of-single-field-query activerecord: Use a simpler query condition for aggregates with one mapping
| * | | Use public_send instead since respond_to? doesn't include private/protected ↵Ryuta Kamizono2019-01-171-1/+1
| | | | | | | | | | | | | | | | | | | | methods by default Co-Authored-By: dylanahsmith <dylan.smith@shopify.com>
| * | | Avoid using yield_self to make it easier to backportDylan Thacker-Smith2019-01-171-5/+4
| | | |
| * | | activerecord: Use a simpler query condition for aggregates with one mappingDylan Thacker-Smith2019-01-172-8/+14
| |/ /
* | | Merge pull request #34966 from ↵Rafael Mendonça França2019-01-173-4/+14
|\ \ \ | | | | | | | | | | | | | | | | | | | | bogdanvlviv/ensure-ar-relation-exists-allows-permitted-params Ensure that AR::Relation#exists? allows only permitted params
| * | | Ensure that AR::Relation#exists? allows only permitted paramsbogdanvlviv2019-01-173-7/+17
| |/ / | | | | | | | | | | | | Clarify changelog entry Related to #34891
* | | Remove deprecated `#set_state` from the transaction objectRafael Mendonça França2019-01-173-29/+4
| | |
* | | Remove deprecated `#supports_statement_cache?` from the database adaptersRafael Mendonça França2019-01-173-11/+4
| | |
* | | Remove deprecated `#insert_fixtures` from the database adaptersRafael Mendonça França2019-01-175-43/+5
| | |
* | | Remove deprecated ↵Rafael Mendonça França2019-01-173-9/+4
| | | | | | | | | | | | `ActiveRecord::ConnectionAdapters::SQLite3Adapter#valid_alter_table_type?`
* | | Do not allow passing the column name to `sum` when a block is passedRafael Mendonça França2019-01-173-9/+11
| | |
* | | Do not allow passing the column name to `count` when a block is passedRafael Mendonça França2019-01-173-9/+11
| | |
* | | Remove delegation of missing methods in a relation to arelRafael Mendonça França2019-01-173-20/+4
| | |
* | | Remove delegation of missing methods in a relation to private methods of the ↵Rafael Mendonça França2019-01-173-12/+4
| | | | | | | | | | | | class
* | | Change `SQLite3Adapter` to always represent boolean values as integersRafael Mendonça França2019-01-175-63/+33
| | |
* | | Remove ability to specify a timestamp name for `#cache_key`Rafael Mendonça França2019-01-174-31/+10
| | |
* | | Remove deprecated `ActiveRecord::Migrator.migrations_path=`Rafael Mendonça França2019-01-173-17/+4
| | |
* | | Remove deprecated `expand_hash_conditions_for_aggregates`Rafael Mendonça França2019-01-173-46/+7
|/ /
* | Add foreign key to active_storage_attachments for `blob_id` via new migrationbogdanvlviv2019-01-161-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We need this in order to be able to add this migration for users that use ActiveStorage during update their apps from Rails 5.2 to Rails 6.0. Related to #33405 `rake app:update` should update active_storage `rake app:update` should execute `rake active_storage:update` if it is used in the app that is being updated. It will add new active_storage's migrations to users' apps during update Rails. Context https://github.com/rails/rails/pull/33405#discussion_r204239399 Also, see a related discussion in the Campfire: https://3.basecamp.com/3076981/buckets/24956/chats/12416418@1236713081
* | Refs #28025 nullify *_type column on polymorphic associations on :nu… ↵Laerti2019-01-159-4/+63
| | | | | | | | | | | | (#28078) This PR addresses the issue described in #28025. On `dependent: :nullify` strategy only the foreign key of the relation is nullified. However on polymorphic associations the `*_type` column is not nullified leaving the record with a NULL `*_id` but the `*_type` column is present.
* | Remove public `prevent_writes` writerRyuta Kamizono2019-01-151-5/+5
| | | | | | | | | | | | The `@prevent_writes` should be updated only in the `while_preventing_writes`, it is not necessary to expose the attr writer.
* | Deprecate `connection.visitor = ...` which is not released internal usageRyuta Kamizono2019-01-151-2/+6
| | | | | | | | | | | | | | | | | | This attr writer was introduced at 7db90aa, but the usage is already removed at bd2f5c0 before v3.2.0.rc1 is released. If we'd like to customize the visitor in the connection, `arel_visitor` which is implemented in all adapters (mysql2, postgresql, sqlite3, oracle-enhanced, sqlserver) could be used for the purpose #23515.
* | Remove unused `Arel::Compatibility::Wheres`Ryuta Kamizono2019-01-152-36/+0
| | | | | | | | This class is no longer used since 9cbfc8a370bf6537a02a2f21e7246dc21ba4cf1f.
* | Merge pull request #34891 from gmcgibbon/ac_params_existsRafael França2019-01-144-0/+31
|\ \ | | | | | | Allow strong params in ActiveRecord::Base#exists?
| * \ Merge branch 'master' into ac_params_existsAaron Patterson2019-01-1124-96/+111
| |\ \
| * | | Allow strong params in ActiveRecord::Base#exists?Gannon McGibbon2019-01-074-0/+30
| | | | | | | | | | | | | | | | | | | | Allow `ActionController::Params` as argument of `ActiveRecord::Base#exists?`
* | | | More exercise test cases for `not_between`Ryuta Kamizono2019-01-122-31/+84
| |/ / |/| | | | | | | | | | | | | | And support endless ranges for `not_between` like as `between`. Follow up #34906.
* | | Merge pull request #34906 from gregnavis/add-endless-ranges-to-activerecordAaron Patterson2019-01-113-2/+18
|\ \ \ | | | | | | | | Support endless ranges in where
| * | | Support endless ranges in whereGreg Navis2019-01-113-2/+18
| | | | | | | | | | | | | | | | | | | | | | | | This commit adds support for endless ranges, e.g. (1..), that were added in Ruby 2.6. They're functionally equivalent to explicitly specifying Float::INFINITY as the end of the range.
* | | | Remove `id_value` argument which is no longer passed to `sql_for_insert`Ryuta Kamizono2019-01-112-3/+3
| | | | | | | | | | | | | | | | Since #26002, `id_value` is no longer passed to `sql_for_insert`.
* | | | Fix `test_case_insensitiveness` to follow up eb5fef5Ryuta Kamizono2019-01-111-9/+8
| | | |
* | | | Refactor `bind_attribute` to expand an association to actual attributeRyuta Kamizono2019-01-112-5/+5
| | | |
* | | | Refactor `build_relation` in the uniqueness validator to avoid low level ↵Ryuta Kamizono2019-01-113-27/+29
| | | | | | | | | | | | | | | | predicate construction
* | | | Merge pull request #34900 from gmcgibbon/fix_test_find_only_some_columnsEileen M. Uchitelle2019-01-091-2/+11
|\ \ \ \ | |/ / / |/| | | Reset column info on original Topic in serialized attr test
| * | | Reset column info on original Topic in serialized attr testGannon McGibbon2019-01-091-2/+11
| | | | | | | | | | | | | | | | | | | | Call .reset_column_information on ::Topic in serialized attribute test so that attribute methods are safely undefined for all topics.
* | | | Enable `Lint/UselessAssignment` cop to avoid unused variable warnings (#34904)Ryuta Kamizono2019-01-098-12/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Enable `Lint/UselessAssignment` cop to avoid unused variable warnings Since we've addressed the warning "assigned but unused variable" frequently. 370537de05092aeea552146b42042833212a1acc 3040446cece8e7a6d9e29219e636e13f180a1e03 5ed618e192e9788094bd92c51255dda1c4fd0eae 76ebafe594fc23abc3764acc7a3758ca473799e5 And also, I've found the unused args in c1b14ad which raises no warnings by the cop, it shows the value of the cop.
* | | | Revert "Revert "Merge pull request #34387 from ↵Kasper Timm Hansen2019-01-081-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | yhirano55/rails_info_properties_json"" I reverted the wrong commit. Damn it. This reverts commit f66a977fc7ae30d2a07124ad91924c4ee638a703.
* | | | Revert "Merge pull request #34387 from yhirano55/rails_info_properties_json"Kasper Timm Hansen2019-01-081-3/+0
|/ / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We had a discussion on the Core team and we don't want to expose this information as a JSON endpoint and not by default. It doesn't make sense to expose this JSON locally and this controller is only accessible in dev, so the proposed access from a production app seems off. This reverts commit 8eaffe7e89719ac62ff29c2e4208cfbeb1cd1c38, reversing changes made to b6e4305c3bca4c673996d0af9db0f4cfbf50215e.