aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/adapter_test.rb
Commit message (Collapse)AuthorAgeFilesLines
* Deprecate update_attributes and update_attributes!Eddie Lebow2018-02-171-1/+1
| | | | Closes #31998
* Use assert_empty and assert_not_emptyDaniel Colson2018-01-251-1/+1
|
* Use assert_predicate and assert_not_predicateDaniel Colson2018-01-251-5/+5
|
* Fix `can't modify frozen String` error in an AR testKoichi ITO2017-08-191-2/+2
|
* Restore the ability that SQL with binds for `insert`, `update`, and `delete` ↵Ryuta Kamizono2017-08-181-0/+32
| | | | | | | | (#29944) Since 213796f, it was lost the ability that SQL with binds for `insert`, `update`, and `delete` (like `select_all`). This restores the ability because `insert`, `update`, and `delete` are public API, so it should not be removed without deprecation.
* Merge remote-tracking branch 'origin/master' into unlock-minitestRafael Mendonça França2017-08-011-3/+3
|\
| * Refactor Active Record to let Arel manage bind paramsSean Griffin2017-07-241-3/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A common source of bugs and code bloat within Active Record has been the need for us to maintain the list of bind values separately from the AST they're associated with. This makes any sort of AST manipulation incredibly difficult, as any time we want to potentially insert or remove an AST node, we need to traverse the entire tree to find where the associated bind parameters are. With this change, the bind parameters now live on the AST directly. Active Record does not need to know or care about them until the final AST traversal for SQL construction. Rather than returning just the SQL, the Arel collector will now return both the SQL and the bind parameters. At this point the connection adapter will have all the values that it had before. A bit of this code is janky and something I'd like to refactor later. In particular, I don't like how we're handling associations in the predicate builder, the special casing of `StatementCache::Substitute` in `QueryAttribute`, or generally how we're handling bind value replacement in the statement cache when prepared statements are disabled. This also mostly reverts #26378, as it moved all the code into a location that I wanted to delete. /cc @metaskills @yahonda, this change will affect the adapters Fixes #29766. Fixes #29804. Fixes #26541. Close #28539. Close #24769. Close #26468. Close #26202. There are probably other issues/PRs that can be closed because of this commit, but that's all I could find on the first few pages.
| * Merge pull request #29732 from kirs/frozen-activerecordRafael França2017-07-211-0/+2
| |\ | | | | | | Use frozen-string-literal in ActiveRecord
| | * Use frozen-string-literal in ActiveRecordKir Shatrov2017-07-191-0/+2
| | |
| * | Revert "Extract `bind_param` and `bind_attribute` into `ActiveRecord::TestCase`"Sean Griffin2017-07-211-1/+1
| |/ | | | | | | | | | | | | | | This reverts commit b6ad4052d18e4b29b8a092526c2beef013e2bf4f. This is not something that the majority of Active Record should be testing or care about. We should look at having fewer places rely on these details, not make it easier to rely on them.
* / Move `reset_pk_sequence!` test to `AdapterTestWithoutTransaction`yuuji.yaginuma2017-07-171-20/+20
|/ | | | | | | | | | | | | | | | | | | If execute PostgreSQL test with specifying 53853 for seed, the following error will occur. ``` 1) Error: TransactionTest#test_restore_custom_primary_key_after_rollback: ActiveRecord::RecordNotUnique: PG::UniqueViolation: ERROR: duplicate key value violates unique constraint "movies_pkey" DETAIL: Key (movieid)=(2) already exists. : INSERT INTO "movies" ("name") VALUES ($1) RETURNING "movieid" ``` travis is here https://travis-ci.org/rails/rails/jobs/254095918 As with #29287, it seems like a problem that the value of primary key obtained from connection gets different. Therefore, fixed to execute that test within transaction.
* Remove driver-specific hard-coding in the tests.Dennis Taylor2017-07-071-9/+1
|
* Rename the StatementInvalid test method for clarity.Dennis Taylor2017-07-071-1/+1
|
* Use StandardError instead of RuntimeError.Dennis Taylor2017-07-061-2/+2
| | | | Whoops.
* Fix indentation style for private method.Dennis Taylor2017-07-051-5/+5
|
* Don't translate non-database exceptions.Dennis Taylor2017-07-051-0/+30
| | | | The AbstractAdapter will translate all StandardErrors generated during the course of a query into ActiveRecord::StatementInvalids. Unfortunately, it'll also mangle non-database-related errors generated in ActiveSupport::Notification callbacks after the query has successfully completed. This should prevent it from translating errors from ActiveSupport::Notifications.
* Revert "Merge pull request #29540 from kirs/rubocop-frozen-string"Matthew Draper2017-07-021-1/+0
| | | | | This reverts commit 3420a14590c0e6915d8b6c242887f74adb4120f9, reversing changes made to afb66a5a598ce4ac74ad84b125a5abf046dcf5aa.
* Enforce frozen string in RubocopKir Shatrov2017-07-011-0/+1
|
* Extract `bind_param` and `bind_attribute` into `ActiveRecord::TestCase`Ryuta Kamizono2017-05-041-1/+1
| | | | These are used in tests from anywhere.
* 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)