aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/locking
Commit message (Collapse)AuthorAgeFilesLines
* Rase when calling `lock!` in a dirty recordRafael Mendonça França2017-10-231-4/+5
|
* Update links to use https instead of http [ci skip]Yoshiyuki Hirano2017-08-221-1/+1
|
* Change http postgresql.org links to https [ci skip]yuuji.yaginuma2017-07-301-1/+1
| | | | | It seems that it accepts only HTTPS connections. Ref: https://github.com/postgres/postgres/commit/7f77cbd996855a06fb742ea11adbe55c42b48fe2
* Use frozen-string-literal in ActiveRecordKir Shatrov2017-07-192-0/+4
|
* Revert "Merge pull request #29540 from kirs/rubocop-frozen-string"Matthew Draper2017-07-022-2/+0
| | | | | This reverts commit 3420a14590c0e6915d8b6c242887f74adb4120f9, reversing changes made to afb66a5a598ce4ac74ad84b125a5abf046dcf5aa.
* Enforce frozen string in RubocopKir Shatrov2017-07-012-0/+2
|
* Fix destroy with locking_column value nullbogdanvlviv2017-06-201-1/+1
| | | | | | | Fix destroying existing object does not work well when optimistic locking enabled and `locking column` is null in the database. Follow 22a822e5813ef7ea9ab6dbbb670a363899a083af, #28914
* Clean up 'Optimistic Locking' implementationbogdanvlviv2017-06-121-3/+4
|
* Add option for class_attribute default (#29270)David Heinemeier Hansson2017-05-291-2/+1
| | | | | | | | | | | | * Allow a default value to be declared for class_attribute * Convert to using class_attribute default rather than explicit setter * Removed instance_accessor option by mistake * False is a valid default value * Documentation
* Remove ability update locking_column valuebogdanvlviv2017-03-161-6/+2
|
* Deprecate locking of dirty recordsMarc Schütz2017-02-071-1/+10
|
* No need to nodoc private methodsAkira Matsuda2016-12-241-2/+2
|
* Small grammar fix for #26867Jon Moss2016-10-231-1/+2
| | | | [ci skip]
* Add info about updating locking column valuebogdanvlviv2016-10-231-0/+1
| | | | | [ci skip] Follow #26050
* Added ability update locking_column valuebogdanvlviv2016-10-211-6/+8
|
* Fixed: Optimistic locking does not work well with null in the databasebogdanvlviv2016-10-211-4/+6
|
* Fix broken comments indentation caused by rubocop auto-correct [ci skip]Ryuta Kamizono2016-09-141-4/+4
| | | | | | All indentation was normalized by rubocop auto-correct at 80e66cc4d90bf8c15d1a5f6e3152e90147f00772. But comments was still kept absolute position. This commit aligns comments with method definitions for consistency.
* Add `Style/EmptyLines` in `.rubocop.yml` and remove extra empty linesRyuta Kamizono2016-08-071-1/+0
|
* normalizes indentation and whitespace across the projectXavier Noria2016-08-061-43/+43
|
* modernizes hash syntax in activerecordXavier Noria2016-08-061-1/+1
|
* applies new string literal convention in activerecord/libXavier Noria2016-08-061-5/+5
| | | | | The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.
* 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]
* schema_load triggers 2nd schema_load (via locking)Keenan Brock2016-04-281-1/+1
| | | | | | | | | | | | | | Currently, loading the schema (schema_load) accesses the locking column (locking_column) which defaults the value (reset_locking_column) which invalidates the schema (reload_schema_from_cache) which forces another schema load. Good news: The second schema_load does accesses locking_column, but locking_column is set, so it does not reset_locking_column and it does not trigger an infinite loop. The solution is not invalidate the cache while default locking_column
* Followup of #15771Vipul A M2016-04-241-0/+4
| | | | | | | | | Make sure we handle explicitly passed nil's to lock_version as well. An explicitly passed nil value is now converted to 0 on LockingType, so that we don't end up with ActiveRecord::StaleObjectError in update record optimistic locking Fixes #24695
* Fix ActiveRecord::Locking doc [ci skip]Mehmet Emin İNAÇ2015-09-241-2/+2
|
* Updated MySQL documentation link to MySQL latest version 5.7 everywhere [ci ↵amitkumarsuroliya2015-09-101-1/+1
| | | | | skip] Bumps from `5.6` to `5.7`
* Update old link in pessimistic.rb commentsAlexander Leishman2015-03-181-1/+1
| | | Update link in comments to point to latest MySQL production version documentation. See here for reference: http://dev.mysql.com/doc/refman/5.0/en/choosing-version.html
* Call `attributes_for_update` in `_update_record` w/ optimistic lockingSean Griffin2015-02-241-1/+1
| | | | Fixes #19057
* `Type#type_cast_from_database` -> `Type#deserialize`Sean Griffin2015-02-171-1/+1
|
* Change `LockingType` to use `DelegateClass`Sean Griffin2015-02-091-1/+1
| | | | Significantly faster than `SimpleDelegator`.
* Attribute assignment and type casting has nothing to do with columnsSean Griffin2015-01-311-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It's finally finished!!!!!!! The reason the Attributes API was kept private in 4.2 was due to some publicly visible implementation details. It was previously implemented by overloading `columns` and `columns_hash`, to make them return column objects which were modified with the attribute information. This meant that those methods LIED! We didn't change the database schema. We changed the attribute information on the class. That is wrong! It should be the other way around, where schema loading just calls the attributes API for you. And now it does! Yes, this means that there is nothing that happens in automatic schema loading that you couldn't manually do yourself. (There's still some funky cases where we hit the connection adapter that I need to handle, before we can turn off automatic schema detection entirely.) There were a few weird test failures caused by this that had to be fixed. The main source came from the fact that the attribute methods are now defined in terms of `attribute_names`, which has a clause like `return [] unless table_exists?`. I don't *think* this is an issue, since the only place this caused failures were in a fake adapter which didn't override `table_exists?`. Additionally, there were a few cases where tests were failing because a migration was run, but the model was not reloaded. I'm not sure why these started failing from this change, I might need to clear an additional cache in `reload_schema_from_cache`. Again, since this is not normal usage, and it's expected that `reset_column_information` will be called after the table is modified, I don't think it's a problem. Still, test failures that were unrelated to the change are worrying, and I need to dig into them further. Finally, I spent a lot of time debugging issues with the mutex used in `define_attribute_methods`. I think we can just remove that method entirely, and define the attribute methods *manually* in the call to `define_attribute`, which would simplify the code *tremendously*. Ok. now to make this damn thing public, and work on moving it up to Active Model.
* Go through normal where logic in destroy with lockingSean Griffin2015-01-141-6/+2
| | | | | | Building the Arel AST, and manipulating the relation manually like this is prone to errors and breakage as implementation details change from underneath it.
* Properly persist `lock_version` as 0 if the DB has no defaultSean Griffin2015-01-091-5/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | The reason this bug occured is that we never actually check to see if this column has changed from it's default, since it was never assigned and is not mutable. It appears I was wrong in b301c40224c6d15b539dbcc7485adb44d810f88c, with my statement of "there is no longer a case where a given value would differ from the default, but would not already be marked as changed." However, I chose not to revert the deletion of `initialize_internals_callback` from that commit, as I think a solution closer to where the problem lies is less likely to get erroneously removed. I'm not super happy with this solution, but it mirrors what is being done in `_update_record`, and a fix for one should work for the other. I toyed with the idea of changing the definition of `changed?` on the type to `changed_in_place?`. If we type cast the raw value, it'll break a test about updating not modifying the lock column if nothing else was changed. We could have the definition check if `raw_old_value` is `nil`, but this feels fragile and less intention revealing. It would, however, have the benefit of cleaning up old data that incorrectly persisted as `nil`. Fixes #18422
* Tiny documentation fixes [ci skip]Robin Dupret2014-12-301-1/+1
|
* Go through normal `update_all` logic when updating lock columnsSean Griffin2014-12-261-17/+7
|
* We don't need additional type casting for locking updatesSean Griffin2014-12-261-3/+11
| | | | | | | Part of the larger refactoring to remove type casting from Arel. We can inform it that we already have the right type by wrapping the value in an `Arel::Nodes::Quoted`. This commit can be reverted when we have removed type casting from Arel in Rail 5.1
* Remove the unused second argument to `substitute_at`Sean Griffin2014-11-171-1/+1
| | | | Oh hey, we got to remove some code because of that!
* Stop using instance exec for type decoratorsSean Griffin & Sean Doyle2014-06-271-5/+16
| | | | | | | | We are moving this behavior out to an object that we would like to keep separated from `ActiveRecord::Base`, which means not passing the class object to it. As such, we need to stop using `instance_exec`, and instead close over the subclass on global type decorators that are applied in `Base`.
* add missing `:nodoc:` for recent refactorings. [ci skip]Yves Senn2014-06-241-1/+1
| | | | | | | | | | Adding `# :nodoc:` to the parent `class` / `module` is not going to ignore nested classes or modules. There is a modifier `# :nodoc: all` but sadly the containing class or module will continue to be in the docs. /cc @sgrif
* Don't mess with `column_defaults` when optimistic locking is enabledSean Griffin2014-06-171-10/+23
|
* Remove deprecated method ActiveRecord::Base.quoted_locking_columnAkshay Vishnoi2014-06-101-6/+0
|
* Remove duplicated `@raw_attributes.keys`Sean Griffin2014-06-071-1/+1
| | | | | Reduces the number of things outside of attribute methods that cares about the details of how we store and type cast attributes
* Rename attribute related instance variables to better express intentSean Griffin2014-05-301-1/+1
| | | | | | | | | `@attributes` was actually used for `_before_type_cast` and friends, while `@attributes_cache` is the type cast version (and caching is the wrong word there, but I'm working on removing the conditionals around that). I opted for `@raw_attributes`, because `_before_type_cast` is also semantically misleading. The values in said hash are in the state given by the form builder or database, so raw seemed to be a good word.
* [Active Record] Renamed private methods create_record and update_recordPrathamesh Sonpatki2014-02-201-1/+1
| | | | | | This is to ensure that they are not accidentally called by the app code. They are renamed to _create_record and _update_record respectively. Closes #11645
* pass the pk to compile_updateAaron Patterson2013-11-161-1/+4
|
* [ci skip] avoid deprecation warning in sample codesue4452013-10-181-3/+3
| | | | | Account.find(1, lock: true) -> DEPRECATION WARNING: Passing options to #find is deprecated. Please build a scope and then call #find on it.
* Deprecate unused quoted_locking_column method.kennyj2013-09-241-0/+1
|
* Tidy up the "Specified column type for quote_value" changesBen Woosley2013-07-221-1/+1
| | | | | | This includes fixing typos in changelog, removing a deprecated mocha/setup test require, and preferring the `column_for_attribute` accessor over direct access to the columns_hash in the new code.
* Specified column type for quote_valueAlfred Wong2013-07-221-1/+1
| | | | | | | | | | | | | | | | | | | | | When calling quote_value the underlying connection sometimes requires more information about the column to properly return the correct quoted value. I ran into this issue when using optimistic locking in JRuby and the activerecord-jdbcmssql-adapter. In SQLSever 2000, we aren't allowed to insert a integer into a NVARCHAR column type so we need to format it as N'3' if we want to insert into the NVARCHAR type. Unfortuantely, without the column type being passed the connection adapter cannot properly return the correct quote value because it doesn't know to return N'3' or '3'. This patch is fairly straight forward where it just passes in the column type into the quote_value, as it already has the ability to take in the column, so it can properly handle at the connection level. I've added the tests required to make sure that the quote_value method is being passed the column type so that the underlying connection can determine how to quote the value.
* Reset @column_defaults when assigning .kennyj2013-07-141-0/+1
|