aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters
Commit message (Collapse)AuthorAgeFilesLines
* Don't rely on Hash key's orderingVitor Baptista2013-01-162-3/+5
| | | | | | | | | | | | | | | | | | | If we set encoding latin1 for a PostgreSQL database, it calls PostgreSQLAdapter::create_database with options that have, among other things: { 'encoding' => 'latin1' } Then, we use reverse_merge(:encoding => "utf8") to setup the default encoding. In the end, the hash looks like: { :encoding => 'utf8', 'encoding' => 'latin1' } The call to options.symbolize_keys calls to_sym on each_key of this Hash. It usually means that the encoding passed overwrites the default utf8, but it's not guaranteed. So, we shouldn't rely on it. The same was happening in ActiveRecord::ConnectionHandling.
* Use whitelist to pass valid connection parameters to PGConn.Rafael Mendonça França2013-01-061-7/+10
| | | | | | | | | All the valids parameters for libpq are used. See http://www.postgresql.org/docs/9.1/static/libpq-connect.html for the full list Fixes #8784
* Remove the configuration key in the correct placeRafael Mendonça França2013-01-061-3/+1
|
* Fix error when assigning NaN to an integer columnTristan Harward2013-01-061-5/+1
| | | | | | | | | Also covers any non-castable case by returning nil, which is in-line with the intention of the former implementation, but covers the odd cases which respond to to_i but raise an error when it's called, such as NaN, Infinity and -Infinity. Fixes #8757
* These are already required through AS/railsAkira Matsuda2013-01-073-4/+0
| | | | | | * dependencies/autoload * concern * deprecation
* Remove unnecessary begin..rescue..end, use only rescueAkira Matsuda2013-01-061-25/+23
|
* Support for PostgreSQL's ltree data type.Rob Worley2013-01-042-1/+9
|
* Reuse the Column integer converterRafael Mendonça França2013-01-031-1/+1
|
* Fix undefined method `to_i' introduced since 3.2.8Jason Stirk2013-01-041-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit fixes a bug introduced in 96a13fc7 which breaks behaviour of integer fields. In 3.2.8, setting the value of an integer field to a non-integer (eg. Array, Hash, etc.) would default to 1 (true) : # 3.2.8 p = Post.new p.category_id = [ 1, 2 ] p.category_id # => 1 p.category_id = { 3 => 4 } p.category_id # => 1 In 3.2.9 and above, this will raise a NoMethodError : # 3.2.9 p = Post.new p.category_id = [ 1, 2 ] NoMethodError: undefined method `to_i' for [1, 2]:Array Whilst at first blush this appear to be sensible, it combines in bad ways with scoping. For example, it is common to use scopes to control access to data : @collection = Posts.where(:category_id => [ 1, 2 ]) @new_post = @collection.new In 3.2.8, this would work as expected, creating a new Post object (albeit with @new_post.category_id = 1). However, in 3.2.9 this will cause the NoMethodError to be raised as above. It is difficult to avoid triggering this error without descoping before calling .new, breaking any apps running on 3.2.8 that rely on this behaviour. This patch deviates from 3.2.8 in that it does not retain the somewhat spurious behaviour of setting the attribute to 1. Instead, it explicitly sets these invalid values to nil : p = Post.new p.category_id = [ 1, 2 ] p.category_id # => nil This also fixes the situation where a scope using an array will "pollute" any newly instantiated records. @new_post = @collection.new @new_post.category_id # => nil Finally, 3.2.8 exhibited a behaviour where setting an object to an integer field caused it to be coerced to "1". This has not been retained, as it is spurious and surprising in the same way that setting Arrays and Heshes was : c = Category.find(6) p = Post.new # 3.2.8 p.category_id = c p.category_id # => 1 # This patch p.category_id = c p.category_id # => nil This commit includes explicit test cases that expose the original issue with calling new on a scope that uses an Array. As this is a common situation, an explicit test case is the best way to prevent regressions in the future. It also updates and separates existing tests to be explicit about the situation that is being tested (eg. AR objects vs. other objects vs. non-integers)
* small refactoring, added blob_or_text_colum? in AbstractMysqlAdapterAngelo Capilleri2012-12-281-2/+6
|
* Fixes for PR [#8267]Marc-Andre Lafortune2012-12-221-3/+6
| | | | | | | | * Fix Migration#reversible by not using `transaction`. * Adapt mysql adapter to updated api for remove_column * Update test after aedcd683684d08eaf30623a4b48ce31a31426372
* Fix calling quote column name in interpolated stringCarlos Antonio da Silva2012-12-211-1/+1
|
* Differentiate between remove_column and remove_columns. Make remove_column ↵Marc-Andre Lafortune2012-12-213-14/+23
| | | | | | reversible. [#8267]
* Make drop_table reversible [#8267]Marc-Andre Lafortune2012-12-211-0/+4
|
* Add drop_join_table [#8267]Marc-Andre Lafortune2012-12-211-0/+11
|
* Simplify change_table and avoid duplicated logicMarc-Andre Lafortune2012-12-211-14/+2
|
* Keep index names when using with sqlite3Yves Senn2012-12-191-2/+1
|
* #5523 Add ability for postgresql adapter to disable user triggers in ↵Gary S. Weaver2012-12-181-4/+12
| | | | disable_referential_integrity.
* AR supporting new int4range and int8range data type on PostgreSQL >= 9.2. ↵Alexey2012-12-171-4/+11
| | | | Fix realization
* AR supporting new intrange data type on PostgreSQL >= 9.2Alexey2012-12-166-4/+68
|
* Merge pull request #8510 from thedarkone/thread_safety_improvementsAaron Patterson2012-12-141-9/+16
|\ | | | | Thread safety improvements
| * Replace some global Hash usages with the new thread safe cache.thedarkone2012-12-141-9/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary of the changes: * Add thread_safe gem. * Use thread safe cache for digestor caching. * Replace manual synchronization with ThreadSafe::Cache in Relation::Delegation. * Replace @attribute_method_matchers_cache Hash with ThreadSafe::Cache. * Use TS::Cache to avoid the synchronisation overhead on listener retrieval. * Replace synchronisation with TS::Cache usage. * Use a preallocated array for performance/memory reasons. * Update the controllers cache to the new AS::Dependencies::ClassCache API. The original @controllers cache no longer makes much sense after @tenderlove's changes in 7b6bfe84f3 and f345e2380c. * Use TS::Cache in the connection pool to avoid locking overhead. * Use TS::Cache in ConnectionHandler.
* | Deprecate obsolete Time to DateTime fallback methodsAndrew White2012-12-111-1/+1
|/ | | | | | | The Time.time_with_datetime_fallback, Time.utc_time and Time.local_time methods were added to handle the limitations of Ruby's native Time implementation. Those limitations no longer apply so we are deprecating them in 4.0 and they will be removed in 4.1.
* Move to the schema-migrations-metadata branch.Jeremy Kemper2012-12-091-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | Pending work on graceful app upgrades. Revert "Merge pull request #8439 from joshsusser/fixes" This reverts commit ce8ac39338f86388e70356b3a470b3ea443802ae, reversing changes made to b0e7b6f67c984d4b1502e801781ed75fad681633. Revert "Merge pull request #8431 from joshsusser/schemadump" This reverts commit 036d3e1c2b65c4b8cbd23de2e20ad67b9b756182, reversing changes made to 0c692f4d121792117b6a71e5ed590a31c3b9d12e. Revert "Merge branch 'joshsusser-master' into merge" This reverts commit 0c692f4d121792117b6a71e5ed590a31c3b9d12e, reversing changes made to 2e299fca715b083a60222a85e48f9d3b8dd8ce93. Conflicts: activerecord/CHANGELOG.md activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb activerecord/test/cases/schema_dumper_test.rb
* Session variables for mysql, mysql2, and postgresql adapters can be setAaron Stone2012-12-084-34/+61
| | | | | | | | | 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.
* revises a RDoc example to make it idiomaticXavier Noria2012-12-071-8/+8
| | | | | | The force flag suggests the original was probably copied from some db/schema.rb. Thanks to Josh Susser for spotting and reporting this.
* Use CURRENT_TIMESTAMP since it has apparently better cross db supportCarlos Antonio da Silva2012-12-061-1/+1
| | | | | LOCALTIMESTAMP is not support by sqlite3, and travis was giving us these errors: https://travis-ci.org/rails/rails/jobs/3535241/#L570
* Merge branch 'joshsusser-master' into mergeAaron Patterson2012-12-051-4/+4
|\ | | | | | | | | | | | | | | | | | | | | * joshsusser-master: style cleanup Add migration history to schema.rb dump Add metadata to schema_migrations Conflicts: activerecord/CHANGELOG.md activerecord/lib/active_record/schema.rb
| * Add migration history to schema.rb dumpJosh Susser2012-12-021-2/+2
| |
| * Add metadata to schema_migrationsJosh Susser2012-12-011-3/+3
| | | | | | | | | | migrated_at: timestamp when migration run fingerprint: md5 hash of migration source name: filename without version or extension
* | Fix #8414. Performance problem with postgresql adapter primary_key function.kennyj2012-12-051-3/+2
| |
* | pg_namespace table isn't used.kennyj2012-12-051-1/+0
|/
* Fix memory leak in development modeJon Leighton2012-11-301-8/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Keying these hashes by klass causes reloadable classes to never get freed. Thanks to @thedarkone for pointing this out in the comments on 221571beb6b4bb7437989bdefaf421f993ab6002. This doesn't seem to make a massive difference to performance. Benchmark --------- require 'active_record' require 'benchmark/ips' class Post < ActiveRecord::Base establish_connection adapter: 'sqlite3', database: ':memory:' end GC.disable Benchmark.ips(20) do |r| r.report { Post.connection } end Before ------ Calculating ------------------------------------- 5632 i/100ms ------------------------------------------------- 218671.0 (±1.9%) i/s - 4364800 in 19.969401s After ----- Calculating ------------------------------------- 8743 i/100ms ------------------------------------------------- 206525.9 (±17.8%) i/s - 4039266 in 19.992590s
* schema cache already has the columns as a hash, so use thatAaron Patterson2012-11-252-2/+12
|
* speed up fixture loading by querying the schema cache for column namesAaron Patterson2012-11-252-2/+11
|
* TypoChris Patuzzo2012-11-211-1/+1
|
* Merge pull request #6245 from bogdan/bc_timestampRafael Mendonça França2012-11-212-3/+9
|\ | | | | Postgresql adapter: fix handling of BC timestamps
| * Fix postgresql adapter to handle bc timestamps correctlyBogdan Gusiev2012-11-212-3/+9
| |
* | Refactoring, testing and documenting pg_connection.distinctSemyon Perepelitsa2012-11-211-13/+10
|/
* Postgresql doesn't accepts limits on text columns.Victor Costan2012-11-201-0/+7
|
* Be a bit less conservative with mysql in adapterCarlos Antonio da Silva2012-11-191-1/+1
|
* Add rename_index to change_table.Jarek Radosz2012-11-191-0/+8
|
* Bump mysql gem version to the newly 2.9.0, fix build.Carlos Antonio da Silva2012-11-171-1/+1
|
* Properly deprecate ConnectionHandler#connection_poolsJon Leighton2012-11-091-6/+14
| | | | | | | | Rather than just changing it and hoping for the best. Requested by @jeremy: https://github.com/rails/rails/commit/ba1544d71628abff2777c9c514142d7e9a159111#commitcomment-2106059
* Check if the options value is present before to send the deprecationRafael Mendonça França2012-11-031-4/+6
| | | | message
* Remove old commentRafael Mendonça França2012-11-021-1/+1
| | | | | | | | | | | | | | | This comment is not valid since that `if` is there to make possible to do: remove_index :users, :name Instead of: remove_index :users, column: :name What is a valid use case. [ci skip]
* Deprecate passing a string as third argument of `add_index`Rafael Mendonça França2012-11-021-0/+6
| | | | | | | This was there due historical reasons since 7dc45818dc43c163700efc9896a0f3feafa31138 to give the user the possibility to create unique indexes passing "UNIQUE" as the third argument
* Raise an ArgumentError when passing an invalid option to add_indexRafael Mendonça França2012-11-021-1/+4
| | | | Closes #8104
* Merge branch 'master' of github.com:lifo/docrailsVijay Dev2012-11-036-50/+50
|\ | | | | | | | | | | | | Conflicts: actionpack/lib/action_controller/metal/mime_responds.rb activerecord/lib/active_record/attribute_methods.rb guides/source/working_with_javascript_in_rails.md
| * Migration of docs to 1.9 hash syntaxAvnerCohen2012-10-236-50/+50
| |