aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
Commit message (Collapse)AuthorAgeFilesLines
...
| * | | | | | | Keep state around for nested calls to #suppressJahfer Husain2016-05-162-1/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If a call to #suppress from the same class occurred inside another #suppress block, the suppression state would be set to false before the outer block completes. This change keeps the previous state around in memory and unwinds it as the blocks exit.
* | | | | | | | Merge pull request #23810 from xijo/fix_json_coder_when_mysql_strict_is_disabledSean Griffin2016-05-163-1/+20
|\ \ \ \ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | Fix bug in JSON deserialization when column default is an empty string
| * | | | | | | | Fix bug in JSON deserialization when column default is an empty stringJohannes Opper2016-02-223-1/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When `ActiveRecord::Coders::JSON` serialization is used and the default of the column returns `''` it raises the following error: ``` JSON::ParserError: A JSON text must at least contain two octets! ``` If MySQL is running in non-strict mode, it returns an empty string as column default for a text column: ```ruby def extract_default if blob_or_text_column? @default = null || strict ? nil : '' end end ``` Since `''` is invalid JSON, there shouldn't be an attempt to parse it, it should be treated like nil. ActiveRecord::Coders::JSON should behave consistently for all possible non-user-set column default values.
* | | | | | | | | Rails 5.1 point type should not raise exception if empty string is provided ↵bUg2016-05-152-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | as value
* | | | | | | | | Merge branch 'master' of github.com:rails/docrailsVijay Dev2016-05-141-1/+4
|\ \ \ \ \ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: guides/source/configuring.md
| * | | | | | | | | Move comment up to the class, for both of the methods, and document on class ↵Vipul A M2016-05-011-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | level why we are doing this. [ci skip]
* | | | | | | | | | Add missing space and newline for clarityKang-Kyu Lee2016-05-121-3/+3
| |_|/ / / / / / / |/| | | | | | | |
* | | | | | | | | Give more context from `AssociationMismatchError`Sean Griffin2016-05-122-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The error message that we give today makes this error difficult to debug if you receive it. I have no clue why we're printing the object ID of the class (the commit doesn't give context), but I've left it as it was deliberate.
* | | | | | | | | Rename test methodMolchanov Andrey2016-05-121-1/+1
| | | | | | | | |
* | | | | | | | | Fix false positive mutation detection when JSON is used with serializeSean Griffin2016-05-122-1/+40
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When looking for mutation, we compare the serialized version of the value to the before_type_cast form. `Type::Serialized` was breaking this contract by passing the already serialized attribute to the subtype's mutation detection. This never manifested previously, as all mutable subtypes either didn't do anything in their `serialize` method, or had a way to detect double serialization (e.g. `is_a?(String)`). However, now that JSON types can handle string primitives, we need to avoid double serialization. Fixes #24993.
* | | | | | | | | Merge pull request #24980 from merhard/virtual-attribute-defaultSean Griffin2016-05-112-1/+10
|\ \ \ \ \ \ \ \ \ | |_|_|_|/ / / / / |/| | | | | | | | Define ActiveRecord::Attribute::Null#type_cast
| * | | | | | | | Define ActiveRecord::Attribute::Null#type_castMatthew Erhard2016-05-112-1/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Using ActiveRecord::Base.attribute to declare an attribute with a default value on a model where the attribute is not backed by the database would raise a NotImplementedError when model.save is called. The error originates from https://github.com/rails/rails/blob/59d252196b36f6afaafd231756d69ea21537cf5d/activerecord/lib/active_record/attribute.rb#L84. This is called from https://github.com/rails/rails/blob/59d252196b36f6afaafd231756d69ea21537cf5d/activerecord/lib/active_record/attribute.rb#L46 on an ActiveRecord::Attribute::Null object. This commit corrects the behavior by implementing ActiveRecord::Attribute::Null#type_cast. With ActiveRecord::Attribute::Null#type_cast defined, ActiveRecord::Attribute::Null#value (https://github.com/rails/rails/blob/59d252196b36f6afaafd231756d69ea21537cf5d/activerecord/lib/active_record/attribute.rb#L173..L175) can be replaced with its super method (https://github.com/rails/rails/blob/59d252196b36f6afaafd231756d69ea21537cf5d/activerecord/lib/active_record/attribute.rb#L36..L40). fixes #24979
* | | | | | | | | remove_connection should not remove parent connectionArthur Neves2016-05-112-1/+9
|/ / / / / / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When calling remove_connection in a subclass, that should not fallback to the parent, otherwise it will remove the parent connection from the handler.
* | | | | | | | Merge pull request #24971 from arthurnn/arthurnn/dont_cache_specification_nameArthur Nogueira Neves2016-05-112-2/+11
|\ \ \ \ \ \ \ \ | | | | | | | | | | | | | | | | | | Dont cache the conn_spec_name when empty
| * | | | | | | | Dont cache the conn_spec_name when emptyArthur Neves2016-05-112-2/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We cannot cache the connection_specification_name when it doesnt exist. Thats because the parent value could change, and we should keep failling back to the parent. If we cache that in a children as an ivar, we would not fallback anymore in the next call, so the children would not get the new parent spec_name.
* | | | | | | | | Set conn_spec_name after removeArthur Neves2016-05-111-2/+2
|/ / / / / / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `remove_connection` can reset the `connection_specification_name`, so we need to to set it after the remove_connection call on `establish_connection` method.
* | | | | | | | [ci skip] Update documents of `ConnectionHandler`yui-knk2016-05-111-3/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Follow up of #24844. The key of `@owner_to_pool` was changed from `klass.name` to `spec.name`. By this change "memory leaks in development mode" will not happen, bacause the equality of string is not changed by reloading of model files.
* | | | | | | | Make sure we reset the connection_specification_name onArthur Neves2016-05-102-1/+22
| |_|_|/ / / / |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | remove_connection When calling `remove_connection` on a model, we delete the pool so we also need to reset the `connection_specification_name` so it will fallback to the parent. This was the current behavior before rails 5, which will fallback to the parent connection pool. [fixes #24959] Special thanks to @jrafanie for working with me on this fix.
* | | | | | | Merge pull request #24950 from kamipo/should_quote_lock_nameRafael França2016-05-102-5/+5
|\ \ \ \ \ \ \ | | | | | | | | | | | | | | | | Should quote `lock_name` to pass to `get_advisory_lock`
| * | | | | | | Should quote `lock_name` to pass to `get_advisory_lock`Ryuta Kamizono2016-05-102-5/+5
| | | | | | | |
* | | | | | | | Merge pull request #24939 from Neodelf/again_with_loopXavier Noria2016-05-101-2/+1
|\ \ \ \ \ \ \ \ | |/ / / / / / / |/| | | | | | | Replacement cycle for readability
| * | | | | | | Replacement cycle for readabilityMolchanov Andrey2016-05-101-2/+1
| | | | | | | |
* | | | | | | | Add migration compatibility class for Rails 5.1Rafael Mendonça França2016-05-101-1/+4
| | | | | | | |
* | | | | | | | Start Rails 5.1 development :tada:Rafael Mendonça França2016-05-102-2116/+3
|/ / / / / / /
* | | | | | | Replacement cycle for readabilityMolchanov Andrey2016-05-091-2/+2
| | | | | | |
* | | | | | | Followup to #24844Jon Moss2016-05-072-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Some slight documentation edits and fixes. Also, run remove unnecessary `RuntimeError`. r? @arthurnn
* | | | | | | Preparing for 5.0.0.rc1 releaseRafael Mendonça França2016-05-062-1/+6
| |_|_|_|/ / |/| | | | |
* | | | | | Merge pull request #24844 from arthurnn/arthurnn/connArthur Nogueira Neves2016-05-0611-92/+109
|\ \ \ \ \ \ | | | | | | | | | | | | | | Refactor connection handler
| * | | | | | Update docs for connection handlerArthur Neves2016-05-061-2/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | [skip ci]
| * | | | | | s/specification_name/connection_specification_nameArthur Neves2016-05-064-14/+14
| | | | | | |
| * | | | | | s/specification_id/specification_nameArthur Neves2016-05-058-48/+48
| | | | | | |
| * | | | | | Retrive the right pool for db tasksArthur Neves2016-05-051-2/+2
| | | | | | |
| * | | | | | inline retrive_conn_pool methodArthur Neves2016-05-051-12/+8
| | | | | | |
| * | | | | | Better code readabilityArthur Neves2016-05-052-4/+2
| | | | | | |
| * | | | | | Test to swap connection at runtimeArthur Neves2016-05-051-0/+7
| | | | | | |
| * | | | | | fix testArthur Neves2016-05-051-8/+7
| | | | | | |
| * | | | | | Add spec_id testsArthur Neves2016-05-051-0/+9
| | | | | | |
| * | | | | | Use spec key, when given as spec_idArthur Neves2016-05-052-20/+23
| | | | | | |
| * | | | | | Better specification_id methodArthur Neves2016-05-051-10/+7
| | | | | | |
| * | | | | | Rename methodArthur Neves2016-05-051-3/+3
| | | | | | |
| * | | | | | Refactor connection handlerArthur Neves2016-05-059-83/+88
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ConnectionHandler will not have any knowlodge of AR models now, it will only know about the specs. Like that we can decouple the two, and allow the same model to use more than one connection. Historically, folks used to create abstract AR classes on the fly in order to have multiple connections for the same model, and override the connection methods. With this, now we can override the `specificiation_id` method in the model, to return a key, that will be used to find the connection_pool from the handler.
* | | | | | | Merge pull request #24871 from vipulnsward/disable-transaction-failureArthur Nogueira Neves2016-05-061-0/+2
|\ \ \ \ \ \ \ | | | | | | | | | | | | | | | | Fix failures due to transactions
| * | | | | | | We are erroring due to nested transaction failures from mysql on ↵Vipul A M2016-05-061-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | test_migrate_clears_schema_cache_afterward test. Disable transactions for this test. Fixes #24391
* | | | | | | | Allow the connection adapters to determine the order of bind paramsSean Griffin2016-05-063-4/+46
|/ / / / / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In 5.0 we use bind parameters for limit and offset, while in 4.2 we used the values directly. The code as it was written assumed that limit and offset worked as `LIMIT ? OFFSET ?`. Both Oracle and SQL Server have a different syntax, where the offset is stated before the limit. We delegate this behavior to the connection adapter so that these adapters are able to determine how the bind parameters are flattened based on what order their specification has the various clauses appear. Fixes #24775
* | | | | | | Merge pull request #24869 from vipulnsward/change-exampleRafael França2016-05-051-3/+3
|\ \ \ \ \ \ \ | | | | | | | | | | | | | | | | Change to use a more realistic example [ci skip]
| * | | | | | | Change to use a more realistic example and not giving the impression that ↵Vipul A M2016-05-051-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | destroy_all is preferred way to destroy related records. This example just wants to demonstrate callback behaviour. [ci skip]
* | | | | | | | Merge pull request #24868 from vipulnsward/delegate_encode_withRafael França2016-05-051-1/+1
|\ \ \ \ \ \ \ \ | |/ / / / / / / |/| | | | | | | delegate encode_with instead of to_yaml, which is deprecated
| * | | | | | | delegate encode_with instead of to_yaml, which is deprecatedVipul A M2016-05-051-1/+1
| | | | | | | |
* | | | | | | | [ci skip] Don't promote SQL interpolation.Kasper Timm Hansen2016-05-051-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | After fb898e9, the `before_destroy` had some code that used SQL interpolation left over. Don't think we should promote that even if the values aren't directly from user input.
* | | | | | | | Merge pull request #24859 from y-yagi/do_not_pass_conditon_to_destroy_allVipul A M2016-05-052-3/+3
|\ \ \ \ \ \ \ \ | |_|/ / / / / / |/| | | | | | | do not pass conditions to `#destroy_all` [ci skip]