aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
Commit message (Collapse)AuthorAgeFilesLines
* :scissors:Rafael Mendonça França2014-05-141-2/+0
|
* PostgreSQLAdapter::Utils seems to be only used from a single spot - quite ↵kares2014-05-141-19/+0
| | | | redundant
* move PostgreSQL's DatabaseStatements out of the PostgreSQLAdapter name-spacekares2014-05-141-6/+1
|
* PostgreSQL's SchemaStatements seems a could candidate for re-use (with AR-JDBC)kares2014-05-141-2/+5
|
* introduce AR::ConnectionAdapters::PostgreSQL for sharing modules (with AR-JDBC)kares2014-05-141-6/+11
| | | ... 'shared' OID, ArrayParser and Cast helpers, also re-arranged Column's dependencies
* extract pg type map initialization process to `TypeMapInitializer`.Yves Senn2014-05-131-65/+3
|
* Merge branch 'master' into adequaterecordAaron Patterson2014-04-201-0/+8
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * master: (74 commits) [ci skip] builtin -> built-in Fix code indentation and improve formatting Grammar fix in Getting Started Guide Make URL escaping more consistent Optimize URI escaping Always escape string passed to url helper. Remove statement assuming coffee shop/public space wifi is inherently insecure Don't rely on Arel master in bug report template [ci skip] wrap methods in backticks [ci skip] "subhash" --> "sub-hash" multibyte_conformance.rb --> multibyte_conformance_test.rb Fix inconsistent behavior from String#first/#last `@destroyed` should always be set to `false` when an object is duped. remove warning `warning: ambiguous first argument; put parentheses or even spaces` :uglify -> :uglifier Regression test for irregular inflection on has_many Singularize association names before camelization Fix spelling and proper nouns Optimize select_value, select_values, select_rows and dry up checking whether to exec with cache for Postgresql adapter Include default rails protect_from_forgery with: :exception ... Conflicts: activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb
| * Optimize select_value, select_values, select_rows and dry up checking ↵Kris Selden2014-04-171-0/+8
| | | | | | | | | | whether to exec with cache for Postgresql adapter Reduces creating unused objects, with the most dramatic reduction in select_values which used to map(&:first) an array of single element arrays.
* | Merge branch 'master' into adequaterecordAaron Patterson2014-04-141-3/+20
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * master: (70 commits) [ci skip] Added link to ruby-lang.org installation. Use the index on hidden field `collection_check_boxes` respects `:index` option for the hidden filed name. docs, double meaning of `serialize` argument. Closes #14284. Just call read_attribute, no need to use `send`. - Fix lingering reference to `:text` instead of the newer `:plain` - Section references `form_tag` instead of the `form_for` used in the example again, read_attribute is public, so just call it read_attribute is public, so we should just call it Disable assest cache store in docs [ci skip] Make counter cache decrementation on destroy idempotent Write the failing test case for concurrent counter cache [ci skip] Use plain underscore instead of "\_". Update documentation to use Rails.application instead Add a changelog entry for #14546 [ci skip] Move tests for deep_dup and duplicable to object directory Missing 'are' in note - [ci skip] CollectionHelpers now accepts a readonly option Fix a few typos [ci skip] Bundle tzinfo-data on :x64_mingw (64-bit Ruby on Windows). don't bother with an offset if the offset is zero ...
| * PostgreSQL, warn once per connection per missing OID. Closes #14275.Yves Senn2014-04-111-2/+2
| | | | | | | | [Yves Senn & Matthew Draper]
| * PostgreSQL, adapter automatically reloads it's type map. Closes #14678.Yves Senn2014-04-111-3/+20
| | | | | | | | [Yves Senn & Matthew Draper]
* | remove the bind visitor since the collector handles substituting bind valuesAaron Patterson2014-04-091-6/+2
|/
* 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.
* PostgreSQL, Support for materialized views. [Dave Lee & Yves Senn]Dave Lee2014-04-021-0/+4
| | | | | Expand the query used in #table_exists? to include materialized views in the kinds of relations it searches.
* Clarify 'database does not exist' message and implementation.Jeremy Kemper2014-04-011-2/+2
| | | | | | | | | | | * Clarify what the situation is and what to do. * Advise loading schema using `rake db:setup` instead of migrating. * Use a rescue in the initializer rather than extending the error message in-place. * Preserve the original backtrace of other errors by using `raise` rather than raising again with `raise error`. References 0ec45cd15d0a2f5aebc75e23d841b6c12f3ba763
* fix, adjust OID query without range support to include required fields.Yves Senn2014-04-011-3/+4
| | | | | This is a follow-up fix to f7a6b115fea9f675190a79b701c7034214678f19 and 06082f66d541e581110406bbac3bc395bace3f86
* refactor, use `typtype` instead of `typinput` to segment PG types.Yves Senn2014-04-011-3/+3
|
* PostgreSQL, register custom domains. Closes #14305.Yves Senn2014-04-011-1/+11
| | | | | | | This patch registers custom domains in our OID-type_map. They will behave exactly as the type specified by `pg_type.typbasetype`. /cc @matthewd
* refactor, put `PostgreSQLColumn` into `column.rb`.Yves Senn2014-03-311-218/+1
| | | | | We have `connection_adapters/column.rb` so it's easier to remember that the column in in a separate file.
* Reap connections based on owning-thread deathMatthew Draper2014-03-181-4/+0
| | | | | | | | | | | | | | | | .. not a general timeout. Now, if a thread checks out a connection then dies, we can immediately recover that connection and re-use it. This should alleviate the pool exhaustion discussed in #12867. More importantly, it entirely avoids the potential issues of the reaper attempting to check whether connections are still active: as long as the owning thread is alive, the connection is its business alone. As a no-op reap is now trivial (only entails checking a thread status per connection), we can also perform one in-line any time we decide to sleep for a connection.
* Teach PostgreSQLAdapter#reset! to actually resetMatthew Draper2014-03-181-1/+6
| | | | It wasn't doing anything beyond clearing the statement cache.
* `change_table` supports `citext`. Follow up to #12523.Yves Senn2014-03-111-0/+4
|
* register OID for PostgreSQL citex datatype [Troy Kruthoff & Lachlan Sylvester]lsylvester2014-03-111-1/+8
| | | | citext makes it possible to use AR Hash finders for case-insensitive matching as sql UPPER/LOWER functions are not needed.
* Add Enum type to postgresql adapter's oids to prevent unknown OID warnings.Dieter Komendera2014-03-041-0/+6
|
* Fix warnings due to:Vipul A M2014-03-031-1/+1
| | | | | - unused variable in PG Adapter. - Ambiguous argument warning from range_test for use - to + Infinity range without brackets.
* dynamically define PostgreSQL OID range types.Yves Senn2014-02-231-5/+23
| | | | | | | | This gets AR working with custom defined range types. It also removes the need for subtype specific branches in `OID::Range`. This expands the interface of all `OID` types with the `infinity` method. It's responsible to provide a value for positive and negative infinity.
* Reaper has access to threadsafe active? callKevin Casey2014-02-081-1/+6
|
* Fix regression on `.select_*` methods.Arthur Neves2014-01-301-8/+0
| | | | | | | | | | | | | | | | | | This was a common pattern: ``` query = author.posts.select(:title) connection.select_one(query) ``` However `.select` returns a ActiveRecord::AssociationRelation, which has the bind information, so we can use that to get the right sql query. Also fix select_rows on postgress and sqlite3 that were not using the binds [fixes #7538] [fixes #12017] [related #13731] [related #12056]
* fix exception translationAaron Patterson2014-01-171-1/+1
|
* translate exceptions on prepared statement failureAaron Patterson2014-01-171-1/+5
|
* Make change_table use object of current database adapterNishant Modak2014-01-071-5/+5
| | | | | | | | | - 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
* Do not consider PG array columns as number or text columnsCarlos Antonio da Silva2013-12-231-1/+9
| | | | | | | | | | | | | | | | | | | | | | | 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.
* Tell how to Create a Database in Error Messageschneems2013-12-231-0/+6
| | | | | | | | | | | | | | | | Currently if you attempt to use a database that does not exist you get an error: ``` PG::ConnectionBad FATAL: database "db_error" does not exist ``` The solution is easy, create and migrate your database however new developers may not know these commands by memory. Instead of requiring the developer to search for a solution, tell them how to fix the problem in the error message: ``` ActiveRecord::NoDatabase: FATAL: database "db_error" does not exist Run `$ bin/rake db:create db:migrate` to create your database ``` Active Record should not know about `rake db:migrate` so this additional information needs to come from the railtie. Potential alternative implementation suggestions are welcome.
* Fix PostgreSQL insert to properly extract table name from multiline string SQL.Kuldeep Aggarwal2013-12-191-1/+1
| | | | | | | | | | | | Previously, executing an insert SQL in PostgreSQL with a command like this: insert into articles( number) values( 5152 ) would not work because the adapter was unable to extract the correct articles table name.
* support creating temporary tables from queriesCody Cutrer2013-12-141-2/+2
| | | | | also override drop_table in AbstractMySQLAdapter to properly drop temporary tables without committing the transaction
* fix pg warnings on geometric typesAaron Patterson2013-12-051-10/+23
|
* make the type_map per connection. fixes #13182Aaron Patterson2013-12-041-11/+16
|
* Drop a sqlite_version check because we only support SQLite 3.6.16 or newer.Ben Woosley2013-11-121-1/+0
| | | Drop some comments that document the implementation rather than the interface.
* Don't use Active Support where we don't need toRafael Mendonça França2013-11-091-1/+1
|
* log bind variables after they were type casted.Yves Senn2013-11-091-4/+5
| | | | | | | | | | | | | | | The log output used to be confusing in situation where type casting has "unexpected" effects. For example when finding records with a `String`. BEFORE: irb(main):002:0> Event.find("im-no-integer") D, [2013-11-09T11:10:28.998857 #1706] DEBUG -- : Event Load (4.5ms) SELECT "events".* FROM "events" WHERE "events"."id" = $1 LIMIT 1 [["id", "im-no-integer"]] AFTER: irb(main):002:0> Event.find("im-no-integer") D, [2013-11-09T11:10:28.998857 #1706] DEBUG -- : Event Load (4.5ms) SELECT "events".* FROM "events" WHERE "events"."id" = $1 LIMIT 1 [["id", 0]]
* `ActiveRecord::Store` works together with PG `hstore` columns.Yves Senn2013-10-251-0/+4
| | | | | | 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.
* Escape the parentheses in the default function regexpRafael Mendonça França2013-10-211-1/+1
| | | | | | | This is causing every default value in PostreSQL database to being handled as default function. Fixes #12581
* Extract a function to determine if the default value is a functionRafael Mendonça França2013-10-141-1/+5
|
* Push default_function to superclass to avoid method checkRafael Mendonça França2013-10-141-3/+5
|
* log the statement name along with the SQLAaron Patterson2013-10-041-1/+1
|
* log every sql statement, even when they errorAaron Patterson2013-10-041-25/+25
|
* prepare the statement inside the begin / rescue blockAaron Patterson2013-10-041-4/+4
|
* wrap logging around the actual query call itself.Aaron Patterson2013-10-041-25/+29
| | | | This is to be consistent with the way the mysql2 adapter times queries
* extract adapter savepoint implementations into `abstract/savepoints.rb`.Yves Senn2013-09-301-5/+1
|
* Merge pull request #11382 from kennyj/fix_10751-2Rafael Mendonça França2013-09-221-3/+6
|\ | | | | | | | | | | | | Dump UUID default functions to schema.rb [2nd version]. Fixes #10751. Conflicts: activerecord/CHANGELOG.md