aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
Commit message (Collapse)AuthorAgeFilesLines
...
| * | | | | | Fixed a regression introduced in 84cf156Godfrey Chan2014-06-141-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 84cf156 (PR #15694) introduced a subtle regression. There are actually three distinct entry points to creating an AR object – via .new (i.e. #initialize), via #init_with (e.g. from YAML or database queries) and via .allocate. With the patch in 84cf156, attribute methods and respond_to? will not work correctly when objects are allocated directly, without going through either The reason this test case didn't catch the regression was that the `Topic` class is shared between test cases, so by the time this test case is ran the attribute methods are very likely to be defined. Switching to use a fresh anonymous class in the test to ensure we surface this problem in the future.
* | | | | | | nodoc enum hooks [ci skip]Rafael Mendonça França2014-07-161-2/+2
| | | | | | |
* | | | | | | Merge pull request #16138 from sgrif/sg-attribute-set-keyYves Senn2014-07-162-5/+5
|\ \ \ \ \ \ \ | | | | | | | | | | | | | | | | AttributeSet#include? -> AttributeSet#key?
| * | | | | | | AttributeSet#include? -> AttributeSet#key?Sean Griffin2014-07-112-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | https://github.com/rails/rails/pull/15868/files#r14135210
* | | | | | | | Move uuid_v5 and uuid_v3 to Digest::UUIDRafael Mendonça França2014-07-151-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | These methods are not random so they should not belings to SecureRandom module.
* | | | | | | | Merge pull request #16180 from rafaelfranca/rm-dirtyRafael Mendonça França2014-07-151-2/+2
|\ \ \ \ \ \ \ \ | | | | | | | | | | | | | | | | | | Improve Active Model Dirty API.
| * | | | | | | | Deprecate ActiveModel::Dirty#reset_changes in favor of ↵Rafael Mendonça França2014-07-151-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | #clear_changes_information This method name is causing confusion with the `reset_#{attribute}` methods. While `reset_name` set the value of the name attribute for the previous value the `reset_changes` only discard the changes and previous changes.
* | | | | | | | | Merge branch 'master' of git://github.com/rails/railsGodfrey Chan2014-07-153-6/+18
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: activerecord/CHANGELOG.md
| * | | | | | | | Predicate methods don't need to return `true` / `false`Rafael Mendonça França2014-07-151-1/+1
| | | | | | | | |
| * | | | | | | | Fix version detection for RENAME INDEX support. Fixes #15931.Jeff Browning2014-07-153-6/+18
| | | | | | | | |
* | | | | | | | | Merge pull request #16162 from chancancode/fix_json_coderGodfrey Chan2014-07-151-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixed JSON coder when loading NULL from DB
* | | | | | | | | Revert "Revert "Merge pull request #16059 from jenncoop/json-serialized-attr""Godfrey Chan2014-07-153-1/+20
|/ / / / / / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit 6f3c64eeb1dc8288dae49f114aaf619adc7dcb7f. Conflicts: activerecord/CHANGELOG.md
* | | | | | | | Merge pull request #15266 from dv/use_counter_cache_for_empty_callGodfrey Chan2014-07-151-0/+8
|\ \ \ \ \ \ \ \ | |_|_|/ / / / / |/| | | | | | | If a counter_cache exists, use it for #empty?
| * | | | | | | If a counter_cache exists, use it for #empty?David Verhasselt2014-06-101-0/+8
| | | | | | | |
* | | | | | | | [CI SKIP] Doc fix.Guo Xiang Tan2014-07-151-2/+2
| | | | | | | |
* | | | | | | | Merge pull request #16089 from ↵Aaron Patterson2014-07-142-67/+128
|\ \ \ \ \ \ \ \ | |_|_|_|/ / / / |/| | | | | | | | | | | | | | | | | | | | | | | eileencodes/refactor-reflections-from-sub-classes-to-delegates Refactor reflections from sub classes to delegates
| * | | | | | | Begin refactoring ThroughReflectioneileencodes2014-07-082-67/+128
| | |/ / / / / | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This allows us to decouple AssociationReflection and ThroughReflection making ThroughReflection it's own Reflection bucket in a way. The benefit of this is to be able to remove checks against the macro's symbol for exmaple `macro == :belongs_to`. Get all tests passing again Some of the methods that used to be inherited from MacroReflection through AssociationReflection were no longer getting passed through. They needed to be duplicated into the ThroughReflection. I will extract these out into a separate class. Refactor shared methods into strategy object Now that we've separated ThroughReflection and AssociationReflection we can combine shared methods into one class to avoid duplication. Break out class for each type of reflection This creates a class for each reflection type (has_many, has_one, belongs_to and habtm). We then can remove the need to set the macro symbol in each initialization. Tests were updated to reflect these changes because creation of these reflections is now different. Remove need for @collection instance var We now define `collection?` as `false` by default and set it to `true` in `has_and_belongs_to_many` and `has_many` reflections. This removes the need for the `@collection` instance variable. Raise exception on unknown macro types We shouldn't accept just any macro when creating reflections. An unrecongnized AssociationReflection raises an error. Tests in `reflection_test` were updated to reflect these new changes. `:has_and_belongs_to_many` macro tests were removed because we no longer internally return HABTM.
* | | | | | | Merge pull request #16127 from Envek/fix_16111Matthew Draper2014-07-141-1/+2
|\ \ \ \ \ \ \ | |_|_|_|_|/ / |/| | | | | | Dump PostgreSQL primary key with custom function as a default.
| * | | | | | Dump PostgreSQL primary key with custom function as a default.Andrey Novikov2014-07-111-1/+2
| |/ / / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For example, if use pgcrypto extension in PostgreSQL 9.4 beta 1, where uuid-ossp extension isn't available for moment of writing, and thus to use a gen_random_uuid() method as a primary key default. In this case schema dumper wasn't able to correctly reconstruct create_table statement and lost primary key constraint on schema load. Fixes #16111.
* | | | | | Fixing typo in commentGregory Igelmund2014-07-121-1/+1
| | | | | |
* | | | | | Merge pull request #16136 from sgrif/sg-pg-bit-stringMatthew Draper2014-07-122-13/+33
|\ \ \ \ \ \ | | | | | | | | | | | | | | Don't rely on the column SQL type for bit string quoting
| * | | | | | Don't rely on the column SQL type for bit string quotingSean Griffin2014-07-112-13/+33
| |/ / / / /
* | | | | | Merge pull request #16055 from sgrif/sg-refactor-sqlite3-stringsMatthew Draper2014-07-121-14/+22
|\ \ \ \ \ \ | |/ / / / / |/| | | | | Use a type object for type casting behavior on SQLite3
| * | | | | Use a type object for type casting behavior on SQLite3Sean Griffin2014-07-111-14/+22
| | | | | |
* | | | | | Merge pull request #16071 from sgrif/sg-pg-type-castRafael Mendonça França2014-07-081-15/+0
|\ \ \ \ \ \ | | | | | | | | | | | | | | Remove PG's definition of `type_cast`
| * | | | | | Remove PG's definition of `type_cast`Sean Griffin2014-07-061-15/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | All cases except for `nil` in an array have been removed. `nil` in an array is handled by the Array type object.
* | | | | | | Merge pull request #16072 from sgrif/sg-xml-quotingRafael Mendonça França2014-07-084-4/+42
|\ \ \ \ \ \ \ | | | | | | | | | | | | | | | | Don't rely on the sql type to quote XML columns in PG
| * | | | | | | Don't rely on the sql type to quote XML columns in PGSean Griffin2014-07-064-4/+42
| |/ / / / / /
* | | | | | | Merge pull request #16078 from tgxworld/retreive_connection_onceRafael Mendonça França2014-07-071-2/+3
|\ \ \ \ \ \ \ | | | | | | | | | | | | | | | | Avoid retrieving connection in ActiveRecord::QueryCache multiple times.
| * | | | | | | Avoid retrieving connection in ActiveRecord::QueryCache multiple times.Guo Xiang Tan2014-07-071-2/+3
| |/ / / / / /
* / / / / / / Remove the `text?` predicate from the type objectsSean Griffin2014-07-064-14/+4
|/ / / / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This was only used for uniqueness validations. The first usage was in conjunction with `limit`. Types which cast to string, but are not considered text cannot have a limit. The second case was only with an explicit `:case_sensitive => true` option given by the user.
* | | | | | Change back occurrences of SQLite(3) to sqlite3 when referring to theZachary Scott2014-07-062-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | adapter, fixed from #16057 [ci skip]
* | | | | | Merge pull request #16057 from akshay-vishnoi/doc_changeZachary Scott2014-07-062-3/+3
|\ \ \ \ \ \ | | | | | | | | | | | | | | [ci skip] /sqlite/i --> SQLite
| * | | | | | [ci skip] /sqlite/i --> SQLiteAkshay Vishnoi2014-07-062-3/+3
| | | | | | |
* | | | | | | active_record: Type cast booleans and durations for string columns.Dylan Thacker-Smith2014-07-062-2/+4
| | | | | | |
* | | | | | | Revert "Merge pull request #16059 from jenncoop/json-serialized-attr"Godfrey Chan2014-07-053-20/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit a03097759bd7103bb9db253e7ba095f011453f75. This needs more work before it would work correctly on master.
* | | | | | | Merge pull request #16059 from jenncoop/json-serialized-attrGodfrey Chan2014-07-053-1/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixed issue with ActiveRecord serialize object as JSON Conflicts: activerecord/CHANGELOG.md activerecord/lib/active_record/attribute_methods/serialization.rb
* | | | | | | Merge pull request #16065 from matthewd/mysql-explicit-non-strictMatthew Draper2014-07-061-2/+2
|\ \ \ \ \ \ \ | | | | | | | | | | | | | | | | If our connection is explicitly non-strict, tell MySQL
| * | | | | | | If our connection is explicitly non-strict, tell MySQLMatthew Draper2014-07-061-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We default to making the connection strict, but have historically relied on the MySQL default when we want it to be non-strict. On some (recent?) versions of MySQL, new connections default to being strict, so if we've been told 'strict:false', we're obliged to pass that on. This fixes a test failure that we've seen turn up on relatively-new development machines, so we do already have a test covering it.
* | | | | | | | Use the type object for quoting PG RangesSean Griffin2014-07-054-48/+34
| | | | | | | |
* | | | | | | | Add a `required` option to singular associationsSean Griffin2014-07-043-1/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In addition to defining the association, a `required` association will also have its presence validated. Before: ```ruby belongs_to :account validates_presence_of :account ``` After: ```ruby belongs_to :account, required: true ``` This helps to draw a distinction between types of validations, since validations on associations are generally for data integrity purposes, and aren't usually set through form inputs.
* | | | | | | | Revert "Use a type object for type casting behavior on SQLite3"Matthew Draper2014-07-051-37/+13
|/ / / / / / /
* | | | | | | Merge pull request #16003 from sgrif/sg-refactor-sqlite3-stringsMatthew Draper2014-07-051-13/+37
|\ \ \ \ \ \ \ | | | | | | | | | | | | | | | | Use a type object for type casting behavior on SQLite3
| * | | | | | | Use a type object for type casting behavior on SQLite3Sean Griffin2014-07-011-13/+37
| | |/ / / / / | |/| | | | | | | | | | | | | | | | | | | | | | | | | | Note: I'm not sure we actually need to be logging when this happens. This code would be a fair bit cleaner if we didn't need to log it.
* | | | | | | Merge pull request #16028 from ↵Rafael Mendonça França2014-07-041-1/+1
|\ \ \ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | cade/fix_counter_cache_count_with_association_selects Add `:all` argument to `count` in `reset_counters` Conflicts: activerecord/CHANGELOG.md
| * | | | | | | Add `:all` argument to `count` in `reset_counters`Cade Truitt2014-07-021-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Prior to this fix, if an association had a scope with a `select`, calls to `reset_counters` would generate invalid SQL and throw: ActiveRecord::StatementInvalid: [$DB_ADAPTER]: wrong number of arguments to function COUNT() References #10710, #13648
* | | | | | | | Merge pull request #16049 from matthewd/find-via-reloadMatthew Draper2014-07-051-0/+1
|\ \ \ \ \ \ \ \ | | | | | | | | | | | | | | | | | | After find-via-reload, the record is not new
| * | | | | | | | After find-via-reload, the record is not newMatthew Draper2014-07-051-0/+1
| | |_|/ / / / / | |/| | | | | |
* | | | | | | | Merge pull request #16037 from sgrif/sg-money-quotingRafael Mendonça França2014-07-042-11/+4
|\ \ \ \ \ \ \ \ | |/ / / / / / / |/| | | | | | | Remove unneccessary special case for money in quoting
| * | | | | | | Remove unneccessary special case for money in quotingSean Griffin2014-07-032-11/+4
| | | | | | | |