aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters
Commit message (Collapse)AuthorAgeFilesLines
* Clarify 'database does not exist' message and implementation.Jeremy Kemper2014-04-014-8/+8
| | | | | | | | | | | * 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
* PostgreSQL determine `Column#type` through corresponding OID. #7814Yves Senn2014-04-012-101/+91
| | | | | | | | | | | | | I ran the whole test suite and compared the old to the new types. Following is the list of types that did change with this patch: ``` DIFFERENT TYPE FOR mood: NEW: enum, BEFORE: DIFFERENT TYPE FOR floatrange: NEW: floatrange, BEFORE: float ``` The `floatrange` is a custom type. The old type `float` was simply a coincidence form the name `floatrange` and our type-guessing.
* refactor, put `PostgreSQLColumn` into `column.rb`.Yves Senn2014-03-312-218/+222
| | | | | We have `connection_adapters/column.rb` so it's easier to remember that the column in in a separate file.
* fix mysql buildsLuke Steensen2014-03-301-1/+1
|
* fix bug on non empty defaults for pg array columnsLuke Steensen2014-03-302-2/+8
| | | | fixes #10613
* No need to call to_symRafael Mendonça França2014-03-301-2/+2
| | | | It is already called inside type_to_sql method.
* Replace trivial regexp with string or index, twice as fastKelley Reynolds2014-03-281-1/+1
|
* Remove unused methodRafael Mendonça França2014-03-261-5/+0
| | | | | This method is not being called anywhere in our code and a GitHub search show it is not being used in any project.
* No need to gsub the stringRafael Mendonça França2014-03-261-1/+1
|
* Don't use send when we own the methodRafael Mendonça França2014-03-262-35/+35
|
* Make method privateRafael Mendonça França2014-03-261-5/+6
|
* Improve the methodRafael Mendonça França2014-03-261-5/+6
| | | | | | * cache `o.name` value * Avoid extra `concat` call * Avoid extra `<<` call
* Remove unneeded comments about feature support on the adaptersRafael Mendonça França2014-03-261-20/+9
| | | | | These comments will likely be outdated with time and doesn't include any information that can't be found in the adapters
* Invert the conditionals to make easier to readRafael Mendonça França2014-03-261-4/+4
| | | | Also improve some of the code conventions
* Fixes bugs for using indexes in CREATE TABLE by adding checks for table ↵Steve Rice2014-03-252-2/+2
| | | | | | | | existence Also: - updates tests by stubbing table_exists? method - adds entry for creating indexes in CREATE TABLE to changelog
* create indexes inline in CREATE TABLE for MySQLCody Cutrer2014-03-253-11/+36
| | | | | | | | This is important, because adding an index on a temporary table after it has been created would commit the transaction Conflicts: activerecord/CHANGELOG.md
* Postgres schema: Constrain sequence search classidJosh Williams2014-03-201-0/+1
| | | | | | | | | | | The pk_an_sequence_for query previously joined against pg_class's oid for rows in pg_depend, but pg_depend's objid may point to other system tables, such as pg_attrdef. If a row in one of those other tables coincidentally has the same oid as an (unrelated) sequence, that sequence name may be returned instead of the real one. This ensures that only the pg_depend entries pointing to pg_class are considered.
* Reap connections based on owning-thread deathMatthew Draper2014-03-183-46/+34
| | | | | | | | | | | | | | | | .. 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.
* Allow custom JDBC urlsschneems2014-03-141-2/+2
| | | | mitigates #14323
* No need to binds be optionalRafael Mendonça França2014-03-131-2/+2
|
* Make select_all on query cache accept a Relation without binds.Arthur Neves2014-03-132-12/+10
| | | | | [fixes #14361] [related #13886]
* Merge pull request #13040 from kamipo/case_sensitive_comparisonRafael Mendonça França2014-03-122-0/+13
|\ | | | | | | | | | | | | Only use BINARY for mysql case sensitive uniqueness check when column has a case insensitive collation. Conflicts: activerecord/CHANGELOG.md
| * Only use BINARY for mysql case sensitive uniqueness check when column has a ↵Ryuta Kamizono2013-11-262-0/+13
| | | | | | | | case insensitive collation.
* | MySQL 5.6 and later supports microsecond precision in datetime.Tatsuhiko Miyagawa2014-03-121-0/+8
| | | | | | | | | | You might want to branch it to include this only for 5.6, but passing these values to < 5.6 doesn't cause issues either.
* | `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-112-1/+9
| | | | | | | | citext makes it possible to use AR Hash finders for case-insensitive matching as sql UPPER/LOWER functions are not needed.
* | Merge pull request #14262 from sferik/flat_mapAndrew White2014-03-091-2/+2
|\ \ | | | | | | Replace additional instances of map.flatten with flat_map
| * | Replace map.flatten with flat_map in activerecordErik Michaels-Ober2014-03-031-2/+2
| | |
* | | Add Enum type to postgresql adapter's oids to prevent unknown OID warnings.Dieter Komendera2014-03-042-0/+12
|/ /
* | 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.
* | Add missing parantheses in index_exists?Yannick Schutz2014-02-251-1/+1
| |
* | Coerce strings when reading attributes.Yves Senn2014-02-232-7/+21
| |
* | deprecate support for pg ranges with excluding beginnings.Yves Senn2014-02-231-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The Ruby Range object does not support excluding beginnings. We currently support excluding beginnings for some subtypes using manually by incrementing them (now using the `#succ` method). This is approach is flawed as it's not equal to an excluding beginning. This commit deprecates the current support for excluding beginnings. It also raises an `ArgumentError` for subtypes that do not implement the `succ` method. This is a temporary solution to get rid of the broken state. We might still add complete support for excluding beginnings afterwards. (Probably with a new `PGRange` object, which acts like a `Range` but has excluding beginnings.
* | dynamically define PostgreSQL OID range types.Yves Senn2014-02-232-41/+37
| | | | | | | | | | | | | | | | 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.
* | Distinguish ConnectionNotEstablished messages: no conn pool for the class, ↵Jeremy Kemper2014-02-221-1/+4
| | | | | | | | or no conn available from the pool
* | Merge branch '4-1-0-beta2'Rafael Mendonça França2014-02-181-1/+5
|\ \ | | | | | | | | | | | | | | | Conflicts: actionview/CHANGELOG.md activerecord/CHANGELOG.md
| * | Correctly escape PostgreSQL arrays.Aaron Patterson2014-02-181-1/+5
| | | | | | | | | | | | | | | | | | Thanks Godfrey Chan for reporting this! Fixes: CVE-2014-0080
* | | Resolve encoding issues with arrays of hstore (bug 11135).Josh Goodall2014-02-172-7/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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/
* | | `execute` is a hotspot, so let's reduce branchesAaron Patterson2014-02-121-6/+2
| | |
* | | Reaper has access to threadsafe active? callKevin Casey2014-02-083-2/+13
| | |
* | | docs, AR already auto-detects primary keys. Closes #13946. [ci skip]Yves Senn2014-02-051-3/+3
| | | | | | | | | | | | | | | This behavior was introduced since Rails 3.1 (207f266ccaaa9cd04cd2a7513ae5598c4358b510) but the docs were still out of date.
* | | Merge pull request #13688 from jbaudanza/psql-index-existsRafael Mendonça França2014-02-011-0/+13
|\ \ \ | | | | | | | | | | | | | | | | | | | | | | | | PostgreSQL implementation of SchemaStatements#index_name_exists? Conflicts: activerecord/CHANGELOG.md
| * | | psql implementation of #index_name_exists?Jonathan Baudanza2014-01-161-0/+13
| | | |
* | | | Fixes issue with parsing whitespace content back from database - fixes #13907Mauricio Linhares2014-02-011-2/+3
| | | |
* | | | Fix regression on `.select_*` methods.Arthur Neves2014-01-306-18/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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]
* | | | Restore ActiveRecord states after a rollback for models w/o callbacksGodfrey Chan2014-01-181-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This fixes a regression (#13744) that was caused by 67d8bb9. In 67d8bb9, we introduced lazy rollback for records, such that the record's internal states and attributes are not restored immediately after a transaction rollback, but deferred until they are first accessed. This optimization is only performed when the model does not have any transactional callbacks (e.g. `after_commit` and `after_create`). Unfortunately, the models used to test the affected codepaths all comes with some sort of transactional callbacks. Therefore this codepath remains largely untested until now and as a result there are a few issues in the implementation that remains hidden until now. First, the `sync_with_transaction_state` (or more accurately, `update_attributes_from_transaction_state`) would perform the synchronization prematurely before a transaction is finalized (i.e. comitted or rolled back). As a result, when the actuall rollback happens, the record will incorrectly assumes that its internal states match the transaction state, and neglect to perform the restore. Second, `update_attributes_from_transaction_state` calls `committed!` in some cases. This in turns checks for the `destroyed?` state which also requires synchronization with the transaction stae, which causes an infnite recurrsion. This fix works by deferring the synchronization until the transaction has been finalized (addressing the first point), and also unrolled the `committed!` and `rolledback!` logic in-place (addressing the second point). It should be noted that the primary purpose of the `committed!` and `rolledback!` methods are to trigger the relevant transactional callbacks. Since this code path is only entered when there are no transactional callbacks on the model, this shouldn't be necessary. By unrolling the method calls, the intention here (to restore the states when necessary) becomes more clear.