aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
Commit message (Collapse)AuthorAgeFilesLines
* Define id_was to get the previous value of the primary keyRafael Mendonça França2014-08-061-1/+7
| | | | | | | | | Currently when we call id_was and we have a custom primary key name Active Record will return the current value of the primary key. This make impossible to correctly do an update operation if you change the id. Fixes #16413
* schema rake tasks are specific about the configuration to act on.Yves Senn2014-08-063-14/+25
| | | | | | | | | | The rake tasks and the `DatabaseTakss` adapter classes used to assume a configuration at some places. This forced the rake tasks to establish a specific connection before calling into `load_schema`. After #15394 this started to cause issues because it could `purge` the wrong database before loading the schema.
* Revert "Revert "Merge pull request #15394 from ↵Yves Senn2014-08-062-1/+7
| | | | | | morgoth/fix-automatic-maintaining-test-schema-for-sql-format"" This reverts commit 5c87b5c5248154cf8aa76cce9a24a88769de022d.
* Merge pull request #16364 from arthurnn/make_transaction_one_classJeremy Kemper2014-08-051-70/+54
|\ | | | | Clarify Transaction responsibilities by breaking unneeded inheritance hierarchy.
| * Cleanup Transaction inheritance.Arthur Neves2014-08-051-70/+54
| | | | | | | | | | | | | | | | | | Transaction class doesnt need to encapsulate the transaction state using inheritance. This removes all Transaction subclasses, and let the Transaction object controls different actions based on its own state. Basically the only actions would behave differently are `being`,`commit`,`rollback` as they could act in a savepoint or in a real transaction.
* | Merge pull request #16404 from bogdan/move-create-with-bangCarlos Antonio da Silva2014-08-052-15/+12
|\ \ | | | | | | | | | Moved #create! method from Validations to Persistence module
| * | Moved #create! method from Validations to Persistence moduleBogdan Gusiev2014-08-052-15/+12
| | |
* | | Remove unused text? predicate method and delegationCarlos Antonio da Silva2014-08-052-5/+1
|/ / | | | | | | | | | | | | | | The method has been removed in 09206716f8695f6b8467f15c1befa5a4c3c10978 (PR #16074), but the delegation was apparently missed, and one instance of the method was added back with the addition of OID::Xml in 336be2bdf7dfa1b31879d0ab27e5f3101b351923 (PR #16072), so we can safely rm both.
* | Don't delegate Reflection#chain to ThroughAssociationeileencodes2014-08-041-2/+2
| | | | | | | | | | | | We shouldn't be delegating chain to ThroughAssociation since the only place that needs to call it is `target_scope`. Instead we can call `reflecion.chain`.
* | Merge pull request #16333 from ↵Yves Senn2014-08-041-4/+17
|\ \ | | | | | | | | | | | | | | | | | | | | | | | | joker1007/fix_decimal_cast_from_float_with_large_precision Fix type casting to Decimal from Float with large precision Conflicts: activerecord/CHANGELOG.md
| * | Fix type casting to Decimal from Float with ...joker10072014-08-011-4/+17
| | | | | | | | | | | | | | | When I defines large precision column at RDBMS, I assigns float value, raise ArgumentError (precision too large).
* | | Merge pull request #16378 from ↵Rafael Mendonça França2014-08-021-1/+1
|\ \ \ | | | | | | | | | | | | | | | | JackDanger/doc-fix-in-join-association-build_constraint [doc] updating documented parameter for build_constraint
| * | | updating documented parameter for build_constraintJack Danger Canty2014-08-021-1/+1
| | | | | | | | | | | | | | | | | | | | Updates documentation in line with changes made in 743b67508e2027e1d086142ccbec47a19fc943f6
* | | | Merge pull request #16377 from JackDanger/doc-fix-in-association-reflectionEileen M. Uchitelle2014-08-021-1/+1
|\ \ \ \ | | | | | | | | | | Fixes small error in ActiveRecord::Reflection docs
| * | | | Fixes small error in ActiveRecord::Reflection docsJack Danger Canty2014-07-311-1/+1
| |/ / / | | | | | | | | | | | | [ci skip]
* | | | Deprecate source_macroeileencodes2014-08-021-1/+7
| | | | | | | | | | | | | | | | | | | | | | | | `source_macro` is no longer used in any ActiveRecord code. I've chosen to deprecate it because it was not marked as nodoc and may be in use outside of rails source.
* | | | Use available method rather than macro name checkingCarlos Antonio da Silva2014-07-311-1/+1
| | | |
* | | | Rename method for clarityCarlos Antonio da Silva2014-07-311-3/+3
| |_|/ |/| | | | | | | | Ruby generally does not use the is_* prefix on predicate methods.
* | | Replace ClosedTransaction with NullTransactionArthur Neves2014-07-312-8/+5
| | |
* | | Move TransactionManager to bottom of classArthur Neves2014-07-311-67/+67
| | |
* | | Merge pull request #16341 from arthurnn/transactions_remove_beginRafael Mendonça França2014-07-311-54/+18
|\ \ \ | | | | | | | | Transactions refactoring - 2
| * | | Make ClosedTransaction a null objectArthur Neves2014-07-311-16/+6
| | | |
| * | | Remove parent on Transaction objectArthur Neves2014-07-311-16/+9
| | | |
| * | | Remove being/number methods from transaction classArthur Neves2014-07-311-27/+8
| | | |
* | | | Merge pull request #16350 from JackDanger/test-rake-db-migrate-taskRafael Mendonça França2014-07-312-4/+11
|\ \ \ \ | | | | | | | | | | Add ActiveRecord::Tasks::DatabaseTasks.migrate
| * | | | Add ActiveRecord::Tasks::DatabaseTasks.migrateJack Danger Canty2014-07-312-4/+11
| | |/ / | |/| | | | | | | | | | | | | | | | | | This extracts the logic that was embedded in a Rake task into a static method. Bonus: the first test for `rake db:migrate`
* | | | Merge pull request #16361 from JackDanger/clearer-connection-pool-documentationRafael Mendonça França2014-07-311-15/+36
|\ \ \ \ | | | | | | | | | | [doc] Clarify how the ConnectionHandler works
| * | | | Clarify how the ConnectionHandler worksJack Danger Canty2014-07-311-15/+36
| |/ / / | | | | | | | | | | | | | | | | | | | | | | | | This makes the implicit description of how connection pooling works a little more explicit. It converts the examples of a model hierarchy into actual Ruby code and demonstrates how the key structure of the database.yml relates to the `establish_connection` method.
* | | / Refactor join_keys to remove complex conditionalseileencodes2014-07-312-29/+29
| |_|/ |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Pushing conditionals down to through reflection Only the through association needs the part of this conditional that deals with belongs to and polymorphic? so that can be pushed down into the ThroughReflection reducing the conditionals. Remove conditional because we can delegate join keys to source reflection Remove need for source_macro checking By adding join_id_for to the other reflections we remove the need to cehck against the source_macro and can reduce the conditioanl from the original join_id_for(owner) Using polymorphism instead of testing the source_macro This case statement in join_association is almost exactly the same as the original join_keys code. Testing taht theory by creating a new join_dependency_keys(assoc_klass) method. Refactor join_keys further to be more concise Fixed format of "#:nodoc:" to "# :nodoc:" where I added them to this file.
* | | Redefine macro checks for reflectionseileencodes2014-07-303-11/+9
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | Now that we define the macro on the reflection type we no longer need to check `macro == :what` on each type for `belongs_to?` or `has_one?` etc. These now default to false unless it's defined in the reflection class. Reuse existing belongs_to? method to check macros We don't need to do `:belongs_to == macro` anymore becasue we have a `belongs_to?` method. I didn't find this being used anywhere for `has_one?` or `collection?` since they were already fixed.
* / Remove redundant `self.` in class method callsJack Danger Canty2014-07-301-5/+5
|/ | | | These are the only instances of this in the whole code base.
* Remove @state.parent assignment on commitArthur Neves2014-07-291-2/+1
| | | | | | | | | This piece of code was introduced on 67d8bb963d5d51fc644d6b1ca20164efb4cee6d7 , which was calling `committed?` in the `transaction_state` before calling the `committed!` method. However on 7386ffc781fca07a0c656db49fdb54678caef809, the `committed?` check was removed and replaced by a `finalized?`, which only checks if the state is not nil. Thus we can remove that line.
* [ci skip] fix doc typo for validates_uniqueness_ofSatoru Yamasaki2014-07-291-1/+1
|
* remove blank lines in the start of the ActiveRecord filesPonomarev Nikolay2014-07-298-8/+0
|
* Merge pull request #16305 from tomkadwill/documented_change_tableRafael Mendonça França2014-07-281-1/+1
|\ | | | | Added documentation for change_table
| * Added nodoc to change_tableTom Kadwill2014-07-281-1/+1
| |
* | Extract the transaction class to a local variableRafael Mendonça França2014-07-281-6/+2
| |
* | Merge pull request #16284 from arthurnn/transactionsRafael Mendonça França2014-07-283-62/+81
|\ \ | | | | | | | | | Transactions refactoring
| * | savepoint_name should return nil for non-savepoint transactionsArthur Neves2014-07-282-4/+7
| | | | | | | | | | | | Also add test to assets the savepoint name
| * | Transactions refactoringArthur Neves2014-07-283-38/+65
| | | | | | | | | | | | | | | | | | | | | Add a transaction manager per connection, so it can controls the connection responsibilities. Delegate transaction methods to transaction_manager
| * | Remove finishing? method from transaction.Arthur Neves2014-07-242-24/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The finishing variable on the transaction object was a work-around for the savepoint name, so after a rollback/commit the savepoint could be released with the previous name. related: 9296e6939bcc786149a07dac334267c4035b623a 60c88e64e26682a954f7c8cd6669d409ffffcc8b
* | | Fix typo and remove code block since present is not a method.Rafael Mendonça França2014-07-281-1/+1
| | |
* | | docs, clarify attribute query methods on numeric columns. Closes #16246.Yves Senn2014-07-281-0/+1
| | | | | | | | | | | | [ci skip]
* | | Merge pull request #16297 from calebthompson/extract-iterator-methodRafael Mendonça França2014-07-281-10/+14
|\ \ \ | | | | | | | | Extract iterator method in AR::SchemaDumper
| * | | Extract iterator method in AR::SchemaDumperCaleb Thompson2014-07-251-10/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Gems which wish to tie into ActiveRecord::SchemaDumper need to duplicate this logic currently. [Foreigner] is one such example, as is a library I'm currently working on but which hasn't been released yet: def tables_with_foreign_keys(stream) tables_without_foreign_keys(stream) @connection.tables.sort.each do |table| next if ['schema_migrations', ignore_tables].flatten.any? do |ignored| case ignored when String; table == ignored when Regexp; table =~ ignored else raise StandardError, 'ActiveRecord::SchemaDumper.ignore_tables accepts an array of String and / or Regexp values.' end end foreign_keys(table, stream) end end [Foreigner]: https://github.com/matthuhiggins/foreigner/blob/master/lib/foreigner/schema_dumper.rb#L36-L43 Extract the skip logic to a method, making it much simpler to follow this same behavior in gems that are tying into the migration flow and let them dump only tables that aren't skipped without copying this block of code. The above code could then be simplified to: def tables_with_foreign_keys(stream) tables_without_foreign_keys(stream) @connection.tables.sort.each do |table| foreign_keys(table, stream) unless ignored?(table) end end It also, in my opinion, simplifies the logic on ActiveRecord's side, and clarifies the intent of the skip logic.
* | | | Merge pull request #16295 from kenn/no_stacktrace_drop_taskRafael Mendonça França2014-07-281-0/+2
|\ \ \ \ | | | | | | | | | | | | | | | No verbose backtrace by db:drop when database does not exist.
| * | | | No verbose backtrace by db:drop when database does not exist.Kenn Ejima2014-07-271-0/+2
| | | | |
* | | | | [ci skip] Fix documentation for @macro and reflection typeseileencodes2014-07-272-7/+10
|/ / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | Since `@macro` doesn't exist anymore and these reflections are no longer AssociationReflections but their own types of reflections based on macro I updated the documentation to match the changes I made in #16089 and #16198. An `AssociationReflection` that had a `@macro` of `:has_many` now is a `HasManyReflection`
* | | | Merge pull request #16290 from a3gis/masterZachary Scott2014-07-252-2/+2
|\ \ \ \ | |/ / / |/| | | [ci skip] Fix documentation of SQLite3Adapter.columns where SQLite3Column was removed in e781aa31fc52a7c696115302ef4d4e02bfd1533b
| * | | Remove references to SQLite3Column from documentationa3gis2014-07-251-1/+1
| | | |