aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/adapters/postgresql/hstore_test.rb
Commit message (Collapse)AuthorAgeFilesLines
* Make sure to disable extension after testyuuji.yaginuma2017-05-311-6/+2
| | | | | If keep the extension, can not test properly to make sure that extension can be enabled.
* Compare deserialized values for `PostgreSQL::OID::Hstore` typesJon Moss2017-01-031-0/+19
| | | | | | | | | | | | | Per the regression commit below, the commit changes the behavior of `#changed?`to consult the `#changed_in_place?` method on `Type::Value` classes. Per this change, `PostgreSQL::OID::Hstore` needs to override this method in order to compare the deserialized forms of the two arguments. In Ruby, two hashes are considered equal even if their key order is different. This commit helps to bring that behavior to `Hstore` values. Fixes regression introduced by 8e633e505880755e7e366ccec2210bbe2b5436e7 Fixes #27502
* 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-291-13/+13
|
* improve error message when include assertions failMichael Grosser2016-09-161-1/+1
| | | | | | 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-26/+26
| | | | | | | | Style/SpaceBeforeBlockBraces Style/SpaceInsideBlockBraces Style/SpaceInsideHashLiteralBraces Fix all violations in the repository.
* applies remaining conventions across the projectXavier Noria2016-08-061-4/+4
|
* normalizes indentation and whitespace across the projectXavier Noria2016-08-061-26/+26
|
* remove redundant curlies from hash argumentsXavier Noria2016-08-061-6/+6
|
* modernizes hash syntax in activerecordXavier Noria2016-08-061-3/+3
|
* applies new string literal convention in activerecord/testXavier Noria2016-08-061-48/+48
| | | | | The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.
* Internal test migrations use the private 'Current' versionMatthew Draper2015-12-151-1/+1
| | | | | | | | Apart from specific versioning support, our tests should focus on the behaviour of whatever version they're accompanying, regardless of when they were written. Application code should *not* do this.
* make it possible to run AR tests with bin/testYves Senn2015-06-111-1/+1
|
* Fix intermittent test failuresSean Griffin2015-03-091-0/+1
| | | | | | | | | | The table is being modified in tests, without reloading the column information on the appropriate class. This is leading to incorrect column information in many cases. The failures fixed by this commit can be replicated with: ARCONN=postgresql ruby -Itest test/cases/adapters/postgresql/hstore_test.rb --seed 21574
* prefer `drop_table if_exists: true` over raw SQL.Yves Senn2015-02-181-1/+1
| | | | | | | /cc @yahonda This makes it easier for third party adapters to run our tests, even if that database does not support IF EXISTS.
* `type_cast_for_database` -> `serialize`Sean Griffin2015-02-171-4/+4
|
* `Type#type_cast_from_database` -> `Type#deserialize`Sean Griffin2015-02-171-11/+11
|
* rm `Type#number?`Sean Griffin2015-02-071-1/+0
| | | | | This predicate is only used in `query_attribute`, and is relatively easy to remove without adding a bunch of is a checks.
* Removed magic comments # encoding: utf-8 , since its default from ruby 2.0 ↵Vipul A M2015-02-031-1/+0
| | | | onwards.
* Remove most type related predicates from `Column`Sean Griffin2015-01-301-17/+19
| | | | | | Remaining are `limit`, `precision`, `scale`, and `type` (the symbol version). These will remain on the column, since they mirror the options to the `column` method in the schema definition DSL
* Should escape regexp wildcard character `.`Ryuta Kamizono2015-01-191-1/+1
| | | | | `.` is regexp meta character. It should be escape for `assert_match` correctly.
* Prefer `array?` rather than `array`Ryuta Kamizono2015-01-041-1/+1
| | | | | | Slightly refactoring `PostgreSQLColumn`. `array` should be readonly. `default_function` should be initialized by `super`. `sql_type` has been removed `[]`. Since we already choose to remove it we should not change.
* tests, move schema shorthand assertions into pg specific tests.Yves Senn2014-12-021-0/+7
|
* pg tests, only execute what's necessary.Yves Senn2014-11-071-26/+25
|
* tests, remove unneeded requires.Yves Senn2014-11-061-3/+0
|
* Remove the `text?` predicate from the type objectsSean Griffin2014-07-061-1/+0
| | | | | | | This was only used for uniqueness validations. The first usage was in conjunction with `limit`. Types which cast to string, but are not considered text cannot have a limit. The second case was only with an explicit `:case_sensitive => true` option given by the user.
* Use the type object for type casting HStore columnsSean Griffin2014-07-031-11/+5
|
* Consolidate testing of update_all type castingSean Griffin2014-06-261-10/+0
| | | | | | | | | | | | | | We have several test cases on "tricky" types that are essentially testing that `update_all` goes through the same type casting behavior as a normal assignment + save. We recently had another case to add this test for another type in https://github.com/rails/rails/pull/12742. Rather than testing this separately for every type which is "tricky" when round tripping, let's instead have a fairly exhaustive test that ensures we're getting the correct values at every step for `update_all`. Given the structure of the code now, we can be confident that if the type is correct, and `update_all` is type casting correctly, we're going to get the right behavior for all types.
* Don't type cast the default on the columnSean Griffin2014-06-171-2/+1
| | | | | | | If we want to have type decorators mess with the attribute, but not the column, we need to stop type casting on the column. Where possible, we changed the tests to test the value of `column_defaults`, which is public API. `Column#default` is not.
* Don't assume that Hstore columns have always changedSean Griffin2014-06-171-0/+1
| | | | | | | | | HStore columns come back from the database separated by a comma and a space, not just a comma. We need to mirror that behavior since we compare the two values. Also adds a regression test against JSON to ensure we don't have the same bug there.
* Detect in-place changes on mutable AR attributesSean Griffin2014-06-131-0/+9
| | | | | | We have several mutable types on Active Record now. (Serialized, JSON, HStore). We need to be able to detect if these have been modified in place.
* Rename `type_cast` to `type_cast_from_database`Sean Griffin2014-06-091-11/+11
| | | | | | | | In some cases there is a difference between the two, we should always be doing one or the other. For convenience, `type_cast` is still a private method on type, so new types that do not need different behavior don't need to implement two methods, but it has been moved to private so it cannot be used accidentally.
* Merge pull request #15587 from sgrif/sg-remove-workaroundRafael Mendonça França2014-06-091-15/+8
|\ | | | | Remove workaround for non-lazy serialize in tests
| * Remove workaround for non-lazy serialize in testsSean Griffin2014-06-091-15/+8
| | | | | | | | `serialize` is now lazy, so the workaround is no longer needed.
* | Make `_before_type_cast` actually be before type castSean Griffin2014-06-091-0/+1
|/ | | | | | | | | | | | | - The following is now true for all types, all the time - `model.attribute_before_type_cast == given_value` - `model.attribute == model.save_and_reload.attribute` - `model.attribute == model.dup.attribute` - `model.attribute == YAML.load(YAML.dump(model)).attribute` - Removes the remaining types implementing `type_cast_for_write` - Simplifies the implementation of time zone aware attributes - Brings tz aware attributes closer to being implemented as an attribute decorator - Adds additional point of control for custom types
* serialized Type should delegate `type_cast_for_write` to underlying TypeYves Senn2014-06-061-0/+35
| | | | | | | This adds a regression test for #14411, which was fixed by #15503. Closes #14411 Closes #14595
* Bring type casting behavior of hstore/json in line with serializedSean Griffin2014-06-041-0/+10
| | | | | `@raw_attributes` should not contain the type-cast, mutable version of the value.
* Revert "test pg, we don't care about the internal state of `column#default`."Yves Senn2014-06-031-0/+3
| | | | | | | | | | | | | | Revert "test pg, remove unused column assignments. Follow up to 254cdf47" Related to #15492 This reverts commit 254cdf4728291277f3fbaa854f34495030e476b4. This reverts commit 4bcf9029452e0c760af04faab6b549710401e8cf. There are public methods that assume `Column#default` is type casted. The return value of `Column#default` is publicly relevant and should not change. /cc @sgrif
* test pg, remove unused column assignments. Follow up to 254cdf47Yves Senn2014-06-031-2/+0
|
* test pg, we don't care about the internal state of `column#default`.Yves Senn2014-06-031-1/+0
| | | | | That data is internal to Active Record. What we care about is that new records have the right default value.
* pg, keep `hstore` and `json` attributes as `Hash` in @attributes.Yves Senn2014-05-281-0/+10
| | | | | | | | | | | The solution presented in this patch is not efficient. We should replace it in the near future. The following needs to be worked out: * Is `@attributes` storing the Ruby or SQL representation? * `cacheable_column?` is broken but `hstore` and `json` rely on that behavior Refs #15369. /cc @sgrif @rafaelfranca
* test, use `columns_hash[]` in place of `columns.find {}`.Yves Senn2014-05-121-2/+2
|
* PostgreSQL, test-cases to lock down column default values.Yves Senn2014-03-281-0/+11
|
* PostgreSQL, test cases to lock the current column types.Yves Senn2014-03-281-0/+5
|
* 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.
* Resolve encoding issues with arrays of hstore (bug 11135).Josh Goodall2014-02-171-0/+39
| | | | | | | | | | | | | | | | | | | | | | | | | | We didn't have enough encoding for the wire protocol to store an array of hstore types. So, further encode any hstore that is an array member. Whilst we're here, ensure it's an HashWithIndifferentAccess being returned, to be consistent with other serialized forms, and add testing for arrays of hstore. So now the following migration: enable_extension "hstore" create_table :servers do |t| t.string :name t.hstore :interfaces, array: true end produces a model that can used like this, to store an array of hashes: server = Server.create(name: "server01", interfaces: [ { name: "bge0", ipv4: "192.0.2.2", state: "up" }, { name: "de0", state: "disabled", by: "misha" }, { name: "fe0", state: "up" }, ]) More at http://inopinatus.org/2013/07/12/using-arrays-of-hstore-with-rails-4/
* Make change_table use object of current database adapterNishant Modak2014-01-071-0/+17
| | | | | | | | | - Earlier, change_table was creating database-agnostic object. - After this change, it will create correct object based on current database adapter. - This will ensure that create_table and change_table will get same objects. - This makes update_table_definition method public and nodoc. - Fixes #13577 and #13503
* Tidy up fix for PG extensions quotingCarlos Antonio da Silva2013-12-231-2/+6
| | | | | Always pass in the column for quote_bound_value and quote using it in case it exists there.
* Serialize postgres' hstore, json and array types correctly in AR update methods.Tadas Tamosauskas2013-12-231-0/+6
| | | | | | | | | Fixes #12261. Closes #12395. Conflicts: activerecord/CHANGELOG.md activerecord/test/cases/adapters/postgresql/array_test.rb activerecord/test/cases/adapters/postgresql/json_test.rb
* Don't skip tests if we don't need to.Rafael Mendonça França2013-11-081-151/+149
| | | | | | | We can conditional define the tests depending on the adapter or connection. Lets keep the skip for fail tests that need to be fixed.