aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/adapters/postgresql/array_test.rb
Commit message (Collapse)AuthorAgeFilesLines
* applies remaining conventions across the projectXavier Noria2016-08-061-1/+1
|
* normalizes indentation and whitespace across the projectXavier Noria2016-08-061-13/+13
|
* applies new string literal convention in activerecord/testXavier Noria2016-08-061-40/+40
| | | | | The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.
* Do not specal case inspecting associated arrays of over 10 elements, ↵Kevin McPhillips2016-06-291-1/+6
| | | | preventing infinite looping in some cases.
* make it possible to run AR tests with bin/testYves Senn2015-06-111-4/+4
|
* Fix intermittent test failuresSean Griffin2015-03-091-0/+1
| | | | | | | | | | | The default value of `"pg_arrays"."tags"` is being changed to `[]` in one test, but the column information on the model isn't reset after it's changed back. As such, we think the default value is `[]` when in the database it's actually `nil`. That means any test which was assigning `[]` to a new record would have that key skipped with partial writes, as it hasn't changed from the default. However since the *actual* default value is `nil`, we get back values that the test doesn't expect, and it fails.
* 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-3/+3
|
* `Type#type_cast_from_database` -> `Type#deserialize`Sean Griffin2015-02-171-3/+3
|
* Remove unused lineRyuta Kamizono2015-02-081-1/+0
|
* rm `Type#number?`Sean Griffin2015-02-071-2/+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-7/+9
| | | | | | 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-2/+2
| | | | | `.` is regexp meta character. It should be escape for `assert_match` correctly.
* Prefer `array?` rather than `array`Ryuta Kamizono2015-01-041-3/+3
| | | | | | 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.
* Revert to 4.1 behavior for casting PG arraysSean Griffin2014-12-081-5/+20
| | | | | | | | | | The user is able to pass PG string literals in 4.1, and have it converted to an array. This is also possible in 4.2, but it would remain in string form until saving and reloading, which breaks our `attr = save.reload.attr` contract. I think we should deprecate this in 5.0, and only allow array input from user sources. However, this currently constitutes a breaking change to public API that did not go through a deprecation cycle.
* pg tests, move uniqueness validation test to array tests.Yves Senn2014-12-021-0/+15
|
* tests, move schema shorthand assertions into pg specific tests.Yves Senn2014-12-021-0/+8
|
* pg, test assigning non-array values to an array column. Closes #14716.Yves Senn2014-10-161-0/+9
| | | | | | The behavior has changed since 4.1 and non-array values are no longer type casted to a blank array. This way the user can define custom validations on that property.
* Added enable_extension! to helperAbdelkader Boudih2014-09-051-6/+2
|
* 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.
* 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.
* Reconnect after possibly enabling hstoreMatthew Draper2014-06-181-0/+2
|
* Merge pull request #15782 from sgrif/sg-column-defaultsMatthew Draper2014-06-181-7/+4
|\ | | | | Don't type cast the default on the column
| * Don't type cast the default on the columnSean Griffin2014-06-171-7/+4
| | | | | | | | | | | | | | 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.
* | Enable hstore in array testsSean Griffin2014-06-171-0/+6
| |
* | Detect mutations of arrays and array membersSean Griffin2014-06-171-0/+23
| |
* | Ensure `OID::Array#type_cast_for_database` matches PG's quoting behaviorSean Griffin2014-06-171-0/+18
|/ | | | | | Also takes a step towards supporting types which use a character other than ',' for the delimiter (`box` is the only built in type for which this is the case)
* PG arrays should type cast user inputSean Griffin2014-06-131-2/+7
| | | | | | We guarantee that `model.value` does not change after `model.save && model.reload`. This requires type casting user input for non-string types.
* Rename `type_cast` to `type_cast_from_database`Sean Griffin2014-06-091-3/+3
| | | | | | | | 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.
* Ensure time zones don't change after round trip with array columnsSean Griffin2014-06-071-0/+2
| | | | | The times would be equivalent, even if they were in different time zones. E.g. 12:00 UTC == 5:00 PDT
* Don't rely on `Time.current` in testsSean Griffin2014-06-071-5/+10
| | | | Millisecond inequality causes failures on Travis
* Add array support when time zone aware attributes are enabledSean Griffin2014-06-071-0/+16
|
* Revert "test pg, we don't care about the internal state of `column#default`."Yves Senn2014-06-031-0/+4
| | | | | | | | | | | | | | 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, rm unused requires.Yves Senn2014-06-031-2/+0
|
* test pg, we don't care about the internal state of `column#default`.Yves Senn2014-06-031-2/+0
| | | | | That data is internal to Active Record. What we care about is that new records have the right default value.
* Rename `oid_type` to `cast_type` to make PG columns consistentSean Griffin2014-05-211-10/+1
|
* test, move all pg array tests into `postgresql/array_test.rb`.Yves Senn2014-05-131-5/+28
|
* test, use `columns_hash[]` in place of `columns.find {}`.Yves Senn2014-05-121-2/+2
|
* pg, `change_column_default` accepts `[]`. Closes #11586.Yves Senn2014-05-121-1/+9
|
* PostgreSQL and SQLite, remove varchar limit. [Vladimir Sazhin & Toms Mikoss ↵Yves Senn2014-04-041-1/+1
| | | | | | | | | | | | | | | | & Yves Senn] There is no reason for the PG adapter to have a default limit of 255 on :string columns. See this snippet from the PG docs: Tip: There is no performance difference among these three types, apart from increased storage space when using the blank-padded type, and a few extra CPU cycles to check the length when storing into a length-constrained column. While character(n) has performance advantages in some other database systems, there is no such advantage in PostgreSQL; in fact character(n) is usually the slowest of the three because of its additional storage costs. In most situations text or character varying should be used instead.
* fix bug on non empty defaults for pg array columnsLuke Steensen2014-03-301-0/+11
| | | | fixes #10613
* 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/+3
|
* 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.
* Fixes issue with parsing whitespace content back from database - fixes #13907Mauricio Linhares2014-02-011-0/+12
|
* 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
* Do not consider PG array columns as number or text columnsCarlos Antonio da Silva2013-12-231-2/+6
| | | | | | | | | | | | | | | | | | | | | | | The code uses these checks in several places to know what to do with a particular column, for instance AR attribute query methods has a branch like this: if column.number? !value.zero? end This should never be true for array columns, since it would be the same as running [].zero?, which results in a NoMethodError exception. Fixing this by ensuring that array columns in PostgreSQL never return true for number?/text? checks. Since most of the array support was based on the postgres_ext lib, it's worth noting it does the same thing for numeric array columns too: https://github.com/dockyard/postgres_ext/blob/v1.0.0/lib/postgres_ext/active_record/connection_adapters/postgres_adapter.rb#L72 This extended the same logic for text columns to ensure consistency.