aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test
Commit message (Collapse)AuthorAgeFilesLines
* fix set_pk_sequence and add a test for it.Aaron Patterson2014-10-311-0/+8
|
* Don't modify the columns hash to set defaults from the attributes APISean Griffin2014-10-311-10/+14
| | | | | Nothing is directly using the columns for the default values anymore. This step helps us get closer not not mutating the columns hash.
* Load test schema even if there are no migrationsSean Griffin2014-10-311-0/+13
| | | | Fixes #17170
* Merge pull request #17305 from ↵Rafael Mendonça França2014-10-311-0/+89
|\ | | | | | | | | ziggythehamster/activerecord-connectionhandling-RAILS_ENV-without-rails If Rails is not defined, check ENV["RAILS_ENV"] and ENV["RACK_ENV"] in ActiveRecord::ConnectionHandling
| * If Rails is not defined, check ENV["RAILS_ENV"] and ENV["RACK_ENV"].Keith Gable2014-10-211-0/+89
| | | | | | | | | | | | | | This fixes a regression introduced by 6cc03675d30b58e28f585720dad14e947a57ff5b. ActiveRecord, if used without Rails, always checks the "default_env" environment. This would be OK, except that Sinatra also supports environments, and it runs with {RACK|RAILS}_ENV=production. This patch adds a fallback to RAILS_ENV and RACK_ENV (and ultimately default_env) if Rails.env doesn't exist.
* | Use the correct values for int max and minSean Griffin2014-10-312-47/+106
| | | | | | | | | | We had accidentally gone one power of two too far. In addition, we need to handle minimum values as well as the maximum.
* | Treat strings greater than int max value as out of rangeSean Griffin2014-10-313-15/+14
| | | | | | | | | | | | | | | | | | | | | | Sufficiently large integers cause `find` and `find_by` to raise `StatementInvalid` instead of `RecordNotFound` or just returning `nil`. Given that we can't cast to `nil` for `Integer` like we would with junk data for other types, we raise a `RangeError` instead, and rescue in places where it would be highly unexpected to get an exception from casting. Fixes #17380
* | Don't require calculations to be aliased to a columnSean Griffin2014-10-311-1/+0
| | | | | | | | | | | | | | Arel has changed so that `.sum` no longer aliases `SUM(the_column)` to `sum_id`. This means the type returned by the adapter will be at the key `"SUM(the_column)"`. Longer term, we should eventually be able to retain type information from the AR::Base subclasses used in joined queries
* | Remove redundant `to_s` in interpolationclaudiob2014-10-301-3/+3
| |
* | add bigserial pk supportAaron Patterson2014-10-291-0/+20
| |
* | fix MySQL enum type lookup with values matching another type. Closes #17402.Yves Senn2014-10-291-0/+4
| | | | | | | | | | | | | | | | | | | | The MySQLAdapter type map used the lowest priority for enum types. This was the result of a recent refactoring and lead to some broken lookups for enums with values that match other types. Like `8bit`. This patch restores the priority to what we had before the refactoring. /cc @sgrif
* | 💣Sean Griffin2014-10-282-2/+5
| | | | | | | | We were relying on hash inequality in tests
* | Allow Relation#rewhere to work with infinite range valuesDan Olson2014-10-271-0/+21
| |
* | Merge pull request #17374 from maurogeorge/scope-exceptionYves Senn2014-10-271-0/+7
|\ \ | | | | | | | | | Raises ArgumentError when try to define a scope without a callable
| * | Raises ArgumentError when try to define a scope without a callableMauro George2014-10-231-0/+6
| |/ | | | | | | | | | | This changes the actual exception `NoMethodError: undefined method `call' for #<ActiveRecord::Relation []>` to a `ArgumentError` when try to define a scope without a callable.
* | Merge pull request #14143 from derekprior/dp-compound-index-orderingYves Senn2014-10-272-3/+3
|\ \ | | | | | | | | | | | | | | | | | | Use type column first in multi-column indexes Conflicts: activerecord/CHANGELOG.md
| * | Use type column first in multi-column indexesDerek Prior2014-10-242-3/+3
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `add_reference` can very helpfully add a multi-column index when you use it to add a polymorphic reference. However, the first column in the index is the `id` column, which is less than ideal. The [PostgreSQL docs][1] say: > A multicolumn B-tree index can be used with query conditions that > involve any subset of the index's columns, but the index is most > efficient when there are constraints on the leading (leftmost) > columns. The [MySQL docs][2] say: > MySQL can use multiple-column indexes for queries that test all the > columns in the index, or queries that test just the first column, the > first two columns, the first three columns, and so on. If you specify > the columns in the right order in the index definition, a single > composite index can speed up several kinds of queries on the same > table. In a polymorphic relationship, the type column is much more likely to be useful as the first column in an index than the id column. That is, I'm more likely to query on type without an id than I am to query on id without a type. [1]: http://www.postgresql.org/docs/9.3/static/indexes-multicolumn.html [2]: http://dev.mysql.com/doc/refman/5.0/en/multiple-column-indexes.html
* / Fix Relation.rewhere to work with Range valuesDan Olson2014-10-201-0/+7
|/
* Merge pull request #17019 from yuki24/add-class-name-to-unknown-attr-errorYves Senn2014-10-201-2/+2
|\ | | | | | | Message on AR::UnknownAttributeError should include the class name of a record
| * AR::UnknownAttributeError should include the class name of a recordYuki Nishijima2014-10-151-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This would be helpful if 2 models have an attribute that has a similar name to the other. e.g: before: User.new(name: "Yuki Nishijima", projects_attributes: [name: "kaminari"]) # => ActiveRecord::UnknownAttributeError: unknown attribute: name after: User.new(name: "Yuki Nishijima", projects_attributes: [name: "kaminari"]) # => ActiveRecord::UnknownAttributeError: unknown attribute on User: name
* | AR::UnknownAttributeError should include the class name of a recordYuki Nishijima2014-10-201-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This would be helpful if 2 models have an attribute that has a similar name to the other. e.g: before: User.new(name: "Yuki Nishijima", projects_attributes: [name: "kaminari"]) # => ActiveRecord::UnknownAttributeError: unknown attribute: name after: User.new(name: "Yuki Nishijima", projects_attributes: [name: "kaminari"]) # => ActiveRecord::UnknownAttributeError: unknown attribute on User: name
* | Fixed test throwing unused variable warningVipul A M2014-10-191-1/+1
| |
* | Merge pull request #17302 from ↵Rafael Mendonça França2014-10-181-3/+3
| | | | | | | | | | | | claudiob/replace-slower-block-call-with-faster-yield Replace (slower) block.call with (faster) yield
* | Revert "Replace (slower) block.call with (faster) yield"Zachary Scott2014-10-181-3/+3
| | | | | | | | This reverts commit 0ab075e75f58bf403f7ebe20546c7005f35db1f6.
* | Replace (slower) block.call with (faster) yieldclaudiob2014-10-181-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Performance optimization: `yield` with an implicit `block` is faster than `block.call`. See http://youtu.be/fGFM_UrSp70?t=10m35s and the following benchmark: ```ruby require 'benchmark/ips' def fast yield end def slow(&block) block.call end Benchmark.ips do |x| x.report('fast') { fast{} } x.report('slow') { slow{} } end # => fast 154095 i/100ms # => slow 71454 i/100ms # => # => fast 7511067.8 (±5.0%) i/s - 37445085 in 4.999660s # => slow 1227576.9 (±6.8%) i/s - 6145044 in 5.028356s ```
* | Add a deprecation warning for abiguous boolean valuesSean Griffin2014-10-161-4/+6
| | | | | | | | | | | | | | | | | | | | | | In Rails 5.0, we'd like to change the behavior of boolean columns in Rails to be closer to Ruby's semantics. Currently we have a small set of values which are "truthy", and all others are "falsy". In Rails 5.0, we will reverse this to have a small number of values which are "falsy", and all others will become "truthy". In the interim, all values which are ambiguous must emit a deprecation warning.
* | test, better describe `SerializationTypeMismatch` behavior. refs #14716.Yves Senn2014-10-161-2/+1
| |
* | pg, test assigning non-array values to an array column. Closes #14716.Yves Senn2014-10-161-0/+9
| | | | | | | | | | | | The behavior has changed since 4.1 and non-array values are no longer type casted to a blank array. This way the user can define custom validations on that property.
* | add table.bigint supportAaron Patterson2014-10-151-0/+19
|/ | | | | | | | In the DSL you can now do: create_table(:foos) do |t| t.bigint :hi end
* Raise an error for has_one associations which try to go :through a ↵Tu Hoang2014-10-152-0/+9
| | | | polymorphic association [#17263]
* :scissors: duplicated `require`sGodfrey Chan2014-10-141-1/+0
|
* make sure cache is not used for collection assocations tooAaron Patterson2014-10-142-1/+13
| | | | follow up for #17052
* break cache if we're inside a "scoping" call. fixes #17052Aaron Patterson2014-10-141-0/+10
| | | | | For now, we don't want to take "scoping" calls in to account when calculating cache keys for relations, so just opt-out.
* measure record instantiation time in AS::NotificationsAaron Patterson2014-10-131-0/+36
| | | | | emit an event when we instantiate AR objects so we can see how many records were instantiated and how long it took
* add length to ActiveRecord::ResultAaron Patterson2014-10-131-0/+4
|
* Merge pull request #17232 from Agis-/issue-17209Rafael Mendonça França2014-10-132-0/+18
|\ | | | | Autosave callbacks shouldn't be `after_save` callbacks
| * Autosave callbacks shouldn't be `after_save`Agis-2014-10-132-0/+18
| | | | | | | | | | | | | | | | | | | | | | | | 068f092ced8483e557725542dd919ab7c516e567 registered autosave callbacks as `after_save` callbacks. This caused the regression described in #17209. Autosave callbacks should be registered as `after_update` and `after_create` callbacks, just like before. This is a partial revert of 068f092ced8483e557725542dd919ab7c516e567. Fixes #17209.
* | Replace Enumerable#reverse.each with Enumerable#reverse_eachErik Michaels-Ober2014-10-131-1/+1
|/
* Merge pull request #17014 from grosser/grosser/fast-fixturesAaron Patterson2014-10-102-32/+0
|\ | | | | speed up fixtures by not loading all their classes
| * speed up fixtures by not loading all their classesgrosser2014-10-062-32/+0
| |
* | ar/connection_pool: honor overriden rack.test in middlewareSimon Eskildsen2014-09-231-0/+8
| | | | | | | | | | | | | | Honoring an overidden `rack.test` allows testing closed connection between multiple requests. This is useful if you're working on database resiliency, to ensure the connection is in the expected state from one request to another on the same worker.
* | add a truncate method to the connectionAaron Patterson2014-09-222-0/+23
|/ | | | | | it doesn't work on SQLite3 since it doesn't support truncate, but that's OK. If you call truncate on the connection, you're now bound to that database (same as if you use hstore or any other db specific feature).
* Better regression test for Fixtures with fk as a symbolArthur Neves2014-09-222-11/+2
|
* fix fixtures not loading if a belongs_to association is defined with a ↵Will Bryant2014-09-221-0/+9
| | | | :foreign_key option that's a symbol
* Fix assertions in AR::TestCase::AttributeMethodsTestYuki Nishijima2014-09-211-3/+3
| | | | | This test has always been green because it uses "assert" and the first argument is an truthy class/object.
* Fix typo [ci skip]Yuki Nishijima2014-09-201-1/+1
|
* Fix find_by with associations not working with adequate recordGodfrey Chan2014-09-201-0/+5
| | | | | | | | | For now, we will just skip the cache when a non-column key is used in the hash. If the future, we can probably move some of the logic in PredicateBuilder.expand up the chain to make caching possible for association queries. Closes #16903 Fixes #16884
* Merge pull request #15791 from zev/add_model_to_recordnotfound_messageAaron Patterson2014-09-191-10/+18
|\ | | | | Update RecordNotFound exception cases to include a message with the
| * Update RecordNotFound exception cases to include a message with theZev Blut2014-06-181-10/+18
| | | | | | | | Model that the Record was not found in.
* | Merge pull request #16875 from alan/dont_autosave_has_one_through_recordRafael Mendonça França2014-09-171-0/+24
|\ \ | | | | | | | | | | | | | | | | | | Don't autosave unchanged has_one through records Conflicts: activerecord/CHANGELOG.md