aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test
Commit message (Collapse)AuthorAgeFilesLines
* context in validation goes through has many relationshipKevin Casey2014-02-083-0/+26
|
* Return sized enumerator from Batches#find_eachMarc-Andre Lafortune2014-02-052-0/+14
|
* Return sized enumerator from Batches#find_in_batchesMarc-Andre Lafortune2014-02-051-0/+10
|
* Strengthen test with different nb of rows and columnsMarc-Andre Lafortune2014-02-051-2/+4
|
* Merge pull request #13949 from vajrasky/fix_typo_column_definition_testYves Senn2014-02-051-2/+2
|\ | | | | Fixed typos in column_definition_test.rb.
| * Fixed typo in column_definition_test.rb.Vajrasky Kok2014-02-051-2/+2
| |
* | docs, AR already auto-detects primary keys. Closes #13946. [ci skip]Yves Senn2014-02-052-3/+5
|/ | | | | This behavior was introduced since Rails 3.1 (207f266ccaaa9cd04cd2a7513ae5598c4358b510) but the docs were still out of date.
* Merge pull request #13935 from arthurnn/fix_12566Rafael Mendonça França2014-02-041-0/+15
|\ | | | | Make sure transaction state resets after commit
| * Make sure transaction state resets after commitArthur Neves2014-02-031-0/+15
| | | | | | | | [fixes #12566]
* | Merge pull request #13899 from ↵Rafael Mendonça França2014-02-041-0/+10
|\ \ | |/ |/| | | | | Fortisque/kevin/active_record_HABTM_with_belongs_to destruction errors out on HABTM w/out primary key
| * fix HABTM w/out primary key errors on destructionKevin Casey2014-02-021-0/+10
| |
* | pass `habtm :autosave` to underlying `hm:t` association. Closes #13923.Yves Senn2014-02-032-7/+27
| |
* | Remove warnings for already defined methodsRafael Mendonça França2014-02-011-1/+3
| |
* | Merge pull request #13688 from jbaudanza/psql-index-existsRafael Mendonça França2014-02-011-0/+12
|\ \ | | | | | | | | | | | | | | | | | | PostgreSQL implementation of SchemaStatements#index_name_exists? Conflicts: activerecord/CHANGELOG.md
| * | psql implementation of #index_name_exists?Jonathan Baudanza2014-01-161-0/+12
| | |
* | | Fixes issue with parsing whitespace content back from database - fixes #13907Mauricio Linhares2014-02-011-0/+12
| |/ |/|
* | Merge pull request #13896 from laurocaetano/dangerous_association_namesCarlos Antonio da Silva2014-01-313-0/+30
|\ \ | | | | | | Associations now raises `ArgumentError` on name conflicts. Closes #13217.
| * | Associations now raise `ArgumentError` on name conflicts.Lauro Caetano2014-01-313-0/+30
| | | | | | | | | | | | | | | Dangerous association names conflicts include instance or class methods already defined by `ActiveRecord::Base`.
* | | Remove unused variable.Tim Fenney2014-01-311-1/+1
|/ /
* | Merge pull request #13859 from huoxito/let-it-goRafael Mendonça França2014-01-301-0/+10
|\ \ | | | | | | Let `unscope` ignore non Arel scope.where_values
| * | Let `unscope` ignore non Arel scope.where_valuesWashington Luiz2014-01-301-0/+10
| | |
* | | Merge pull request #13886 from arthurnn/fix_relation_arelRafael Mendonça França2014-01-301-0/+23
|\ \ \ | |/ / |/| | Fix regression on .select method
| * | Fix regression on `.select_*` methods.Arthur Neves2014-01-301-0/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This was a common pattern: ``` query = author.posts.select(:title) connection.select_one(query) ``` However `.select` returns a ActiveRecord::AssociationRelation, which has the bind information, so we can use that to get the right sql query. Also fix select_rows on postgress and sqlite3 that were not using the binds [fixes #7538] [fixes #12017] [related #13731] [related #12056]
* | | Remove automatic removal of Date/Time stubs after each test caseRafael Mendonça França2014-01-301-1/+5
| | | | | | | | | | | | | | | | | | This behavior is only work out-of-box with minitest and also add a downside to run after each test case, even if we don't used the travel or travel_to methods
* | | Merge pull request #13878 from marcandre/leave_my_options_aloneRafael Mendonça França2014-01-301-0/+6
|\ \ \ | |/ / |/| | find_in_batches should not mutate its argument
| * | find_in_batches should not mutate its argumentMarc-Andre Lafortune2014-01-291-0/+6
| | |
* | | AestheticRafael Mendonça França2014-01-291-6/+7
| | |
* | | Fixing issue with activerecord serialization not being able to dump a record ↵Mauricio Linhares2014-01-291-0/+23
|/ / | | | | | | after loading it from YAML - fixes #13861
* | Merge pull request #13201 from marcandre/find_in_batch_enumeratorRafael Mendonça França2014-01-291-0/+13
|\ \ | | | | | | | | | | | | | | | | | | | | | `find_in_batches` now returns an `Enumerator` Conflicts: activerecord/CHANGELOG.md activerecord/lib/active_record/relation/batches.rb
| * | `find_in_batches` now returns an `Enumerator` when called without a block, ↵Marc-Andre Lafortune2013-12-061-0/+13
| | | | | | | | | | | | | | | | | | so that it can be chained with other `Enumerable` methods.
* | | `enum` now raises on "dangerous" name conflictsGodfrey Chan2014-01-291-0/+59
| | | | | | | | | | | | | | | | | | | | | | | | | | | Dangerous name conflicts includes instance or class method conflicts with methods defined within `ActiveRecord::Base` but not its ancestors, as well as conflicts with methods generated by other enums on the same class. Fixes #13389.
* | | `scope` now raises on "dangerous" name conflictsGodfrey Chan2014-01-291-0/+57
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Similar to dangerous attribute methods, a scope name conflict is dangerous if it conflicts with an existing class method defined within `ActiveRecord::Base` but not its ancestors. See also #13389. *Godfrey Chan*, *Philippe Creux*
* | | Fixed a bug in AR::Base#respond_to?Godfrey Chan2014-01-291-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Before: >> ActiveRecord::Base.respond_to?(:find_by_something) NoMethodError: undefined method `abstract_class?' for Object:Class After: >> ActiveRecord::Base.respond_to?(:find_by_something) => false
* | | Correctly send the string given to lock! and reload(:lock) to the lock scope ↵Mauricio Linhares2014-01-291-0/+11
| | | | | | | | | | | | | | | | | | - fixes #13788 As per the documentation at lock!, if the :lock option is a string it should use the given SQL to generate the lock statement.
* | | Handle aliased attributes in AR::Relation#select, #order, etc.Tsutomu Kuroda2014-01-292-0/+35
| | | | | | | | | | | | | | | | | | | | | With this we can write `Model#select(:aliased)`, `Model#order(:aliased)`, `Model#reoder(aliased: :desc)`, etc. Supplementary work to 54122067acaad39b277a5363c6d11d6804c7bf6b.
* | | Fix indent on test case [ci skip]Carlos Antonio da Silva2014-01-281-2/+2
| | |
* | | use the new clear_validators! api everywhere to reset validators in testsKuldeep Aggarwal2014-01-282-3/+3
| | |
* | | Merge pull request #13785 from kuldeepaggarwal/fix-find_with_multiple_idsYves Senn2014-01-241-7/+24
|\ \ \ | | | | | | | | Fix `ActiveRecord::RecordNotFound` error message with custom primary key
| * | | Fix `ActiveRecord::RecordNotFound` error message with custom primary keyKuldeep Aggarwal2014-01-251-7/+24
| | | |
* | | | Remove unused assignment to fix warnings in enum test.Vipul A M2014-01-241-1/+0
|/ / /
* | | Calling reset on a collection association should unload the assocationKelsey Schlarman2014-01-211-0/+9
| | | | | | | | | | | | Need to define #reset on CollectionProxy.
* | | Ensure AR #second, #third, etc. finders work through associationsJason Meller2014-01-216-72/+109
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit fixes two regressions introduced in cafe31a078 where newly created finder methods #second, #third, #forth, and #fifth caused a NoMethodError error on reload associations and where we were pulling the wrong element out of cached associations. Examples: some_book.authors.reload.second # Before # => NoMethodError: undefined method 'first' for nil:NilClass # After # => #<Author id: 2, name: "Sally Second", ...> some_book.first.authors.first some_book.first.authors.second # Before # => #<Author id: 1, name: "Freddy First", ...> # => #<Author id: 1, name: "Freddy First", ...> # After # => #<Author id: 1, name: "Freddy First", ...> # => #<Author id: 2, name: "Sally Second", ...> Fixes #13783.
* | | Merge pull request #13776 from rails/dirty-enumRafael Mendonça França2014-01-213-0/+74
|\ \ \ | | | | | | | | | | | | | | | | | | | | | | | | Implement the Dirty API with the Enum feature correctly. Conflicts: activerecord/CHANGELOG.md
| * | | Add more tests for the dirty feature for enumsRafael Mendonça França2014-01-213-0/+34
| | | |
| * | | Make enum feature work with dirty methodsRafael Mendonça França2014-01-211-0/+40
| | | | | | | | | | | | | | | | | | | | To make this possible we have to override the save_changed_attribute hook.
* | | | `has_one` and `belongs_to` accessors don't add ORDER BY to the queries anymore.Rafael Mendonça França2014-01-212-0/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Since Rails 4.0, we add an ORDER BY in the `first` method to ensure consistent results among different database engines. But for singular associations this behavior is not needed since we will have one record to return. As this ORDER BY option can lead some performance issues we are removing it for singular associations accessors. Fixes #12623.
* | | | prepend table name for `Relation#select` columns.Yves Senn2014-01-211-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This fixes a bug where `select(:id)` combined with `joins()` raised: ``` ActiveRecord::StatementInvalid: SQLite3::SQLException: ambiguous column name: id: SELECT id, authors.author_address_id FROM "posts" INNER JOIN "authors" ON "authors"."id" = "posts"."author_id" ORDER BY posts.id LIMIT 3 ``` The `select_values` are still String and Symbols because other parts (mainly calculations.rb) rely on that fact. /cc @tenderlove
* | | | Fail early with "Primary key not included in the custom select clause" in ↵Alexander Balashov2014-01-211-1/+3
|/ / / | | | | | | | | | | | | find_in_batches Before this patch find_in_batches raises this error only on second iteration. So you will know about the problem only when you get the batch size threshold.
* | | Ensure #second acts like #first AR finderJason Meller2014-01-206-26/+123
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit bring the famous ordinal Array instance methods defined in ActiveSupport into ActiveRecord as fully-fledged finders. These finders ensure a default ascending order of the table's primary key, and utilize the OFFSET SQL verb to locate the user's desired record. If an offset is defined in the query, calling #second adds to the offset to get the actual desired record. Fixes #13743.
* | | Merge pull request #13745 from nextgearcapital/masterRafael Mendonça França2014-01-192-0/+4
|\ \ \ | | | | | | | | set encoding for pipe to binary mode