aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test
Commit message (Collapse)AuthorAgeFilesLines
* Add tests for sanitize named bind arityyui-knk2015-09-231-3/+9
|
* Merge pull request #21715 from rails/introduce_data_sourcesYves Senn2015-09-226-7/+35
|\ | | | | introduce `conn.data_source_exists?` and `conn.data_sources`.
| * introduce `conn.data_source_exists?` and `conn.data_sources`.Yves Senn2015-09-226-7/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | These new methods are used from the Active Record model layer to determine which relations are viable to back a model. These new methods allow us to change `conn.tables` in the future to only return tables and no views. Same for `conn.table_exists?`. The goal is to provide the following introspection methods on the connection: * `tables` * `table_exists?` * `views` * `view_exists?` * `data_sources` (views + tables) * `data_source_exists?` (views + tables)
* | tests, use `if_exists: true` instead of `rescue nil`.Yves Senn2015-09-221-1/+1
|/
* fix `bin/test -a sqlite3_mem`.Yves Senn2015-09-221-19/+13
| | | | | | | | | | | | We should not run MysqlAdapter tests when running with `sqlite3_mem`. This also moves the test-case outside the MysqlAdapter namespace. This will prevent the following error when running everything: ``` 1) Error: TestAdapterWithInvalidConnection#test_inspect_on_Model_class_does_not_raise: TypeError: superclass mismatch for class MysqlAdapter ```
* Merge pull request #20569 from theSteveMitchell/masterYves Senn2015-09-221-6/+8
|\ | | | | | | Check mysql structure_load for errors
| * Check response of structure_load for mysql_database_tasks and make ↵Steve Mitchell2015-09-181-3/+16
| | | | | | | | structure_dump consistent
* | Eliminate `test_tables_quoting` following seems to be left in #21687Ronak Jangir2015-09-211-8/+0
| |
* | Skip the test added in 9cc324a on buggy versions of SQliteSean Griffin2015-09-212-17/+22
| | | | | | | | See 7dcfc25e7c52682a4343c2ba7188a69e7c06c936 for more details
* | Ensure aliased attributes passed to `select` are quoted if using `from`Sean Griffin2015-09-212-0/+14
| | | | | | | | | | | | Fixes #21488 [Sean Griffin & johanlunds]
* | Move the appropriate type tests to the Active Model suiteSean Griffin2015-09-215-292/+0
| | | | | | | | | | | | | | | | | | Any tests for a type which is not overridden by Active Record, and does not test the specifics of the attributes API interacting in more complex ways have no reason to be in the Active Record suite. Doing this revealed that the implementation of the date and time types in AM was actually completely broken, and incapable of returning any value other than `nil`.
* | Merge pull request #20009 from kamipo/foreign_keys_in_createJeremy Daer2015-09-201-0/+8
|\ \ | | | | | | Support for foreign keys in create table
| * | Support for foreign keys in create tableRyuta Kamizono2015-09-201-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If foreign keys specified in create table, generated SQL is slightly more efficient. Definition: ``` create_table :testings do |t| t.references :testing_parent, foreign_key: true end ``` Before: ``` CREATE TABLE "testings" ("id" serial primary key, "testing_parent_id" integer); ALTER TABLE "testings" ADD CONSTRAINT "fk_rails_a196c353b2" FOREIGN KEY ("testing_parent_id") REFERENCES "testing_parents" ("id"); ``` After: ``` CREATE TABLE "testings" ("id" serial primary key, "testing_parent_id" integer, CONSTRAINT "fk_rails_a196c353b2" FOREIGN KEY ("testing_parent_id") REFERENCES "testing_parents" ("id")); ```
* | | Merge pull request #21687 from kamipo/refactor_table_existsAndrew White2015-09-202-9/+1
|\ \ \ | | | | | | | | Refactor `table_exists?` in AbstractMysqlAdapter
| * | | Refactor `table_exists?` in AbstractMysqlAdapterRyuta Kamizono2015-09-202-9/+1
| |/ / | | | | | | | | | | | | | | | `table_exists?` calls `tables` twice when passed `'dbname.tblname'` arg. This change is that `table_exists?` execute only once query always and extra args of `tables` is removed.
* | | :hocho: TyposAkira Matsuda2015-09-211-1/+1
| | |
* | | :scissors: empty line at the top of filesAkira Matsuda2015-09-212-2/+0
|/ /
* | Merge pull request #17696 from kamipo/unsigned_integer_supportJeremy Daer2015-09-193-5/+76
|\ \ | | | | | | | | | Add `unsigned` support for numeric data types in MySQL
| * | Add `unsigned` types for numeric data types in MySQLRyuta Kamizono2015-09-182-0/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In the case of using `unsigned` as the type: create_table :foos do |t| t.unsigned_integer :unsigned_integer t.unsigned_bigint :unsigned_bigint t.unsigned_float :unsigned_float t.unsigned_decimal :unsigned_decimal, precision: 10, scale: 2 end
| * | Add `unsigned` support for numeric data types in MySQLRyuta Kamizono2015-09-183-5/+50
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Example: create_table :foos do |t| t.integer :unsigned_integer, unsigned: true t.bigint :unsigned_bigint, unsigned: true t.float :unsigned_float, unsigned: true t.decimal :unsigned_decimal, unsigned: true, precision: 10, scale: 2 end
* | | Merge pull request #19086 from kamipo/move_explain_into_abstract_mysql_adapterJeremy Daer2015-09-191-0/+27
|\ \ \ | | | | | | | | | | | | Move `explain` into `AbstractMysqlAdapter`
| * | | Move `explain` into `AbstractMysqlAdapter`Ryuta Kamizono2015-03-011-0/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Common methods in both mysql adapters are should be added to `AbstractMysqlAdapter`, but some methods had been added to `Mysql2Adapter`. (8744632f, 0306f82e, #14359) Some methods already moved from `Mysql2Adapter` to `AbstractMysqlAdapter`. (#17601, #17998) Common methods in both mysql adapters are remaining only the `explain` method in `Mysql2Adapter`.
* | | | Merge pull request #20645 from kamipo/fix_mysql_set_type_bugJeremy Daer2015-09-191-0/+4
|\ \ \ \ | | | | | | | | | | Fix undesired type lookup with `SET` in MySQL
| * | | | Fix the MySQL column type `SET` registration bugTaishi Kasuga2015-06-201-0/+4
| | | | |
* | | | | Merge pull request #21609 from kamipo/do_not_dump_view_as_tableJeremy Daer2015-09-191-0/+31
|\ \ \ \ \ | | | | | | | | | | | | | | | | | | Do not dump a view as a table in sqlite3, mysql and mysql2 adapters
| * | | | | Do not dump a view as a table in sqlite3, mysql and mysql2 adaptersRyuta Kamizono2015-09-131-0/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Now in sqlite3, mysql and mysql2 adapters, SchemaDumper dump a view as a table. It is incorrect behavior. This change excludes a view in schema.rb.
| * | | | | Add `#views` and `#view_exists?` methods on connection adaptersRyuta Kamizono2015-09-131-0/+18
| | |_|_|/ | |/| | |
* | | | | Merge pull request #21607 from kamipo/remove_unnecessary_display_widthJeremy Daer2015-09-192-5/+5
|\ \ \ \ \ | | | | | | | | | | | | Remove unnecessary display width
| * | | | | Remove unnecessary display widthRyuta Kamizono2015-09-162-5/+5
| |/ / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The **(11)** does not affect the storage size of the data type, which for an INT will always be 4 bytes. It affects the **display width**. http://www.tocker.ca/2015/07/02/proposal-to-deprecate-mysql-integer-display-width-and-zerofill.html
* | | | | Merge pull request #21681 from kamipo/should_test_both_mysql_adaptersJeremy Daer2015-09-194-22/+18
|\ \ \ \ \ | | | | | | | | | | | | Should test both mysql adapters
| * | | | | Should test both mysql adaptersRyuta Kamizono2015-09-204-22/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Some test cases are testing only mysql adapter. We should test mysql2 adapter also.
* | | | | | Merge pull request #21614 from kamipo/correctly_dump_composite_primary_keyJeremy Daer (Kemper)2015-09-192-1/+28
|\ \ \ \ \ \ | |/ / / / / |/| | | | | Correctly dump composite primary key
| * | | | | Correctly dump composite primary keyRyuta Kamizono2015-09-202-1/+28
| | |_|_|/ | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Example: create_table :barcodes, primary_key: ["region", "code"] do |t| t.string :region t.integer :code end
* / | | | Remove `@connection` in `StatementPool`Ryuta Kamizono2015-09-202-2/+2
|/ / / / | | | | | | | | | | | | | | | | `@connection` in `StatementPool` is only used for PG adapter. No need for abstract `StatementPool` class.
* | | | File encoding is defaulted to utf-8 in Ruby >= 2.1Akira Matsuda2015-09-183-4/+0
| | | |
* | | | Merge pull request #21581 from ronakjangir47/restrict_with_errorYves Senn2015-09-172-0/+37
|\ \ \ \ | | | | | | | | | | | | | | | `restrict_with_error` message will now respect owner’s human name
| * | | | `restrict_with_error` message will now respect owner’s human name in any ↵Ronak Jangir2015-09-122-0/+37
| |/ / / | | | | | | | | | | | | locale [kuboon & Ronak Jangir]
* / / / Removed mocha from Active Record Part 2Ronak Jangir2015-09-168-58/+85
|/ / /
* | | remove dead code.Yves Senn2015-09-091-3/+1
| | | | | | | | | | | | | | | | | | The last call site of `last_version` was removed with: 838e18321118ee3ec6669217e5ea0216f79c969a
* | | Merge pull request #21486 from bogdan/refactor-has-many-counter-cacheEileen M. Uchitelle2015-09-091-1/+1
|\ \ \ | | | | | | | | HasManyAssociation: moved half of counter cache code to reflection
| * | | HasManyAssociation: moved half of counter cache code to reflectionBogdan Gusiev2015-09-031-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Current implementation has a lot of utility methods that accept reflection call a lot of methods on it and exit. E.g. has_counter_cache?(reflection) It causes confusion and inability to cache result of the method even through it always returns the same result for the same reflection object. It can be done easier without access to the association context by moving code into reflection itself. e.g. reflection.has_counter_cache? Reflection is less complex object than association so moving code there automatically makes it simplier to understand.
* | | | Revert "Merge pull request #20080 from ↵Rafael Mendonça França2015-09-092-21/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | robertjlooby/fix_overwriting_by_dynamic_finders" This reverts commit d5ba9a42a6e93b163a49f99d739aa56820e044d0, reversing changes made to 30c503395bf6bf7db1ec0295bd661ce644628db5. Reason: This generate the dynalic finders more than one time
* | | | Merge pull request #20080 from robertjlooby/fix_overwriting_by_dynamic_findersRafael Mendonça França2015-09-092-0/+21
|\ \ \ \ | | | | | | | | | | | | | | | put dynamic matchers on GeneratedAssociationMethods instead of model
| * | | | put dynamic matchers on the GeneratedAssociationMethods instead of modelRob Looby2015-05-082-0/+21
| | | | |
* | | | | Merge pull request #20921 from pboling/fix-sql-colors-in-log-subscriberRafael Mendonça França2015-09-091-0/+98
|\ \ \ \ \ | | | | | | | | | | | | | | | | | | Fix and Improve sql logging coloration in `ActiveRecord::LogSubscriber`.
| * | | | | Improve sql logging coloration in `ActiveRecord::LogSubscriber`.Peter Boling2015-07-171-0/+98
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Improves coloring for statements like: # Become WHITE SELECT * FROM ( SELECT * FROM mytable FOR UPDATE ) ss WHERE col1 = 5; LOCK TABLE table_name IN ACCESS EXCLUSIVE MODE; # Becomes RED ROLLBACK - Reinstates the coloration of the `payload[:name]`. Instead of simple alternating colors, adds meaning: - `MAGENTA` for `"SQL"` or `blank?` payload names - `CYAN` for Model Load/Exists - Introduces specs for sql coloration. - Introduces specs for payload name coloration. GH#20885
* | | | | | Merge pull request #21535 from dmitry/feature/validate-multiple-contextsRafael Mendonça França2015-09-081-0/+7
|\ \ \ \ \ \ | | | | | | | | | | | | | | Validate multiple contexts on `valid?` and `invalid?` at once
| * | | | | | Validate multiple contexts on `valid?` and `invalid?` at once.Dmitry Polushkin2015-09-071-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Example: ```ruby class Person include ActiveModel::Validations attr_reader :name, :title validates_presence_of :name, on: :create validates_presence_of :title, on: :update end person = Person.new person.valid?([:create, :update]) # => true person.errors.messages # => {:name=>["can't be blank"], :title=>["can't be blank"]} ```
* | | | | | | Merge pull request #21511 from rwz/ar-exceptions-no-argsEileen M. Uchitelle2015-09-081-0/+16
|\ \ \ \ \ \ \ | | | | | | | | | | | | | | | | Removes mandatory arguments from AR exceptions
| * | | | | | | Make ActiveRecordException descendants args optionalPavel Pravosud2015-09-071-0/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This change allows to instantiate all ActiveRecordError descendant execption classes without arguments, which might be useful in testing and is far less surprising than mandatory arguments.