aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
Commit message (Collapse)AuthorAgeFilesLines
...
* | | Add `#all_includes` method to reflectionseileencodes2015-01-022-1/+5
| | | | | | | | | | | | | | | `yield` instead of relying on checking if the reflection is equal to the `chain_head`.
* | | Initialze `#alias_tracker` with base table nameeileencodes2015-01-023-11/+12
| | | | | | | | | | | | | | | | | | | | | Instead of initializing an empty connection use the base table name instead. Split up and refactor `#create` to be 2 methods `#create` and `#create_with_joins`. Removes the need to update the count by 1 on initialzing a JoinDependency.
* | | Move `alias_candiate` into `AbstractReflection`eileencodes2015-01-022-10/+16
| | | | | | | | | | | | | | | | | | This moves `alias_candidate` out of the `ReflectionProxy` and into the `AbstractReflection` so it is shared by all reflections. Change `alias_name` to a method and and remove assignment in `#get_chain`.
* | | Pass `connection` rather than `alias_tracker`eileencodes2015-01-022-7/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | After the refactorings we're only using the connection and not the alias tracker anymore. This builds on commit 18019. Reuse the already available `@connection` to reduce the surface area of the alias tracker's API. We can then remove the `attr_reader` because the connection is already available.
* | | Assign the `#alias_name` to each reflectioneileencodes2015-01-022-18/+15
| | | | | | | | | | | | This makes the `#alias_name` more functional.
* | | Clean up / refactor new reflection classeseileencodes2015-01-022-92/+76
| | | | | | | | | | | | | | | | | | Move `RuntimeReflection` and `PolymorphicReflect` into Reflection. This allows the methods to inherit from `ThroughReflection` and DRY up the methods by removing duplicates.
* | | Refactor `#get_chain` iteration to a linked listeileencodes2015-01-021-14/+21
| | | | | | | | | | | | | | | | | | The linked list lets us use a loop in `#add_constraints` and completely remove the need for indexing the iteration becasue we have access to the next item in the chain.
* | | Refactor `#get_chain` to remove need for `#construct_tables`eileencodes2015-01-021-14/+11
| | | | | | | | | | | | | | | | | | By concatnating the `ReflectionProxy` with the `chain` we remove the need for `#construct_tables` because the `chain` is now in the correct order (order of the chain DOES matter).
* | | Move `#alias_name` to `ReflectionProxy` classeileencodes2015-01-022-20/+23
| | | | | | | | | | | | | | | Putting the `#alias_name` into ReflectionProxy means we don't have to cache the `#alias_name` globally anymore - it's not cached per query.
* | | Clean up assignments in `#add_constraints`eileencodes2015-01-021-8/+3
| | | | | | | | | | | | | | | | | | `is_first_chain`, `items` and `klass` are no longer beneficial and can be called directly instead of via their assignments - because they are each only used once.
* | | Refactor construct_tables methodeileencodes2015-01-022-36/+20
| | | | | | | | | | | | | | | Move method structure into reflection classes for accessibly on each reflection rather than by traversing the chain.
* | | Add RuntimeReflection for recursive access to chaineileencodes2015-01-021-3/+54
| | | | | | | | | | | | | | | | | | | | | The `RuntimeReflection` class allows the reflection to be accessed at runtime - then we always know which reflection we are accessing in the chain. The `#get_chain` method then allows us to recursively access the chain through the `RuntimeReflection`.
* | | Add PolymorphicReflection and constraints methodeileencodes2015-01-022-4/+62
| | | | | | | | | | | | | | | | | | `#constraints` builds a flattened version of `scope_chain` to allow it to be accessible without requiring an index when iterating over the `scope_chain`
* | | A quick pass through NestedAttributes' doc [ci skip]Robin Dupret2015-01-021-18/+20
| | |
* | | Merge pull request #17822 from kamipo/refactor_visit_change_column_definitionRafael Mendonça França2015-01-024-16/+14
|\ \ \ | | | | | | | | Refactor `visit_ChangeColumnDefinition`
| * | | Refactor `visit_ChangeColumnDefinition`Ryuta Kamizono2015-01-032-11/+9
| | | | | | | | | | | | | | | | `visit_ChangeColumnDefinition` is the same "CHANGE column_name " + `visit_ColumnDefinition(o)`.
| * | | Add default value for `create_table_definition`Ryuta Kamizono2015-01-033-5/+5
| | | | | | | | | | | | | | | | | | | | In most cases, `create_table_definition` called by table_name (the first argument) only.
* | | | Merge pull request #8547 from printercu/patch-1Rafael Mendonça França2015-01-021-1/+6
|\ \ \ \ | |/ / / |/| | | | | | | | | | | | | | | | | | | | | | | fix for messages in invalid encoding from db-drivers Conflicts: activerecord/lib/active_record/connection_adapters/abstract_adapter.rb activerecord/test/cases/connection_adapters/abstract_adapter_test.rb
| * | | fix for messages in invalid encoding from db-driversMax Melentiev2013-12-071-1/+5
| | | |
* | | | Merge pull request #17820 from fw42/restore_query_cache_on_rollbackRafael Mendonça França2015-01-027-9/+17
|\ \ \ \ | | | | | | | | | | | | | | | Clear query cache on rollback
| * | | | Restore query cache on rollbackFlorian Weingarten2014-12-017-9/+17
| | | | |
* | | | | Merge pull request #15309 from iantropov/issue_12698_build_throughRafael Mendonça França2015-01-021-0/+11
|\ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add setting of FK for throgh associations while building Conflicts: activerecord/CHANGELOG.md activerecord/test/cases/associations/has_many_through_associations_test.rb
| * | | | | Add setting of FK for throgh associations while buildingIvan Antropov2014-05-251-0/+11
| | | | | |
* | | | | | Merge pull request #18228 from kamipo/correctly_dump_primary_keyRafael Mendonça França2015-01-025-5/+43
|\ \ \ \ \ \ | |_|_|_|/ / |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Improve a dump of the primary key support. Conflicts: activerecord/CHANGELOG.md
| * | | | | Improve a dump of the primary key support.Ryuta Kamizono2014-12-295-5/+43
| | | | | | | | | | | | | | | | | | | | | | | | If it is not a default primary key, correctly dump the type and options.
* | | | | | Remove support to activerecord-deprecated_findersRafael Mendonça França2015-01-0212-124/+62
| | | | | |
* | | | | | Merge pull request #18067 from ↵Rafael Mendonça França2015-01-021-0/+28
|\ \ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | kamipo/format_datetime_string_according_to_precision Format the datetime string according to the precision of the datetime field. Conflicts: activerecord/CHANGELOG.md
| * | | | | | Format the datetime string according to the precision of the datetime field.Ryuta Kamizono2015-01-021-1/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Incompatible to rounding behavior between MySQL 5.6 and earlier. In 5.5, when you insert `2014-08-17 12:30:00.999999` the fractional part is ignored. In 5.6, it's rounded to `2014-08-17 12:30:01`: http://bugs.mysql.com/bug.php?id=68760
| * | | | | | Allow precision option for MySQL datetimes.Ryuta Kamizono2015-01-021-0/+12
| | | | | | |
* | | | | | | Merge pull request #15746 from amccloud/auto-inverse_of-in-moduleRafael Mendonça França2015-01-021-1/+1
|\ \ \ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixed automatic inverse_of for models nested in module Conflicts: activerecord/CHANGELOG.md
| * | | | | | | Fixed automatic inverse_of for models nested in moduleAndrew McCloud2014-06-151-1/+1
| | | | | | | |
* | | | | | | | Merge pull request #11898 from prathamesh-sonpatki/patch-updateRafael Mendonça França2015-01-021-1/+13
|\ \ \ \ \ \ \ \ | |_|/ / / / / / |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Changed ActiveRecord::Relation#update behavior so that it will work on Relation objects without giving id Conflicts: activerecord/CHANGELOG.md
| * | | | | | | Allow ActiveRecord::Relation#update to run on result of a relation with ↵Prathamesh Sonpatki2014-12-201-1/+13
| | |_|_|_|_|/ | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | callbacks and validations - Right now, there is no method to update multiple records with validations and callbacks. - Changed the behavior of existing `update` method so that when `id` attribute is not given and the method is called on an `Relation` object, it will execute update for every record of the `Relation` and will run validations and callbacks for every record. - Added test case for validating that the callbacks run when `update` is called on a `Relation`. - Changed test_create_columns_not_equal_attributes test from persistence_test to include author_name column on topics table as it it used in before_update callback. - This change introduces performance issues when a large number of records are to be updated because it runs UPDATE query for every record of the result. The `update_all` method can be used in that case if callbacks are not required because it will only run single UPDATE for all the records.
* | | | | | | Merge pull request #18080 from korbin/fix_reaping_frequency_configurationRafael Mendonça França2015-01-021-1/+1
|\ \ \ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | Fix issue with reaping_frequency type.
| * | | | | | | fix issue with reaping_frequency typekorbin2014-12-171-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When using DATABASE_URL to configure ActiveRecord, :reaping_frequency does not get converted from a string to a numeric value. This value is eventually passed to 'sleep' and must be numeric to avoid exceptions. This commit converts :reaping_frequency to a float when present.
* | | | | | | | Do not check only for the Rails constantRafael Mendonça França2015-01-021-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This constant may be define for auxiliar gems like rails-html-sanitizer and these methods call will fail.
* | | | | | | | 💣 I forgot to commit the arity changeSean Griffin2015-01-011-1/+1
| | | | | | | |
* | | | | | | | Don't rely on the column for type information in uniquness validationsSean Griffin2015-01-011-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The validator has access to richer type information
* | | | | | | | Don't load an entire table into memory to copy it on SQLiteSean Griffin2015-01-011-15/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | SQL has mechanisms we can use to copy data from one table into another.
* | | | | | | | Stop using the column for type information in sanitizationSean Griffin2015-01-011-5/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As we move towards removing the types from the column objects, any remaining places which have access to richer type information should be using it.
* | | | | | | | Stop passing the column to the connection adapter when quoting defaultsSean Griffin2015-01-011-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The column is no longer used for anything besides type casting, which is what we're trying to remove from the column entirely.
* | | | | | | | Update copyright notices to 2015 [ci skip]Arun Agrawal2014-12-311-1/+1
| | | | | | | |
* | | | | | | | Extract the index length validation to a auxiliar methodRafael Mendonça França2014-12-303-9/+12
| | | | | | | |
* | | | | | | | Merge pull request #18264 from yahonda/rename_index_mysqlRafael Mendonça França2014-12-301-0/+3
|\ \ \ \ \ \ \ \ | | | | | | | | | | | | | | | | | | Raise a better exception for renaming long indexes for mysql adapters
| * | | | | | | | Raise a better exception for renaming long indexes for mysql adaptersYasuo Honda2014-12-301-0/+3
| | | | | | | | |
* | | | | | | | | Fix error message when trying to create an associated recordRafael Mendonça França2014-12-301-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This error only happens when the foreign key is missing. Before this fix the following exception was being raised: NoMethodError: undefined method `val' for #<Arel::Nodes::BindParam:0x007fc64d19c218> Now the message is: ActiveRecord::UnknownAttributeError: unknown attribute 'foreign_key' for Model.
* | | | | | | | | Share foreign_key_present? implementation in _has_ associationsbrainopia2014-12-314-8/+14
|/ / / / / / / /
* | | | | | | | Merge pull request #17680 from larskanis/fix_bytea_change_detectionSean Griffin2014-12-301-0/+1
|\ \ \ \ \ \ \ \ | | | | | | | | | | | | | | | | | | PostgreSQL, Fix change detection caused by superfluous bytea unescaping
| * | | | | | | | PostgreSQL, Fix change detection caused by wrong data for bytea unescaping.Lars Kanis2014-12-291-0/+1
| | |_|_|/ / / / | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This showed up when running BinaryTest#test_load_save with the more restrictive input string handling of pg-0.18.0.pre20141117110243.gem . Bytea values sent to the server are in binary format, but are returned back as escaped text. To fulfill the assumption that type_cast_from_database(type_cast_for_database(binary)) == binary we unescape only, if the value was really received from the server.
* | | | | | | | Ensures that primary_key method will return nil when multi-pkArthur Neves2014-12-302-8/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When table has a composite primary key, the `primary_key` method for sqlite3 and postgresql was only returning the first field of the key. Ensures that it will return nil instead, as AR dont support composite pks.