aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/adapters/postgresql/connection_test.rb
Commit message (Collapse)AuthorAgeFilesLines
* Merge pull request #29732 from kirs/frozen-activerecordRafael França2017-07-211-0/+2
|\ | | | | Use frozen-string-literal in ActiveRecord
| * Use frozen-string-literal in ActiveRecordKir Shatrov2017-07-191-0/+2
| |
* | Revert "Extract `bind_param` and `bind_attribute` into `ActiveRecord::TestCase`"Sean Griffin2017-07-211-2/+2
|/ | | | | | | | This reverts commit b6ad4052d18e4b29b8a092526c2beef013e2bf4f. This is not something that the majority of Active Record should be testing or care about. We should look at having fewer places rely on these details, not make it easier to rely on them.
* Revert "Merge pull request #29540 from kirs/rubocop-frozen-string"Matthew Draper2017-07-021-1/+0
| | | | | This reverts commit 3420a14590c0e6915d8b6c242887f74adb4120f9, reversing changes made to afb66a5a598ce4ac74ad84b125a5abf046dcf5aa.
* Enforce frozen string in RubocopKir Shatrov2017-07-011-0/+1
|
* Prevent extra `current_database` query for `encoding`/`collation`/`ctype`Ryuta Kamizono2017-05-281-3/+9
|
* Extract `bind_param` and `bind_attribute` into `ActiveRecord::TestCase`Ryuta Kamizono2017-05-041-2/+2
| | | | These are used in tests from anywhere.
* Use `max_identifier_length` for `index_name_length` in PostgreSQL adapterRyuta Kamizono2017-02-271-2/+1
| | | | | Actually `index_name_length` depend on `max_identifier_length`, not always 63.
* Use ensure block for things we cleanup in testsKir Shatrov2017-02-251-0/+1
|
* Reduce string objects by using \ instead of + or << for concatenating stringsAkira Matsuda2017-01-121-2/+2
| | | | (I personally prefer writing one string in one line no matter how long it is, though)
* Deprecate passing `name` to `indexes` like `tables`Ryuta Kamizono2017-01-041-1/+1
| | | | | Passing `name` to `tables` is already deprecated at #21601. Passing `name` to `indexes` is also unused.
* `#tables` and `#table_exists?` and returns only tables and not viewsRafael Mendonça França2016-12-291-1/+1
|
* Remove deprecated `name` argument from `#tables`Rafael Mendonça França2016-12-291-1/+1
|
* Privatize unneededly protected methods in Active Record testsAkira Matsuda2016-12-241-1/+1
|
* Add three new rubocop rulesRafael Mendonça França2016-08-161-6/+6
| | | | | | | | Style/SpaceBeforeBlockBraces Style/SpaceInsideBlockBraces Style/SpaceInsideHashLiteralBraces Fix all violations in the repository.
* normalizes indentation and whitespace across the projectXavier Noria2016-08-061-6/+6
|
* remove redundant curlies from hash argumentsXavier Noria2016-08-061-4/+4
|
* modernizes hash syntax in activerecordXavier Noria2016-08-061-4/+4
|
* applies new string literal convention in activerecord/testXavier Noria2016-08-061-37/+37
| | | | | The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.
* Fix tests failure with `prepared_statements: false`Ryuta Kamizono2016-02-291-8/+10
| | | | | | Some tests does not work for unprepared statements. Add `if ActiveRecord::Base.connection.prepared_statements` and fix a regex for fix tests failure with `prepared_statements: false`.
* Rename 'key' to 'lock_id' or 'lock_name' for advisory lockingSam Davies2015-11-181-10/+10
| | | | | | | | | - key was a poor choice of name. A key implies something that will unlock a lock. The concept is actually more like a 'lock identifier' - mysql documentation calls this a 'lock name' - postgres documentation calls it a 'lock_id' - Updated variable names to reflect the preferred terminology for the database in question
* Deprecate `#table_exists?`, `#tables` and passing arguments to `#talbes`yui-knk2015-11-091-2/+2
| | | | | | | | | | Reported on #21509, how views is treated by `#tables` are differ by each adapters. To fix this different behavior, after Rails 5.0 is released, deprecate `#tables`. And `#table_exists?` would check both tables and views. To make their behavior consistent with `#tables`, after Rails 5.0 is released, deprecate `#table_exists?`.
* Use advisory locks to prevent concurrent migrationsSam Davies2015-10-301-0/+42
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Addresses issue #22092 - Works on Postgres and MySQL - Uses advisory locks because of two important properties: 1. The can be obtained outside of the context of a transaction 2. They are automatically released when the session ends, so if a migration process crashed for whatever reason the lock is not left open perpetually - Adds get_advisory_lock and release_advisory_lock methods to database adapters - Attempting to run a migration while another one is in process will raise a ConcurrentMigrationError instead of attempting to run in parallel with undefined behavior. This could be rescued and the migration could exit cleanly instead. Perhaps as a configuration option? Technical Notes ============== The Migrator uses generate_migrator_advisory_lock_key to build the key for the lock. In order to be compatible across multiple adapters there are some constraints on this key. - Postgres limits us to 64 bit signed integers - MySQL advisory locks are server-wide so we have to scope to the database - To fulfil these requirements we use a Migrator salt (a randomly chosen signed integer with max length of 31 bits) that identifies the Rails migration process as the owner of the lock. We multiply this salt with a CRC32 unsigned integer hash of the database name to get a signed 64 bit integer that can also be converted to a string to act as a lock key in MySQL databases. - It is important for subsequent versions of the Migrator to use the same salt, otherwise different versions of the Migrator will not see each other's locks.
* Do not cache prepared statements that are unlikely to have cache hitsSean Griffin2015-10-201-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Prior to this commit, Rails makes no differentiation between whether a query uses bind parameters, and whether or not we cache that query as a prepared statement. This leads to the cache populating extremely fast in some cases, with the statements never being reused. In particular, the two problematic cases are `where(foo: [1, 2, 3])` and `where("foo = ?", 1)`. In both cases we'll end up quoting the values rather than using a bind param, causing a cache entry for every value ever used in that query. It was noted that we can probably eventually change `where("foo = ?", 1)` to use a bind param, which would resolve that case. Additionally, on PG we can change our generated query to be `WHERE foo = ANY($1)`, and pass an array for the bind param. I hope to accomplish both in the future. For SQLite and MySQL, we still end up preparing the statements anyway, we just don't cache it. The statement will be cleaned up after it is executed. On postgres, we skip the prepare step entirely, as an API is provided to execute with bind params without preparing the statement. I'm not 100% happy on the way this ended up being structured. I was hoping to use a decorator on the visitor, rather than mixing a module into the object, but the way Arel has it's visitor pattern set up makes it very difficult to extend without inheritance. I'd like to remove the duplication from the various places that are extending it, but that'll require a larger restructuring of that initialization logic. I'm going to take another look at the structure of it soon. This changes the signature of one of the adapter's internals, and will require downstream changes from third party adapters. I'm not too worried about this, as worst case they can simply add the parameter and always ignore it, and just keep their previous behavior. Fixes #21992.
* make it possible to run AR tests with bin/testYves Senn2015-06-111-1/+1
|
* `Type#type_cast_from_database` -> `Type#deserialize`Sean Griffin2015-02-171-1/+1
|
* Remove Relation#bind_paramsSean Griffin2015-01-271-3/+3
| | | | | | | | `bound_attributes` is now used universally across the board, removing the need for the conversion layer. These changes are mostly mechanical, with the exception of the log subscriber. Additional, we had to implement `hash` on the attribute objects, so they could be used as a key for query caching.
* Pass symbol as an argument instead of a blockErik Michaels-Ober2014-11-291-3/+1
|
* add a truncate method to the connectionAaron Patterson2014-09-221-0/+10
| | | | | | it doesn't work on SQLite3 since it doesn't support truncate, but that's OK. If you call truncate on the connection, you're now bound to that database (same as if you use hstore or any other db specific feature).
* Rename `type_cast` to `type_cast_from_database`Sean Griffin2014-06-091-1/+1
| | | | | | | | 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.
* Add ConnectionHelper to refactor tests.Guo Xiang Tan2014-04-031-12/+3
|
* Fix tests not unsubscribing from Notifications.Guo Xiang Tan2014-03-281-2/+2
| | | | See https://github.com/rails/rails/blob/master/activesupport/lib/active_support/notifications.rb#L131
* Teach PostgreSQLAdapter#reset! to actually resetMatthew Draper2014-03-181-0/+31
| | | | It wasn't doing anything beyond clearing the statement cache.
* Terminate the backend ourselves on PG 9.2+Matthew Draper2014-02-121-19/+29
| | | | This should make it harder to accidentally break this test.
* Don't skip tests if we don't need to.Rafael Mendonça França2013-11-081-20/+20
| | | | | | | We can conditional define the tests depending on the adapter or connection. Lets keep the skip for fail tests that need to be fixed.
* log the statement name along with the SQLAaron Patterson2013-10-041-0/+10
|
* stop adding singleton methods to the mysql2 adapterAaron Patterson2013-10-041-15/+0
|
* stop adding singleton methods to the PG connectionAaron Patterson2013-10-041-11/+26
|
* Delete failing testJon Leighton2013-03-221-36/+0
| | | | | | | | | | | | I don't think this is testing anything useful, and the test code is exceedingly brittle. It is broken since 34c7e73c1def1312e59ef1f334586ff2f668246e because the test code makes assumptions about the implementation of PostgreSQLAdapter#active? which are incorrect after the commit. I could fix this test but it would be even more brittle (by stubbing the underlying @connection.connect_poll) and it doesn't test any complex logic. I conclude that it's not worth it.
* class_eval should use __FILE__ and __LINE__Neeraj Singh2013-01-301-1/+1
|
* Session variables for mysql, mysql2, and postgresql adapters can be setAaron Stone2012-12-081-0/+41
| | | | | | | | | in the new 'variables:' hash in each database config section in database.yml. The key-value pairs of this hash will be sent in a 'SET key = value, ...' query on new database connections. The configure_connection methods from mysql and mysql2 into are consolidated into the abstract_mysql base class.
* Fix only-once stub logic.Steve Jorgensen2012-08-081-1/+1
| | | | | Didn't fail the test because adapter#query happens to not call raw connection's #query, but don't want to count on that and have a fragile test.
* Fix just-plain-wrongness of psql auto-reconnect test.Steve Jorgensen2012-08-071-8/+9
| | | | | | Full test requiring manual intervention was fine, but w/ simulated disconnect, assertion was backward & still passing. Was several kinds of wrong.
* Stop being silly with formatting of method aliasing.Steve Jorgensen2012-07-161-3/+3
|
* Simulated & actual (manual/skipped) PostgreSQL auto-reconnection tests.Steve Jorgensen2012-07-161-0/+72
|
* Unify the collation API for the database adptersRafael Mendonça França2012-07-011-2/+2
|
* Support collate and ctype on the PostgreSQL.kennyj2012-06-291-0/+8
|
* Change minimum (default) log level in PostgreSQL to warning.kennyj2012-06-181-0/+4
|
* Fix logs name consistency.kennyj2012-05-191-0/+44
|
* Postgresql: add test case for setting custom libpq connection parametersLars Kanis2012-01-041-0/+15
|