aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test
Commit message (Collapse)AuthorAgeFilesLines
* Test to swap connection at runtimeArthur Neves2016-05-051-0/+7
|
* fix testArthur Neves2016-05-051-8/+7
|
* Add spec_id testsArthur Neves2016-05-051-0/+9
|
* Use spec key, when given as spec_idArthur Neves2016-05-051-19/+15
|
* Refactor connection handlerArthur Neves2016-05-055-33/+35
| | | | | | | | | | | | | | | ConnectionHandler will not have any knowlodge of AR models now, it will only know about the specs. Like that we can decouple the two, and allow the same model to use more than one connection. Historically, folks used to create abstract AR classes on the fly in order to have multiple connections for the same model, and override the connection methods. With this, now we can override the `specificiation_id` method in the model, to return a key, that will be used to find the connection_pool from the handler.
* Fix some typos in comments.Joe Rafaniello2016-05-042-2/+2
| | | | [ci skip]
* Followup of #24835Vipul A M2016-05-033-5/+5
| | | | Fix failing tests
* Do not delegate `AR::Base#empty?` to `all`Sean Griffin2016-05-021-6/+0
| | | | | | | | | | Unlike `one?` and `none?`, `empty?` has interactions with methods outside of enumerable. It also doesn't fit in the same vein. `Topic.any?` makes sense. `Topic.empty?` does not, as `Topic` is not a container. Fixes #24808 Close #24812
* Merge pull request #24713 from tomkadwill/fix_counter_cache_incrementSean Griffin2016-04-301-0/+11
|\ | | | | | | | | Fix counter_cache double increment bug Close #24183
| * Fix counter_cache double increment bugTom Kadwill2016-04-281-0/+11
| |
* | Replace `Rails.version.to_f` with Active RecordJon Moss2016-04-301-0/+4
| | | | | | | | | | Rails should not be explicity mentioned within Active Record, since railties and the Rails ecosystem is not required for use.
* | rm unused requireVipul A M2016-04-291-1/+0
| | | | | | | | Signed-off-by: Jeremy Daer <jeremydaer@gmail.com>
* | Extract `add_sql_comment!` methodRyuta Kamizono2016-04-291-3/+3
| | | | | | | | | | | | Refactor of #22911. Signed-off-by: Jeremy Daer <jeremydaer@gmail.com>
* | Treat blank comments as no comment for indexesRyuta Kamizono2016-04-291-1/+10
| | | | | | | | | | | | Follow up of 1683410. Signed-off-by: Jeremy Daer <jeremydaer@gmail.com>
* | test the number of times the schema is loadingKeenan Brock2016-04-281-0/+53
|/
* Dont simply assume a type is a valid database type. This is only always true ↵Vipul A M2016-04-251-0/+11
| | | | | | | in the case of sqlite. Others adapters need to perform a check for validity. Add coverage for mysql2 db type validation
* Add Expression Indexes and Operator Classes support for PostgreSQLRyuta Kamizono2016-04-245-20/+53
| | | | | | | | | | | | | | | | Example: create_table :users do |t| t.string :name t.index 'lower(name) varchar_pattern_ops' end Fixes #19090. Fixes #21765. Fixes #21819. Fixes #24359. Signed-off-by: Jeremy Daer <jeremydaer@gmail.com>
* remove_index do not fetch indexes if name is specifiedSeva Orlov2016-04-242-0/+16
| | | | | | There is no need to fetch all table indexes in remove_index if name is specified. If name is wrong, then StatementInvalid will be raised. Signed-off-by: Jeremy Daer <jeremydaer@gmail.com>
* Followup of #15771Vipul A M2016-04-241-0/+6
| | | | | | | | | Make sure we handle explicitly passed nil's to lock_version as well. An explicitly passed nil value is now converted to 0 on LockingType, so that we don't end up with ActiveRecord::StaleObjectError in update record optimistic locking Fixes #24695
* Merge pull request #24685 from vipulnsward/sqlite-compat-for-multi-insertJeremy Daer2016-04-221-0/+18
|\ | | | | | | Gracefully fallback on version migrations for sqlite < 3.7.11
| * https://github.com/rails/rails/commit/42dd2336b31a8d98776d039a2b9fd7f834156a ↵Vipul A M2016-04-231-0/+18
| | | | | | | | | | | | | | | | | | 78 changed INSERT INTO versions to run in 1 single query. This breaks for sqlite versions < 3.7.11, which is especially the case on Ubuntu 12.04 LTS, that has SQLite version 3.7.9 as default. So we check for support for multi insert, before performing single query inserts, else fallback to older version of running multiple queries. [Vipul A M & Yasuo Honda]
* | Do not attempt to return connection with open transaction to pool (#24610)Sean Griffin2016-04-221-5/+7
|/ | | | | | | | | | | | | When the query cache completes, if Active Record is still inside of a transaction, it is because the transaction is meant to be left open above this unit of work (such as transactional fixtures in tests). There were several tests around the behavior of "tests" that were invalid, as tests are not run through the executor. They have been changed to reflect the new behavior, which is closer to what actually occurs in Rails tests. Fixes #23989 Fixes #24491 Close #24500
* Merge pull request #24221 from gregmolnar/uuidKasper Timm Hansen2016-04-201-0/+7
|\ | | | | create_join_table should work with uuid
| * add column type option to create_join_table to support uuidGreg Molnar2016-03-171-0/+7
| |
* | Dump indexes in `create_table` for generates SQL in one queryRyuta Kamizono2016-04-202-12/+12
| | | | | | | | | | If the adapter supports indexes in create table, it generates SQL in one query.
* | Remove unecessary commentJon Moss2016-04-191-1/+1
| |
* | Database comments: Treat blank comments as no comment. Don't dump blank ↵Jeremy Daer2016-04-191-55/+96
| | | | | | | | comments.
* | Remove unused `table_with_autoincrement` tableRyuta Kamizono2016-04-191-4/+0
| |
* | Merge pull request #24503 from ↵Jeremy Daer2016-04-191-11/+23
|\ \ | | | | | | | | | | | | | | | prathamesh-sonpatki/add-test-for-warn-on-records-fetched-greater-than Add missing test case for record_fetched_greater_than config
| * | Add missing test case for record_fetched_greater_than configPrathamesh Sonpatki2016-04-111-11/+23
| | | | | | | | | | | | - The negative scenario test case was missing earlier.
* | | Merge pull request #23523 from kamipo/avoid_truncation_in_uniqueness_validationJeremy Daer2016-04-181-10/+32
|\ \ \ | | | | | | | | | | | | Avoid a string value truncation in uniqueness validation
| * | | Avoid a string value truncation in uniqueness validationRyuta Kamizono2016-02-121-10/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In MySQL, PostgreSQL, Oracle and SQLServer, a value over the limit cannot be inserted or updated (See #23522). In SQLite3, a value is inserted or updated regardless of the limit. We should avoid a string value truncation in uniqueness validation.
* | | | Merge pull request #23522 from kamipo/add_value_too_long_exception_classJeremy Daer2016-04-181-0/+9
|\ \ \ \ | | | | | | | | | | | | | | | Add `ActiveRecord::ValueTooLong` exception class
| * | | | Add `ActiveRecord::ValueTooLong` exception classRyuta Kamizono2016-02-061-0/+9
| | | | |
* | | | | `foreign_key` respects `table_name_prefix` and `table_name_suffix`Ryuta Kamizono2016-04-192-2/+32
| | | | |
* | | | | Merge pull request #23622 from kamipo/primary_key_should_be_not_nullJeremy Daer2016-04-181-1/+1
|\ \ \ \ \ | | | | | | | | | | | | | | | | | | Primary key should be `NOT NULL`
| * | | | | Primary key should be `NOT NULL`Ryuta Kamizono2016-03-121-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Follow up to #18228. In MySQL and PostgreSQL, primary key is to be `NOT NULL` implicitly. But in SQLite it must be specified `NOT NULL` explicitly.
* | | | | | Fix isolated test failures due to referencing ↵Jeremy Daer2016-04-183-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | ActiveRecord::Tasks::DatabaseAlreadyExists before another test happened to make it available
* | | | | | Database comments: switch to keyword args for new table optionsJeremy Daer2016-04-181-3/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Switch to keyword args where we can without breaking compat. * Use add_table_options! for :options, too. * Some code polish.
* | | | | | Merge pull request #24581 from vipulnsward/add-reference-named-unique-index-testYves Senn2016-04-181-0/+5
|\ \ \ \ \ \ | | | | | | | | | | | | | | Add test to verify named unique index, when creating reference via add_reference
| * | | | | | Add test to verify named unique index, when creating reference via add_referenceVipul A M2016-04-161-0/+5
| | | | | | |
* | | | | | | Merge pull request #24551 from bogdanvlviv/notice_for_tasksJeremy Daer2016-04-174-10/+100
|\ \ \ \ \ \ \ | | | | | | | | | | | | | | | | Added notice when a database is successfully created or dropped.
| * | | | | | | Added notice when a database is successfully created or dropped.bogdanvlviv2016-04-174-10/+100
| | | | | | | |
* | | | | | | | Add support for specifying comments for tables, columns, and indexes.Andrey Novikov2016-04-161-0/+91
| |/ / / / / / |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Comments are specified in migrations, stored in database itself (in its schema), and dumped into db/schema.rb file. This allows to generate good documentation and explain columns and tables' purpose to everyone from new developers to database administrators. For PostgreSQL and MySQL only. SQLite does not support comments at the moment. See docs for PostgreSQL: http://www.postgresql.org/docs/current/static/sql-comment.html See docs for MySQL: http://dev.mysql.com/doc/refman/5.7/en/create-table.html
* | | | | | | Should keep quoting behaivor of a time column value in sqlite3 adapterRyuta Kamizono2016-04-151-3/+8
|/ / / / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Follow up to #24542. In MySQL and PostgreSQL, a time column value is saved as ignored the date part of it. But in SQLite3, a time column value is saved as a string. We should keep previous quoting behavior in sqlite3 adapter. ``` sqlite> CREATE TABLE "foos" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "start" time(0), "finish" time(4)); sqlite> INSERT INTO "foos" ("start", "finish") VALUES ('2000-01-01 12:30:00', '2000-01-01 12:30:00.999900'); sqlite> SELECT "foos".* FROM "foos"; 1|2000-01-01 12:30:00|2000-01-01 12:30:00.999900 sqlite> SELECT "foos".* FROM "foos" WHERE "foos"."start" = '2000-01-01 12:30:00' LIMIT 1; 1|2000-01-01 12:30:00|2000-01-01 12:30:00.999900 sqlite> SELECT "foos".* FROM "foos" WHERE "foos"."start" = '12:30:00' LIMIT 1; sqlite> ```
* | | | | | Add `quoted_time` for truncating the date part of a time column valueRyuta Kamizono2016-04-141-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Context #24522. TIME column on MariaDB doesn't ignore the date part of the string when it coerces to time. ``` root@localhost [test] > CREATE TABLE `foos` (`id` int AUTO_INCREMENT PRIMARY KEY, `start` time(0), `finish` time(4)) ENGINE=InnoDB; Query OK, 0 rows affected (0.02 sec) root@localhost [test] > INSERT INTO `foos` (`start`, `finish`) VALUES ('2000-01-01 12:30:00', '2000-01-01 12:30:00.999900'); Query OK, 1 row affected, 2 warnings (0.00 sec) Note (Code 1265): Data truncated for column 'start' at row 1 Note (Code 1265): Data truncated for column 'finish' at row 1 root@localhost [test] > SELECT `foos`.* FROM `foos`; +----+----------+---------------+ | id | start | finish | +----+----------+---------------+ | 1 | 12:30:00 | 12:30:00.9999 | +----+----------+---------------+ 1 row in set (0.00 sec) root@localhost [test] > SELECT `foos`.* FROM `foos` WHERE `foos`.`start` = '2000-01-01 12:30:00' LIMIT 1; Empty set (0.00 sec) root@localhost [test] > SELECT `foos`.* FROM `foos` WHERE `foos`.`start` = '12:30:00' LIMIT 1; +----+----------+---------------+ | id | start | finish | +----+----------+---------------+ | 1 | 12:30:00 | 12:30:00.9999 | +----+----------+---------------+ 1 row in set (0.00 sec) ```
* | | | | | Merge pull request #24522 from vipulnsward/run-mariadb-on-travisJeremy Daer2016-04-131-0/+1
|\ \ \ \ \ \ | | | | | | | | | | | | | | Test against MariaDB 10.0
| * | | | | | Include running mariadb on travisVipul A M2016-04-141-0/+1
| | |_|_|/ / | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Specify we want to run on latest stable ruby for mariadb - change in runs of builds Make mariadb? method publicly available
* | | | | | Properly serialize all JSON primitives in the AR JSON typeSean Griffin2016-04-132-9/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously we were assuming that the only valid types for encoding were arrays and hashes. However, any JSON primitive is an accepted value by both PG and MySQL. This does involve a minor breaking change in the handling of `default` in the schema dumper. This is easily worked around, as passing a hash/array literal would have worked fine in previous versions of Rails. However, because of this, I will not be backporting this to 4.2 or earlier. Fixes #24234
* | | | | | Merge pull request #24515 from Sen-Zhang/attribute_changed_not_return_nilSean Griffin2016-04-121-2/+2
|\ \ \ \ \ \ | | | | | | | | | | | | | | prevent 'attribute_changed?' from returning nil