aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/adapters/postgresql/hstore_test.rb
Commit message (Collapse)AuthorAgeFilesLines
* 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.
* `ActiveRecord::Store` works together with PG `hstore` columns.Yves Senn2013-10-251-0/+21
| | | | | | This is necessary because as of 5ac2341 `hstore` columns are always stored as `Hash` with `String` keys. `ActiveRecord::Store` expected the attribute to be an instance of `HashWithIndifferentAccess`, which led to the bug.
* cast hstore values on write to be consistent with reading from the db.Yves Senn2013-08-081-0/+7
|
* Merge pull request #9876 from macksmind/restore_cols_dropped_by_hstore_testRafael Mendonça França2013-03-261-15/+5
|\ | | | | Restore columns dropped by hstore test
| * Combine tests and restore columns dropped by hstore testingMack Earnhardt2013-03-261-15/+5
| | | | | | | | | | Disabling the hstore extension during testing created order dependent test failures.
* | Fix regex to strip quotations from hstore valuesjlxw2013-03-231-0/+4
|/ | | | Previously regex did not strip quotation marks where hstore values were multi-line strings.
* Support PostgreSQL specific column types when using `change_table`.Yves Senn2013-02-281-0/+15
| | | | | | | | Closes #9480. We use `TableDefinition` for `#create_table` and `Table` for `#change_table`. The PostgreSQL sepcifc types were only defined on `TableDefinition` so I also added them to `Table`.
* improve tests to check for existence of extensions method, and skip testing ↵Justin George2013-02-061-0/+1
| | | | dumped extensions if they are unsupported by the database
* Add some tests to enumerate how extensions should be stored in the schema outputJustin George2013-02-061-0/+4
|
* Enable hstore extensions on tests if it is not enabled and database supports itRafael Mendonça França2013-02-051-1/+8
|
* add API to pg for enabling / disabling hstoreAaron Patterson2013-01-281-7/+29
|
* %s/find(:\(first\|last\|all\), \([^()]*\))/scoped(\2).\1/gcI amongst other ↵Jon Leighton2012-04-271-3/+3
| | | | things