aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/adapters
Commit message (Collapse)AuthorAgeFilesLines
* Consistently apply adapter behavior when serializing arraysSean Griffin2017-01-032-4/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | In f1a0fa9 we moved backend specific timestamp behavior out of the type and into the adapter. This was in line with our general attempt to reduce the number of adapter specific type subclasses. However, on PG, the array type performs all serialization, including database encoding in its serialize method. This means that we have converted the value into a string before reaching the database, so no adapter specific logic can be applied (and this also means that timestamp arrays were using the default `.to_s` method on the given object, which likely meant timestamps were being ignored in certain cases as well) Ultimately I want to do a more in depth refactoring which separates database serializer objects from the active model type objects, to give us a less awkward API for introducing the attributes API onto Active Model. However, in the short term, we follow the solution we've applied elsewhere for this. Move behavior off of the type and into the adapter, and use a data object to allow the type to communicate information up the stack. Fixes #27514.
* Dump array subtype options correctlyRyuta Kamizono2017-01-011-3/+5
| | | | | Currently schema dumper does not dump array subtype `precision` and `scale` options. This commit fixes the issue.
* `#tables` and `#table_exists?` and returns only tables and not viewsRafael Mendonça França2016-12-292-8/+6
|
* Remove deprecated `name` argument from `#tables`Rafael Mendonça França2016-12-292-4/+2
|
* "Use assert_nil if expecting nil from ...:in `...'. This will fail in MT6."Akira Matsuda2016-12-254-10/+10
|
* "Use assert_nil if expecting nil. This will fail in minitest 6."Akira Matsuda2016-12-255-6/+6
|
* Privatize unneededly protected methods in Active Record testsAkira Matsuda2016-12-244-4/+4
|
* Merge pull request #27329 from kamipo/simplify_unsigned_regexEileen M. Uchitelle2016-12-171-1/+1
|\ | | | | Simplify the regex for `unsigned?` method
| * Simplify the regex for `unsigned?` methodRyuta Kamizono2016-12-111-1/+1
| | | | | | | | | | It is enough to distinguish only the trailing `unsigned` and `unsigned zerofill`.
* | fix new warning in ruby 2.4yuuji.yaginuma2016-12-141-1/+1
|/ | | | | | | | | | | | | | This fixes the following warning. ``` test/caching_test.rb:986: warning: parentheses after method name is interpreted as test/caching_test.rb:986: warning: an argument list, not a decomposed argument test/cases/adapters/mysql2/reserved_word_test.rb:146: warning: parentheses after method name is interpreted as test/cases/adapters/mysql2/reserved_word_test.rb:146: warning: an argument list, not a decomposed argument ``` Ref: https://github.com/ruby/ruby/commit/65e27c8b138d6959608658ffce2fa761842b8d24
* Translate numeric value out of range to the specific exceptionRyuta Kamizono2016-12-061-2/+2
| | | | Raise `ActiveRecord::RangeError` when values that executed are out of range.
* Merge pull request #26687 from kamipo/fix_add_index_to_normalize_optionsMatthew Draper2016-12-062-0/+7
|\ | | | | Fix `add_index` to normalize column names and options
| * Fix `add_index` to normalize column names and optionsRyuta Kamizono2016-10-032-0/+7
| | | | | | | | | | | | | | | | | | | | Currently does not work the following code. ```ruby add_index(:people, ["last_name", "first_name"], order: { last_name: :desc, first_name: :asc }) ``` Normalize column names and options to fix the issue.
* | Make pg adapter use bigserial for pk by defaultPavel Pravosud2016-12-054-0/+186
| |
* | Fix that unsigned with zerofill is treated as signedRyuta Kamizono2016-11-271-0/+1
| | | | | | | | Fixes #27125.
* | abort_on_exception can't be disabled for a single threadMatthew Draper2016-11-272-6/+8
| | | | | | | | | | If it's enabled globally, it's on regardless of how individual threads are set.
* | We expect exceptions; abort will just raise in the wrong placeMatthew Draper2016-11-272-9/+17
| |
* | Should test `test_change_column_default` in `PostgresqlUUIDTest`Ryuta Kamizono2016-11-251-13/+13
| | | | | | | | Follow up to #25395.
* | Merge pull request #27171 from kamipo/suppress_migration_messageMatthew Draper2016-11-251-0/+4
|\ \ | | | | | | Suppress migration message in the test
| * | Suppress migration message in the testRyuta Kamizono2016-11-251-0/+4
| | |
* | | Remove blank else blockRyuta Kamizono2016-11-251-1/+0
|/ /
* | For `PostgreSQL >= 9.4` use `gen_random_uuid()`Yaw Boakye2016-11-221-14/+59
| | | | | | | | | | | | | | | | | | | | Since 9.4, PostgreSQL recommends using `pgcrypto`'s `gen_random_uuid()` to generate version 4 UUIDs instead of the functions in the `uuid-ossp` extension. These changes uses the appropriate UUID function depending on the underlying PostgreSQL server's version, while maintaining `uuid_generate_v4()` in older migrations.
* | Fix prepared statements disabled test againPrathamesh Sonpatki2016-11-202-22/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Due to `assert_nothing_raised` this test was not really testing anything. - So updated it to assert that the query gives expected result. - Also in general we can use `connection.unprepared_statement` for testing queries w/o prepared statements but it can't be used in this case. This test cases was added because when prepared_statements config is set to false, then DetermineIfPreparableVisitor module does not extended by Arel visitor resulting into an error. Ref: https://github.com/rails/rails/pull/22748. - Because DetermineIfPreparableVisitor module does not get added to the visitor chain only if prepared_statements is false while **setting up connection**, not when `unprepared_statement` is used. - I have also added an assertion for making sure that prepared_config is set to false from the start, so that nobody accidentally removes the connection setup using `arunit_without_prepared_statements` and replaces it with stubs or unprepared_statement.
* | Fix typo s/with/without/Ryuta Kamizono2016-11-201-1/+1
| | | | | | | | Follow up to #27109.
* | Fix tests for prepared_statements: false and queries hitting `#select_all`Prathamesh Sonpatki2016-11-191-4/+4
| | | | | | | | | | | | | | | | | | | | - The query needs to be executed for hitting `select_all` so made sure that query gets executed. - Also instead of changing instance variable, just add new configuration for prepared_statements: false and use it for this test. - This way we don't have to touch the internals of AR code and still disable prepared statements config for this test.
* | Merge pull request #27076 from y-yagi/fix_postgresql_array_encodingSean Griffin2016-11-171-3/+3
|\ \ | | | | | | use `force_encoding` instread of `encode!` to avoid `UndefinedConversionError`
| * | use `force_encoding` instread of `encode!` to avoid `UndefinedConversionError`yuuji.yaginuma2016-11-171-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `PG::TextEncoder::Array#encode` returns the encoded value with `ASCII-8BIT`. But in some cases, trying to convert `ASCII-8BIT` to `UTF-8` cause an error. ```ruby "{\xE3\x83\x95\xE3\x82\xA1\xE3\x82\xA4\xE3\x83\xAB}".encode!(Encoding::UTF_8) # => Encoding::UndefinedConversionError: "\xE3" from ASCII-8BIT to UTF-8 ``` Should use `force_encoding` to avoid this error. Follow up to 7ba3a48df5bfdc5e98506bb829f937e03b55a5b3 Ref: https://github.com/rails/rails/pull/23619#issuecomment-189924036
* | | Fix mucking of connection_config leading to issues in prepared_statementsVipul A M2016-11-171-3/+3
| | |
* | | Fix PG prepared statement testVipul A M2016-11-171-1/+2
| | |
* | | Support AC::Parameters for PG HStoreJon Moss2016-11-151-0/+10
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | As reported via #26904, there is a regression in how values for Postgres' HStore column type are being processed, beginning in Rails 5. Currently, the way that Active Record checks whether or not values need to be serialized and put into the correct storage format is whether or not it is a `Hash` object. Since `ActionController::Parameters` no longer inherits from `Hash` in Rails 5, this conditional now returns false. To remedy this, we are now checking to see whether the `value` parameters being passed in responds to a certain method, and then calling the `serialize` method, except this time with a real Hash object. Keeping things DRY! Fixes #26904.
* | Add more rubocop rules about whitespacesRafael Mendonça França2016-10-2913-55/+55
| |
* | Use Regexp#match? rather than Regexp#===Ryuta Kamizono2016-10-261-1/+1
| | | | | | | | Follow up to 99cf7558000090668b137085bfe6bcc06c4571dc.
* | Fix brittle tests which were relying on the error message text from mysql2 gemPrathamesh Sonpatki2016-10-231-4/+4
| | | | | | | | | | | | | | - These tests were fixed earlier on master in https://github.com/rails/rails/commit/f13ec72664fd13d33d617103ca964a7592295854. - They started failing in first place due to change in https://github.com/brianmario/mysql2/commit/f14023fcfee9e85e6fc1b0e568048811518f8c23. - They will fail again when the message is changed in mysql2 so let's not rely on the error message.
* | Update mysql adapter error message when disconnectedGuillermo Iguaran2016-10-221-2/+2
| |
* | Fix `warning: ambiguous first argument`Ryuta Kamizono2016-10-121-4/+4
| | | | | | | | | | | | | | | | | | ``` test/cases/adapters/postgresql/case_insensitive_test.rb:12: warning: ambiguous first argument; put parentheses or a space even after `/' operator test/cases/adapters/postgresql/case_insensitive_test.rb:16: warning: ambiguous first argument; put parentheses or a space even after `/' operator test/cases/adapters/postgresql/case_insensitive_test.rb:20: warning: ambiguous first argument; put parentheses or a space even after `/' operator test/cases/adapters/postgresql/case_insensitive_test.rb:24: warning: ambiguous first argument; put parentheses or a space even after `/' operator ```
* | Merge pull request #26208 from nanaya/pg-insensitive-textMatthew Draper2016-10-111-0/+26
|\ \ | | | | | | | | | Fix case insensitive check for text column in pg
| * | Fix case insensitive check for text column in pgnanaya2016-09-011-0/+26
| | | | | | | | | | | | There's no 'text to text' casting in the cast table so the feature detection fails.
* | | Simplify serializable test to avoid mystery deadlockMatthew Draper2016-10-071-23/+21
| |/ |/|
* | Make PG deadlock error more deterministicMatthew Draper2016-10-011-9/+12
| | | | | | | | | | We've seen occasional Travis failures mentioning deadlocks. I think they're escaping from this test.
* | Serialize JSON attribute value nil as SQL NULL, not JSON 'null'Trung Duc Tran2016-09-232-0/+32
| | | | | | | | | | | | Test: JSON attribute value nil can be used in where(attr: nil) Add changelog entry
* | improve error message when include assertions failMichael Grosser2016-09-163-4/+4
| | | | | | | | | | | | 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
* | Fix broken comments indentation caused by rubocop auto-correct [ci skip]Ryuta Kamizono2016-09-141-3/+3
| | | | | | | | | | | | All indentation was normalized by rubocop auto-correct at 80e66cc4d90bf8c15d1a5f6e3152e90147f00772. But comments was still kept absolute position. This commit aligns comments with method definitions for consistency.
* | Address `warning: ambiguous first argument; put parentheses or a space even ↵Yasuo Honda2016-09-131-2/+2
| | | | | | | | after `/' operator`
* | activerecord/mysql2: Avoid setting @connection to nil, just close itDylan Thacker-Smith2016-09-081-0/+21
| | | | | | | | | | | | | | | | | | | | By doing `@connection = nil` that means that we need nil checks before it is used anywhere, but we weren't doing those checks. Instead, we get a NoMethodError after using a connection after it fails to reconnect. Neither of the other adapters set @connection to nil, just the mysql2 adapter. By just closing it, we avoid the need to check if we have a connection object and it will produce an appropriate exception when used.
* | Fix broken heredoc indentation caused by rubocop auto-correctRyuta Kamizono2016-09-032-7/+7
|/ | | | | | All indentation was normalized by rubocop auto-correct at 80e66cc4d90bf8c15d1a5f6e3152e90147f00772. But heredocs was still kept absolute position. This commit aligns heredocs indentation for consistency.
* Remove deprecated handling of PG PointsSean Griffin2016-08-311-12/+0
| | | | | | | | | | There are some minor changes to the point type as I had forgotten that this will affect the behavior of `t.point` in migrations and the schema dumper so we need to handle those as well. I'll say this again so I can convince myself to come up with a better structure... TYPES SHOULD NOT CARE ABOUT SCHEMA DUMPING AND WE NEED TO BETTER SEPARATE THESE.
* Attempt to maintain encoding for arrays of strings with PGSean Griffin2016-08-311-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | I still think that this is something that should be handled in the pg gem, but it's not going to end up happening there so we'll do it here instead. Once we bump to pg 0.19 we can pass the encoding to the `encode` method instead. This issue occurs because C has no concept of encoding (or strings, really). The bytes that we pass here when sending the value to the database will always be interpreted as whatever encoding the connection is currently configured to use. That means that roundtripping to the database will lose no information However, after assigning we round trip through our type system without hitting the database. The only way that we can do the "correct" thin here would be to actually give a reference to the connection to the array type and have it check the current value of the connection's encoding -- which I'm strongly opposed to. We could also pass in the encoding when it's constructed, but since that can change independently of the type I'm not a huge fan of that either. This feels like a reasonable middle ground, where if we have an array of strings we simply use the encoding of the string we're given. Fixes #26326.
* Fix CI failure caused by df84e9867219e9311aef6f4efd5dd9ec675bee5cRyuta Kamizono2016-08-231-2/+2
|
* Fix `OID::Bit#cast_value`Ryuta Kamizono2016-08-201-2/+3
| | | | Fixes #26137.
* Remove unused `blob_or_text_column?` methodRyuta Kamizono2016-08-191-5/+0
|