aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/adapter_test.rb
Commit message (Collapse)AuthorAgeFilesLines
* Merge pull request #27939 from kamipo/fix_select_all_with_legacy_bindsRafael França2017-03-201-0/+9
|\ | | | | Fix `select_all` with legacy `binds`
| * Fix `select_all` with legacy `binds`Ryuta Kamizono2017-02-121-0/+9
| | | | | | | | Fixes #27923.
* | `valid_type?` should accept only supported typesRyuta Kamizono2017-02-281-0/+10
|/ | | | | | | | | | | | | | | | | | | | `valid_type?` is used in schema dumper to determine if a type is supported. So if `valid_type?(:foobar)` is true, it means that schema dumper is allowed to create `t.foobar`. But it doesn't work. I think that `valid_type?` should accept only supported types. https://github.com/rails/rails/blob/v5.1.0.beta1/activerecord/lib/active_record/schema_dumper.rb#L135-L142 ```ruby columns.each do |column| raise StandardError, "Unknown type '#{column.sql_type}' for column '#{column.name}'" unless @connection.valid_type?(column.type) next if column.name == pk type, colspec = @connection.column_spec(column) tbl.print " t.#{type} #{column.name.inspect}" tbl.print ", #{format_colspec(colspec)}" if colspec.present? tbl.puts end ```
* `primary_key` and `references` columns should be identical typeRyuta Kamizono2017-02-071-1/+1
| | | | | | | | Follow up to #26266. The default type of `primary_key` and `references` were changed to `bigint` since #26266. But legacy migration and sqlite3 adapter should keep its previous behavior.
* Merge pull request #27700 from kenta-s/remove-meaningless-line-from-adapter-testAndrew White2017-01-171-1/+0
|\ | | | | Remove meaningless line from adapter_test.rb
| * Remove meaningless line from adapter_test.rbkenta-s2017-01-161-1/+0
| |
* | Translate Foreign Key violation to the specific exception for SQLite3 adapterRyuta Kamizono2017-01-161-45/+53
|/ | | | | | Raise `ActiveRecord::InvalidForeignKey` when a record cannot be inserted or updated because it references a non-existent record for SQLite3 adapter.
* Revert "Merge pull request #21233 from ↵Rafael Mendonça França2017-01-031-17/+17
| | | | | | | | | | mtsmfm/disable-referential-integrity-without-superuser-privileges" This reverts commit eeac6151a55cb7d5f799e1ae33aa64a839cbc3aa, reversing changes made to 5c40239d3104543e70508360d27584a3e4dc5baf. Reason: Broke the isolated tests. https://travis-ci.org/rails/rails/builds/188721346
* Merge pull request #21233 from ↵Rafael França2017-01-031-17/+17
|\ | | | | | | | | mtsmfm/disable-referential-integrity-without-superuser-privileges Use `SET CONSTRAINTS` for `disable_referential_integrity` without superuser privileges
| * Use `SET CONSTRAINTS` for `disable_referential_integrity` without superuser ↵Fumiaki MATSUSHIMA2016-12-031-17/+17
| | | | | | | | | | | | | | | | | | privileges ref: 72c1557254 - We must use `authors` fixture with `author_addresses` because of its foreign key constraint. - Tests require PostgreSQL >= 9.4.2 because it had a bug about `ALTER CONSTRAINTS` and fixed in 9.4.2.
* | `#tables` and `#table_exists?` and returns only tables and not viewsRafael Mendonça França2016-12-291-18/+6
| |
* | Remove deprecated `name` argument from `#tables`Rafael Mendonça França2016-12-291-4/+0
| |
* | fix QueryCache nil dupRichard Monette2016-12-151-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | make sql statements frozen dup if arel is not our string expect runtime error dont wrap runtime error in invalid log errors will now be treated as runtime errors update changelog
* | Translate numeric value out of range to the specific exceptionRyuta Kamizono2016-12-061-0/+8
| | | | | | | | Raise `ActiveRecord::RangeError` when values that executed are out of range.
* | Translate NOT NULL violation to the specific exceptionRyuta Kamizono2016-12-061-0/+8
|/ | | | | Raise `ActiveRecord::NotNullViolation` when a record cannot be inserted or updated because it would violate a not null constraint.
* Merge pull request #26688 from kamipo/remove_respond_to_indexesKasper Timm Hansen2016-10-281-14/+9
|\ | | | | Remove unnecessary `respond_to?(:indexes)` checking
| * Remove unnecessary `respond_to?(:indexes)` checkingRyuta Kamizono2016-10-031-14/+9
| | | | | | | | | | | | | | | | | | | | Currently all adapters (postgresql, mysql2, sqlite3, oracle-enhanced, and sqlserver) implemented `indexes` and schema dumper expects implemented `indexes`. https://github.com/rails/rails/blob/v5.0.0/activerecord/lib/active_record/schema_dumper.rb#L208 Therefore `respond_to?(:indexes)` checking is unnecessary.
* | Quote table name properlyRyuta Kamizono2016-10-141-2/+5
|/ | | | If does not quote table name properly, invalid SQL is generated.
* improve error message when include assertions failMichael Grosser2016-09-161-8/+8
| | | | | | assert [1, 3].includes?(2) fails with unhelpful "Asserting failed" message assert_includes [1, 3], 2 fails with "Expected [1, 3] to include 2" which makes it easier to debug and more obvious what went wrong
* Add three new rubocop rulesRafael Mendonça França2016-08-161-4/+4
| | | | | | | | Style/SpaceBeforeBlockBraces Style/SpaceInsideBlockBraces Style/SpaceInsideHashLiteralBraces Fix all violations in the repository.
* modernizes hash syntax in activerecordXavier Noria2016-08-061-7/+7
|
* applies new string literal convention in activerecord/testXavier Noria2016-08-061-25/+25
| | | | | The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.
* remove_index do not fetch indexes if name is specifiedSeva Orlov2016-04-241-0/+11
| | | | | | 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>
* 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
| |
* | Add a test case for create a record with primary key as zeroRyuta Kamizono2016-03-301-0/+6
| |
* | Fix tests failure with `prepared_statements: false`Ryuta Kamizono2016-02-291-1/+2
|/ | | | | | Some tests does not work for unprepared statements. Add `if ActiveRecord::Base.connection.prepared_statements` and fix a regex for fix tests failure with `prepared_statements: false`.
* Remove legacy mysql adapterAbdelkader Boudih2015-12-171-2/+2
|
* Deprecate `#table_exists?`, `#tables` and passing arguments to `#talbes`yui-knk2015-11-091-4/+21
| | | | | | | | | | Reported on #21509, how views is treated by `#tables` are differ by each adapters. To fix this different behavior, after Rails 5.0 is released, deprecate `#tables`. And `#table_exists?` would check both tables and views. To make their behavior consistent with `#tables`, after Rails 5.0 is released, deprecate `#table_exists?`.
* Deprecate exception#original_exception in favor of exception#causeYuki Nishijima2015-11-031-4/+12
|
* introduce `conn.data_source_exists?` and `conn.data_sources`.Yves Senn2015-09-221-0/+15
| | | | | | | | | | | | | | | | | 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)
* Should test both mysql adaptersRyuta Kamizono2015-09-201-1/+1
| | | | | Some test cases are testing only mysql adapter. We should test mysql2 adapter also.
* Closes rails/rails#18864: Renaming transactional fixtures to transactional testsBrandon Weiss2015-03-161-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | I’m renaming all instances of `use_transcational_fixtures` to `use_transactional_tests` and “transactional fixtures” to “transactional tests”. I’m deprecating `use_transactional_fixtures=`. So anyone who is explicitly setting this will get a warning telling them to use `use_transactional_tests=` instead. I’m maintaining backwards compatibility—both forms will work. `use_transactional_tests` will check to see if `use_transactional_fixtures` is set and use that, otherwise it will use itself. But because `use_transactional_tests` is a class attribute (created with `class_attribute`) this requires a little bit of hoop jumping. The writer method that `class_attribute` generates defines a new reader method that return the value being set. Which means we can’t set the default of `true` using `use_transactional_tests=` as was done previously because that won’t take into account anyone using `use_transactional_fixtures`. Instead I defined the reader method manually and it checks `use_transactional_fixtures`. If it was set then it should be used, otherwise it should return the default, which is `true`. If someone uses `use_transactional_tests=` then it will overwrite the backwards-compatible method with whatever they set.
* Remove Relation#bind_paramsSean Griffin2015-01-271-2/+2
| | | | | | | | `bound_attributes` is now used universally across the board, removing the need for the conversion layer. These changes are mostly mechanical, with the exception of the log subscriber. Additional, we had to implement `hash` on the attribute objects, so they could be used as a key for query caching.
* Don't test invalid log encoding against PostgreSQL adapterRafael Mendonça França2015-01-021-4/+6
| | | | It already treats the message
* Merge pull request #8547 from printercu/patch-1Rafael Mendonça França2015-01-021-0/+8
|\ | | | | | | | | | | | | | | fix for messages in invalid encoding from db-drivers Conflicts: activerecord/lib/active_record/connection_adapters/abstract_adapter.rb activerecord/test/cases/connection_adapters/abstract_adapter_test.rb
* | Add where condition so select_one returns the correct record.Zuhao Wan2014-07-281-1/+1
| |
* | Remove dead test code for unsupported adaptersSean Griffin2014-05-171-13/+9
| |
* | We can conditional define the tests depending on the adapter orRajarshi Das2014-04-021-7/+5
| | | | | | | | connection.
* | Add a test case for save(validate:false) with invalid foreign key.Lauro Caetano2014-03-271-1/+15
| | | | | | | | | | It is supposed to raise ActiveRecord::InvalidForeignKey when the database has a fk constraint.
* | Use teardown helper method.Guo Xiang Tan2014-03-141-1/+1
| | | | | | | | | | | | | | | | Follow-Up to https://github.com/rails/rails/pull/14348 Ensure that SQLCounter.clear_log is called after each test. This is a step to prevent side effects when running tests. This will allow us to run them in random order.
* | Fix regression on `.select_*` methods.Arthur Neves2014-01-301-0/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This was a common pattern: ``` query = author.posts.select(:title) connection.select_one(query) ``` However `.select` returns a ActiveRecord::AssociationRelation, which has the bind information, so we can use that to get the right sql query. Also fix select_rows on postgress and sqlite3 that were not using the binds [fixes #7538] [fixes #12017] [related #13731] [related #12056]
* | using symbol instead of string in establish_connectionKuldeep Aggarwal2013-12-251-1/+1
| |
* | Deprecate use of string in establish_connection as connection lookupJosé Valim2013-12-241-1/+1
|/
* `connection.type_to_sql` returns a `String` for unmapped types.Yves Senn2013-12-031-0/+4
| | | | | | | | | | Closes #13146. This fixes an error when using: ``` change_colum :table, :column, :bigint, array: true ```
* Don't skip tests if we don't need to.Rafael Mendonça França2013-11-081-15/+13
| | | | | | | We can conditional define the tests depending on the adapter or connection. Lets keep the skip for fail tests that need to be fixed.
* Defines the return type of select / select_all method.kennyj2013-07-231-0/+5
|
* Fixed typos in ActiveRecordPrathamesh Sonpatki2013-03-281-2/+2
|
* Changed update_record to use prepared statements.Noemj2013-02-111-0/+14
|
* Anonymous class is not allowed. For reference see #8934 and bc43763247e25Guillermo Iguaran2013-01-191-4/+6
|