aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test
Commit message (Collapse)AuthorAgeFilesLines
...
* | | Build fix when running in isolationArun Agrawal2014-11-1430-0/+31
| | | | | | | | | | | | | | | `Computer` class needs to be require See #17217 for more details
* | | add a Table#name accessor like TableDefinition#nameCody Cutrer2014-11-101-0/+6
| | |
* | | Merge pull request #17578 from codeodor/fix-17217-test-bugRafael Mendonça França2014-11-101-1/+1
|\ \ \ | | | | | | | | Fix bug found when running individual tests against #17217 after merging
| * | | Fixes a bug found when running individual tests against #17217 after mergingSammy Larbi2014-11-101-1/+1
| |/ /
* | | Merge pull request #11694 from ↵Rafael Mendonça França2014-11-101-0/+7
|\ \ \ | |/ / |/| | | | | | | | | | | | | | | | | | | | Empact/association-bind-values-not-updated-on-save Fix that a collection proxy could be cached before the save of the owner, resulting in an invalid proxy lacking the owner’s id Conflicts: activerecord/CHANGELOG.md
| * | Fix that a collection proxy could be cached before the save of the owner, ↵Ben Woosley2014-10-031-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | resulting in an invalid proxy lacking the owner’s id. Absent this fix calls like: owner.association.update_all to behave unexpectedly because they try to act on association objects where owner_id is null. more evidence here: https://gist.github.com/Empact/5865555 ``` Active Record 3.2.13 -- create_table(:firms, {:force=>true}) -> 0.1371s -- create_table(:clients, {:force=>true}) -> 0.0005s 1 clients. 1 expected. 1 clients updated. 1 expected. ``` ``` Active Record 4.0.0 -- create_table(:firms, {:force=>true}) -> 0.1606s -- create_table(:clients, {:force=>true}) -> 0.0004s 1 clients. 1 expected. 0 clients updated. 1 expected. ```
* | | Revert the behavior of booleans in string columns to that of 4.1Sean Griffin2014-11-091-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Why are people assigning booleans to string columns? >_> We unintentionally changed the behavior on Sqlite3 and PostgreSQL. Boolean values should cast to the database's representation of true and false. This is 't' and 'f' by default, and "1" and "0" on Mysql. The implementation to make the connection adapter specific behavior is hacky at best, and should be re-visted once we decide how we actually want to separate the concerns related to things that should change based on the database adapter. That said, this isn't something I'd expect to change based on my database adapter. We're storing a string, so the way the database represents a boolean should be irrelevant. It also seems strange for us to give booleans special behavior at all in string columns. Why is `to_s` not sufficient? It's inconsistent and confusing. Perhaps we should consider deprecating in the future. Fixes #17571
* | | Ensure HABTM relationships produce valid class names (Fixes #17119)Sammy Larbi2014-11-095-1/+23
| | |
* | | default scopes should break the cache on singulur_association.alfa-jpn2014-11-081-0/+29
| | | | | | | | | | | | fixes #17495
* | | default scopes should break the cache on has_many.Aaron Patterson2014-11-071-0/+26
| | | | | | | | | | | | | | | | | | if you specify a default scope on a model, it will break caching. We cannot predict what will happen inside the scope, so play it safe for now. fixes #17495
* | | pg tests, get rid of `sql_types_test.rb`.Yves Senn2014-11-073-18/+14
| | |
* | | pg tests, only execute what's necessary.Yves Senn2014-11-072-27/+26
| | |
* | | remove the last traces of OpenBase from our codebase. [ci skip]Yves Senn2014-11-071-6/+0
| | |
* | | Merge pull request #17541 from OpenSourceProjects/meaninful_messageYves Senn2014-11-071-3/+9
|\ \ \ | | | | | | | | | | | | Print out a meaningful error when ActiveRecord::ReadOnlyRecord is raised
| * | | Print out a meaningful error when ActiveRecord::ReadOnlyRecord is raisedFranky W2014-11-061-3/+6
|/ / / | | | | | | | | | | | | | | | | | | Currently, there is no messages which get printed out. Convoluted system may have hooks that create other objects in which case we only fail with no messages. This commit changes this information allowing you to know which object is the one that actually raised the error.
* | | tests, remove unneeded requires.Yves Senn2014-11-064-11/+0
| | |
* | | tests, use SchemaDumpingHelper to dump a specific table.Yves Senn2014-11-061-12/+12
| | | | | | | | | | | | | | | This makes debugging the generated schema output much easier. As a side effect it also shaves off 2.5 seconds of test runtime.
* | | Merge pull request #17360 from bronzle/includes_and_unscopedYves Senn2014-11-051-0/+8
|\ \ \ | | | | | | | | | | | | copy reflection_scopes’s unscoped value when building scope for preloading
| * | | copy reflection_scopes’s unscoped value when building scope for ↵Byron Bischoff2014-10-221-0/+8
| | | | | | | | | | | | | | | | preloading, fixes #11036
* | | | Added SchemaDumper support for tables with jsonb columns.Ted O'Meara2014-11-043-18/+12
| | | |
* | | | Add an `assert_deprecated` for `sanitize_sql_hash_for_conditions`Sean Griffin2014-11-021-1/+3
| | | |
* | | | Handle `RangeError` from casting in `find_by` and `find_by!` on RelationSean Griffin2014-11-021-0/+10
| |_|/ |/| | | | | | | | | | | We should not behave differently just because a class has a default scope.
* | | Add a test case for range type castingSean Griffin2014-11-011-0/+4
| | | | | | | | | | | | | | | We support this behavior, but have no tests which assert that type casting actually occurs.
* | | Fix test which failed in isolationSean Griffin2014-11-011-0/+1
| | | | | | | | | | | | It was transitively relying on the vertex model being loaded
* | | Use bind values for joined tables in where statementsSean Griffin2014-11-014-0/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In practical terms, this allows serialized columns and tz aware columns to be used in wheres that go through joins, where they previously would not behave correctly. Internally, this removes 1/3 of the cases where we rely on Arel to perform type casting for us. There were two non-obvious changes required for this. `update_all` on relation was merging its bind values with arel's in the wrong order. Additionally, through associations were assuming there would be no bind parameters in the preloader (presumably because the where would always be part of a join) [Melanie Gilman & Sean Griffin]
* | | 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 ```