aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/adapters/postgresql/json_test.rb
Commit message (Collapse)AuthorAgeFilesLines
* "Use assert_nil if expecting nil from ...:in `...'. This will fail in MT6."Akira Matsuda2016-12-251-2/+2
|
* Add more rubocop rules about whitespacesRafael Mendonça França2016-10-291-8/+8
|
* Serialize JSON attribute value nil as SQL NULL, not JSON 'null'Trung Duc Tran2016-09-231-0/+16
| | | | | | Test: JSON attribute value nil can be used in where(attr: nil) Add changelog entry
* Add three new rubocop rulesRafael Mendonça França2016-08-161-15/+15
| | | | | | | | Style/SpaceBeforeBlockBraces Style/SpaceInsideBlockBraces Style/SpaceInsideHashLiteralBraces Fix all violations in the repository.
* applies remaining conventions across the projectXavier Noria2016-08-061-1/+1
|
* applies new string literal convention in activerecord/testXavier Noria2016-08-061-22/+22
| | | | | The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.
* Properly serialize all JSON primitives in the AR JSON typeSean Griffin2016-04-131-5/+12
| | | | | | | | | | | | | | Previously we were assuming that the only valid types for encoding were arrays and hashes. However, any JSON primitive is an accepted value by both PG and MySQL. This does involve a minor breaking change in the handling of `default` in the schema dumper. This is easily worked around, as passing a hash/array literal would have worked fine in previous versions of Rails. However, because of this, I will not be backporting this to 4.2 or earlier. Fixes #24234
* File encoding is defaulted to utf-8 in Ruby >= 2.1Akira Matsuda2015-09-181-1/+0
|
* make it possible to run AR tests with bin/testYves Senn2015-06-111-2/+2
|
* Fix json_testpalkan2015-03-111-0/+1
|
* Remove unused lineRyuta Kamizono2015-03-031-1/+0
|
* `Type#type_cast_from_database` -> `Type#deserialize`Sean Griffin2015-02-171-5/+5
|
* pg tests, be clear about the missing type that causes a test skip.Yves Senn2015-02-121-7/+6
| | | | Also removed some cruft in the `setup` and `teardown` methods.
* 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-8/+10
| | | | | | 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
* Don't error when invalid json is assigned to a JSON columnSean Griffin2015-01-211-0/+8
| | | | | | | Keeping with our behavior elsewhere in the system, invalid input is assumed to be `nil`. Fixes #18629.
* 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, remove unneeded requires.Yves Senn2014-11-061-3/+0
|
* Added SchemaDumper support for tables with jsonb columns.Ted O'Meara2014-11-041-0/+8
|
* Add support for Postgresql JSONBPhilippe Creux2014-07-241-9/+25
| | | | [Philippe Creux, Chris Teague]
* 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 sending JSON to the databaseSean Griffin2014-06-291-1/+1
|
* 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-1/+2
| | | | | | | | | 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/+20
| | | | | | 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-4/+4
| | | | | | | | 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.
* 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
* Bring type casting behavior of hstore/json in line with serializedSean Griffin2014-06-041-0/+8
| | | | | `@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/+8
| | | | | | | | | | | 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-7/+13
|
* 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.
* no need to `return skip` in tests. `skip` is enough.Yves Senn2014-01-161-1/+1
|
* 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
* cast json values on write to be consistent with reading from the db.Severin Schoepke2013-10-251-0/+7
| | | | See also commit 5ac2341fab689344991b2a4817bd2bc8b3edac9d
* test to verify the `ActiveRecord::Store` behavior with PG's json typeYves Senn2013-10-251-0/+18
|
* Add CHANGELOG enty for #11235Rafael Mendonça França2013-07-021-1/+0
|
* Support array as root element in JSONAlexey Noskov2013-05-141-0/+14
|
* 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`.
* Put the create_table block in a transaction.Rafael Mendonça França2012-09-051-2/+4
| | | | | This will solve the issue that abort the connection transaction when we skip the tests.
* ActiveRecord support to PostgreSQL 9.2 JSON typeDickson S. Guedes2012-09-051-0/+69
This implements the support to encode/decode JSON data to/from database and creating columns of type JSON using a native type [1] supported by PostgreSQL from version 9.2. [1] http://www.postgresql.org/docs/9.2/static/datatype-json.html