aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters/postgresql
Commit message (Collapse)AuthorAgeFilesLines
* Revert "Merge pull request #21233 from ↵Rafael Mendonça França2017-01-031-43/+4
| | | | | | | | | | mtsmfm/disable-referential-integrity-without-superuser-privileges" This reverts commit eeac6151a55cb7d5f799e1ae33aa64a839cbc3aa, reversing changes made to 5c40239d3104543e70508360d27584a3e4dc5baf. Reason: Broke the isolated tests. https://travis-ci.org/rails/rails/builds/188721346
* Merge pull request #21233 from ↵Rafael França2017-01-031-4/+43
|\ | | | | | | | | mtsmfm/disable-referential-integrity-without-superuser-privileges Use `SET CONSTRAINTS` for `disable_referential_integrity` without superuser privileges
| * Use `SET CONSTRAINTS` for `disable_referential_integrity` without superuser ↵Fumiaki MATSUSHIMA2016-12-031-4/+43
| | | | | | | | | | | | | | | | | | privileges ref: 72c1557254 - We must use `authors` fixture with `author_addresses` because of its foreign key constraint. - Tests require PostgreSQL >= 9.4.2 because it had a bug about `ALTER CONSTRAINTS` and fixed in 9.4.2.
* | Merge pull request #25522 from ↵Rafael França2017-01-031-10/+14
|\ \ | | | | | | | | | | | | kamipo/fix_select_rows_method_signature_for_consistency Fix `select_rows` method signature for consistency
| * | Fix `select_rows` method signature for consistencyRyuta Kamizono2017-01-041-10/+14
| | | | | | | | | | | | | | | | | | | | | | | | Related #22973, #24708. `select_all`, `select_one`, `select_value`, and `select_values` method signature is `(arel, name = nil, binds = [])`. But `select_rows` is `(sql, name = nil, binds = [])`.
* | | Remove unneeded requires at active recordRafael Mendonça França2017-01-031-2/+0
| | |
* | | Deprecate passing `name` to `indexes` like `tables`Ryuta Kamizono2017-01-041-1/+7
|/ / | | | | | | | | Passing `name` to `tables` is already deprecated at #21601. Passing `name` to `indexes` is also unused.
* | Compare deserialized values for `PostgreSQL::OID::Hstore` typesJon Moss2017-01-031-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | Consistently apply adapter behavior when serializing arraysSean Griffin2017-01-032-13/+41
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-1/+1
| | | | | | | | | | 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-291-20/+22
| |
* | Remove deprecated `name` argument from `#tables`Rafael Mendonça França2016-12-291-7/+1
| |
* | Sync the visibility of `sql_for_insert` to privateRyuta Kamizono2016-12-291-1/+1
| | | | | | | | | | The visibility of all internal protected methods was changed to private since 5b14129.
* | AR::ConnectionAdapters::PostgreSQL::Name#parts is called from other instancesAkira Matsuda2016-12-251-4/+6
| |
* | Privatize unneededly protected methods in Active RecordAkira Matsuda2016-12-241-1/+1
| |
* | Describe what we are protectingAkira Matsuda2016-12-231-0/+2
| |
* | Merge pull request #27274 from kamipo/primary_key_with_auto_increment_and_bigintMatthew Draper2016-12-061-2/+6
|\ \ | | | | | | Make `:auto_increment` option works on `:bigint`
| * | Make `:auto_increment` option works on `:bigint`Ryuta Kamizono2016-12-061-2/+6
| | | | | | | | | | | | Follow up to #27272.
* | | Change MySQL and Postgresql to use Bigint primary keysJon McCartie2016-12-051-1/+1
|/ /
* / Make `:auto_increment` to internal primary key optionRyuta Kamizono2016-12-061-1/+6
|/ | | | | | Using `:auto_increment` option for abstracting the DB-specific auto incremental types. It is worth to ease to implement the compatibility layer.
* Followup of UUID default extension in the docs [ci skip]Prathamesh Sonpatki2016-11-241-5/+15
| | | | | | | - Mentioned clearly that for PostgreSQL < 9.4, you need to pass the default option with "uuid_generate_v4()" - Also updated PostgreSQL Active Record guide with this change. - https://github.com/rails/rails/pull/25395#r66877078
* For `PostgreSQL >= 9.4` use `gen_random_uuid()`Yaw Boakye2016-11-221-8/+9
| | | | | | | | | | 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.
* Merge pull request #27076 from y-yagi/fix_postgresql_array_encodingSean Griffin2016-11-171-1/+1
|\ | | | | use `force_encoding` instread of `encode!` to avoid `UndefinedConversionError`
| * use `force_encoding` instread of `encode!` to avoid `UndefinedConversionError`yuuji.yaginuma2016-11-171-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `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
* | Support AC::Parameters for PG HStoreJon Moss2016-11-151-0/+2
|/ | | | | | | | | | | | | | | 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.
* Merge pull request #26905 from bogdanvlviv/docsAndrew White2016-11-131-1/+1
|\ | | | | Add missing `+` around a some literals.
| * Add missing `+` around a some literals.bogdanvlviv2016-10-271-1/+1
| | | | | | | | | | | | Mainly around `nil` [ci skip]
* | Refactor column initialization into `new_column_from_field`Kir Shatrov2016-11-111-15/+17
| | | | | | | | that accepts results of SHOW FIELDS
* | Add more rubocop rules about whitespacesRafael Mendonça França2016-10-291-2/+2
| |
* | Permit loads while queries are runningMatthew Draper2016-10-271-2/+6
| | | | | | | | | | A query may wait on a database-level lock, which could lead to a deadlock between threads.
* | Use Regexp#match? rather than Regexp#===Ryuta Kamizono2016-10-262-3/+3
|/ | | | Follow up to 99cf7558000090668b137085bfe6bcc06c4571dc.
* Quote table name properlyRyuta Kamizono2016-10-141-8/+8
| | | | If does not quote table name properly, invalid SQL is generated.
* Fix table comment dumpingRyuta Kamizono2016-10-111-1/+3
| | | | | | | | | | | | | Follow up to #26735. If `table_options` returns `{ comment: nil }`, `create_table` line is broken. Example: ```ruby create_table "accounts", force: :cascade, do |t| ```
* [ci skip] Update PG adapter documentationAlex Kitchens2016-09-261-1/+1
| | | | | | | | Per discussion in pull request #26622: "Let's change it to PG::Error. The more specific classes mentioned are subclasses, and the fact the raised exception is a PG::UndefinedColumn doesn't change the fact that it's also a PG::Error." - matthewd
* [ci skip] Clarify Postgresql DocumentationAlex Kitchens2016-09-251-4/+4
| | | | | This clarifies the object that +ActiveRecord::Base.connection.execute+ will return when using Postgresql.
* Fix Remaining Case-In-Assignment Statement FormattingAlex Kitchens2016-09-061-25/+26
| | | | | | | | | Recently, the Rails team made an effort to keep the source code consistent, using Ruboco (bb1ecdcc677bf6e68e0252505509c089619b5b90 and below). Some of the case statements were missed. This changes the case statements' formatting and is consistent with changes in 810dff7c9fa9b2a38eb1560ce0378d760529ee6b and db63406cb007ab3756d2a96d2e0b5d4e777f8231.
* fixes remaining RuboCop issues [Vipul A M, Xavier Noria]Xavier Noria2016-09-011-2/+2
|
* Remove deprecated handling of PG PointsSean Griffin2016-08-313-19/+30
| | | | | | | | | | 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-1/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | 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 `OID::Bit#cast_value`Ryuta Kamizono2016-08-201-2/+2
| | | | Fixes #26137.
* Remove unnecessary `test_sql_for_insert_with_returning_disabled`Ryuta Kamizono2016-08-181-3/+2
| | | | | Because `sql_for_insert` is only called in `use_insert_returning?` is true since #26002.
* Merge pull request #26002 from ↵Rafael França2016-08-171-6/+10
|\ | | | | | | | | kamipo/sql_for_insert_should_be_called_inside_exec_insert `sql_for_insert` should be called inside `exec_insert`
| * `sql_for_insert` should be called inside `exec_insert`Ryuta Kamizono2016-08-061-6/+10
| | | | | | | | | | `exec_insert` cannot return last inserted id if `use_insert_returning?` is true. `sql_for_insert` should be called inside `exec_insert`.
* | Add three new rubocop rulesRafael Mendonça França2016-08-163-3/+3
| | | | | | | | | | | | | | | | Style/SpaceBeforeBlockBraces Style/SpaceInsideBlockBraces Style/SpaceInsideHashLiteralBraces Fix all violations in the repository.
* | applies remaining conventions across the projectXavier Noria2016-08-061-34/+34
| |
* | normalizes indentation and whitespace across the projectXavier Noria2016-08-0613-161/+161
| |
* | applies new string literal convention in activerecord/libXavier Noria2016-08-0616-118/+118
|/ | | | | The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.
* Make `name` and `binds` to optional args for `exec_{insert,update,delete}`Ryuta Kamizono2016-08-041-2/+2
| | | | | | `insert`, `update`, `delete`, and `exec_query` have a default value against `name` and `binds`. But `exec_insert`, `exec_update`, and `exec_delete` not have. It is an inconvenience and inconsistent.
* Merge pull request #25340 from kamipo/prevent_table_comment_queryRafael França2016-07-281-0/+4
|\ | | | | Prevent `table_comment` query if a table doesn't have a comment
| * Prevent `table_comment` query if a table doesn't have a commentRyuta Kamizono2016-06-101-0/+4
| |