aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test
Commit message (Collapse)AuthorAgeFilesLines
* Remove unnecessary scopingRyuta Kamizono2017-12-011-1/+1
|
* Class level `update` and `destroy` checks all the records exist before ↵Ryuta Kamizono2017-12-011-4/+37
| | | | | making changes (#31306) It makes more sense than ignoring invalid IDs.
* Maintain raising `RecordNotFound` for class level `update` and` destroy`Ryuta Kamizono2017-12-011-2/+12
| | | | | | | | | | | In 35836019, class level `update` and `destroy` suppressed `RecordNotFound` to ensure returning affected objects. But `RecordNotFound` is a common exception caught by a `rescue_from` handler. So changing the behavior when a typical `params[:id]` is passed has a compatibility problem. The previous behavior should not be changed. Fixes #31301.
* Merge pull request #31214 from ↵Eileen M. Uchitelle2017-11-292-0/+14
|\ | | | | | | | | chopraanmol1/bug_fix_has_one_inverse_owner_reload_from_validation Inverse instance should not be reloaded during autosave if called in validation
| * Inverse instance should not be reloaded during autosave if called in validationAnmol Chopra2017-11-272-0/+14
| | | | | | | | | | Record saved in save_has_one_association already make call to association.loaded! via record's before_save callback of save_belongs_to_association, but this will reload object if accessed in record's validation.
* | Prevent scope named same as a ActiveRecord::Relation instance method.Chen Kinnrot2017-11-282-0/+34
| | | | | | | | | | | | | | | | | | Due to inconsistent behavior when chaining scopes and one scope named after a Relation method Validation code added in 2 places: - scope, to prevent problematic scope names. - enum, cause it tries to auto define scope.
* | Add new error class `QueryCanceled` which will be raised when canceling ↵Ryuta Kamizono2017-11-272-2/+56
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | statement due to user request (#31235) This changes `StatementTimeout` to `QueryCanceled` for PostgreSQL. In MySQL, errno 1317 (`ER_QUERY_INTERRUPTED`) is only used when the query is manually cancelled. But in PostgreSQL, `QUERY_CANCELED` error code (57014) which is used `StatementTimeout` is also used when the both case. And, we can not tell which reason happened. So I decided to introduce new error class `QueryCanceled` closer to the error code name.
* | Rename `TransactionTimeout` to more descriptive `LockWaitTimeout` (#31223)Ryuta Kamizono2017-11-272-4/+4
| | | | | | | | | | | | Since #31129, new error class `StatementTimeout` has been added. `TransactionTimeout` is caused by the timeout shorter than `StatementTimeout`, but its name is too generic. I think that it should be a name that understands the difference with `StatementTimeout`.
* | Revert "Merge pull request #31006 from ↵eileencodes2017-11-261-16/+0
| | | | | | | | | | | | | | | | | | | | | | rails/kamipo/ordinal_methods_should_respect_loaded_records" This reverts commit 0f79ab91150b4cdb6c018530978a3395962c7a02, reversing changes made to d575f7f2e737739302a0e8210d01c10f5d4e2c35. This PR philosophically conflicts with #30800 and Matthew thinks we should hold off merging this until we find concensus. Reverting since we're about to cut a release for 5.2.
* | Merge pull request #31221 from matthewd/flush-idle-connectionsMatthew Draper2017-11-262-0/+53
|\ \ | | | | | | Flush idle database connections
| * | Flush idle database connectionsMatthew Draper2017-11-262-0/+53
| |/
* | Merge pull request #31184 from TheSmartnik/fix_record_not_found_on_reloadRafael França2017-11-252-1/+19
|\ \ | | | | | | Provide arguments to RecordNotFound
| * | Provide arguments to RecordNotFoundNikita Misharin2017-11-252-1/+19
| | |
* | | Merge pull request #31006 from ↵Eileen M. Uchitelle2017-11-251-0/+16
|\ \ \ | | | | | | | | | | | | | | | | rails/kamipo/ordinal_methods_should_respect_loaded_records Ordinal methods should respect loaded records
| * | | Ordinal methods should respect loaded recordsRyuta Kamizono2017-10-281-0/+16
| | | | | | | | | | | | | | | | | | | | | | | | We should reset partially loaded `@offsets` cache when latest records has loaded because the cache has been staled and it may not be consistent with latest records.
* | | | Merge pull request #31173 from matthewd/connection-fork-safetyMatthew Draper2017-11-251-0/+32
|\ \ \ \ | |_|_|/ |/| | | Improve AR connection fork safety
| * | | Improve AR connection fork safetyMatthew Draper2017-11-181-0/+32
| | |/ | |/| | | | | | | | | | | | | Use whatever adapter-provided means we have available to ensure forked children don't send quit/shutdown/goodbye messages to the server on connections that belonged to their parent.
* | | No difference between JRuby and CRuby at ↵Yasuo Honda2017-11-211-6/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | test_read_attributes_before_type_cast_on_a_boolean https://github.com/jruby/activerecord-jdbc-adapter ActiveRecord JDBC Adapter is actively developed and it supports Rails 5.1 now. This pull request addresses one of the failure when running ActiveRecord unit tests with ActiveRecord JDBC Adapter. As of right now, ActiveRecord JDBC Adapter supports Rails 5.1, not master branch then this test only can run on `5-1-stable` branch. But I have opened this pull request to `master` branch since this type cast should be going to work in the future versions of ActiveRecord JDBC Adapter . ```ruby $ ARCONN=jdbcmysql bin/test test/cases/attribute_methods_test.rb:203 Using jdbcmysql Run options: --seed 8874 F Finished in 0.709120s, 1.4102 runs/s, 1.4102 assertions/s. 1) Failure: AttributeMethodsTest#test_read_attributes_before_type_cast_on_a_boolean [/home/yahonda/git/rails/activerecord/test/cases/attribute_methods_test.rb:203]: Expected: "0" Actual: 0 1 runs, 1 assertions, 1 failures, 0 errors, 0 skips $ ```
* | | Merge pull request #28742 from quixoten/stack_conn_poolMatthew Draper2017-11-171-0/+8
|\ \ \ | | | | | | | | Switch to LIFO for the connection pool
| * | | Fix typosDevin Christensen2017-04-131-1/+1
| | | |
| * | | Improve documentation and add testDevin Christensen2017-04-131-0/+8
| | | |
* | | | Merge pull request #28869 from eugeneius/query_cache_all_poolsMatthew Draper2017-11-171-0/+9
|\ \ \ \ | |_|/ / |/| | | Enable query cache on all connection pools
| * | | Enable query cache on all connection poolsEugene Kenny2017-04-241-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | Since the query cache no longer eagerly checks out a connection, we can enable it on all connection pools at the start of every request, and it will only take effect for requests that actually use those pools.
* | | | Allow test_ignored_columns_not_included_in_SELECT column names caseYasuo Honda2017-11-151-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | insensitive i.e. Oracle database identifier is UPPERCASE unlike other databases. ```ruby (byebug) query = Developer.all.to_sql "SELECT \"DEVELOPERS\".\"ID\", \"DEVELOPERS\".\"NAME\", \"DEVELOPERS\".\"SALARY\", \"DEVELOPERS\".\"FIRM_ID\", \"DEVELOPERS\".\"MENTOR_ID\", \"DEVELOPERS\".\"CREATED_AT\", \"DEVELOPERS\".\"UPDATED_AT\", \"DEVELOPERS\".\"CREATED_ON\", \"DEVELOPERS\".\"UPDATED_ON\" FROM \"DEVELOPERS\"" ```
* | | | Fix CI failure due to invalid `up_only` for MySQLRyuta Kamizono2017-11-151-5/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `oldie = 'true'` to `tinyint(1)` column is invalid value for MySQL: ``` Mysql2::Error: Incorrect integer value: 'true' for column 'oldie' at row 1: update horses set oldie = 'true' ```
* | | | Add a #populate method to migrations (#31082)Rich2017-11-141-0/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Add a #populate method to migrations * Address rubocop issues * Rename to #up_only and use #execute in the examples intead of the model * Update CHANGELOG [Rich Daley & Rafael Mendonça França]
* | | | Merge pull request #27947 from mastahyeti/unsafe_raw_sqlMatthew Draper2017-11-146-31/+334
|\ \ \ \ | | | | | | | | | | | | | | | Disallow raw SQL in dangerous AR methods
| * | | | use database agnostic function/quoting in testBen Toews2017-11-091-4/+4
| | | | |
| * | | | push order arg checks down to allow for bindsBen Toews2017-11-091-0/+36
| | | | |
| * | | | deal with Array arguments to #orderBen Toews2017-11-091-3/+3
| | | | |
| * | | | convert order arg to string before checking if we can reverse itBen Toews2017-11-091-2/+2
| | | | |
| * | | | use << instead of #concat in #reverse_sql_order because we might be working ↵Ben Toews2017-11-091-1/+1
| | | | | | | | | | | | | | | | | | | | with Arel SQL literator which overrides #concat
| * | | | try using regexesBen Toews2017-11-0924-106/+99
| | | | |
| * | | | allow table name and direction in string order argBen Toews2017-11-0925-219/+263
| | | | |
| * | | | work around deprecation warnings in a bunch of testsBen Toews2017-11-0934-313/+320
| | | | |
| * | | | remove :enabled optionBen Toews2017-11-091-54/+50
| | | | |
| * | | | make tests more verbose/explicitBen Toews2017-11-091-78/+96
| | | | |
| * | | | allow Arel.sql() for pluckBen Toews2017-11-093-33/+69
| | | | |
| * | | | add config to check arguments to unsafe AR methodsBen Toews2017-11-091-0/+177
| | | | |
* | | | | Properly cast input in `update_all`Sean Griffin2017-11-131-1/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The documentation claims that given values go through "normal AR type casting and serialization", which to me implies `serialize(cast(value))`, not just serialization. The docs were changed to use this wording in #22492. The tests I cited in that PR (which is the same test modified in this commit), is worded in a way that implies it should be using `cast` as well. It's possible that I originally meant "normal type casting" to imply just the call to `serialize`, but given that `update_all(archived: params['archived'])` seems to be pretty common, I'm inclined to make this change as long as no tests are broken from it.
* | | | | Merge pull request #30980 from sobrinho/sobrinho/arel-star-ignored-columnsRafael França2017-11-135-45/+66
|\ \ \ \ \ | | | | | | | | | | | | Do not use `Arel.star` when `ignored_columns`
| * | | | | Fix postgres ordering issue on default scoping testGabriel Sobrinho2017-11-131-15/+15
| | | | | |
| * | | | | Change tests to use models which don't ignore any columnsJon Moss2017-11-133-30/+30
| | | | | |
| * | | | | Do not use `Arel.star` when `ignored_columns`Jon Moss2017-11-131-0/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If there are any ignored columns, we will now list out all columns we want to be returned from the database. Includes a regression test.
* | | | | | Add new error class `StatementTimeout` which will be raised when statement ↵Ryuta Kamizono2017-11-132-0/+57
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | timeout exceeded (#31129) We are sometimes using The MAX_EXECUTION_TIME hint for MySQL depending on the situation. It will prevent catastrophic performance down by wrong performing queries. The new error class `StatementTimeout` will make to be easier to handle that case. https://dev.mysql.com/doc/refman/5.7/en/optimizer-hints.html#optimizer-hints-execution-time
* | | | | | Raise `TransactionTimeout` when lock wait timeout exceeded for PG adapterRyuta Kamizono2017-11-112-1/+30
| | | | | | | | | | | | | | | | | | | | | | | | Follow up of #30360.
* | | | | | Should test actual error which is raised from the databaseRyuta Kamizono2017-11-111-1/+23
| | | | | |
* | | | | | Relation merging should keep joining orderRyuta Kamizono2017-11-111-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `joins_values.partition` will break joins values order. It should be kept as user intended order. Fixes #15488.
* | | | | | Fix random CI failure due to non-deterministic sorting orderRyuta Kamizono2017-11-101-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | https://travis-ci.org/rails/rails/jobs/300163487#L1974
* | | | | | Ensure `apply_join_dependency` for subqueries in `from` and `where`Ryuta Kamizono2017-11-101-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | Fixes #21577.