aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters
Commit message (Collapse)AuthorAgeFilesLines
* activerecord: Fix identity for sum of strings3-2-stable-for-hmnoHarald Eilertsen2019-08-061-1/+1
|
* Remove `DEFAULT NULL` for primary key column to support MySQL 5.7.3Yasuo Honda2017-01-171-1/+1
| | | | | | Since MySQL 5.7.3 m13 does now allow primary key column is null. (cherry picked from commit b6655885ef13cf8d1705dc9b5232846f0207febd)
* Fix raising uniqueness constraints in newer versions of SQLiteAndrew White2016-11-021-1/+5
| | | | | Versions 3.8.2 and later of SQLite changed the formatting of the error messages returned when a uniqueness constraint was violated.
* Fix deprecation warnings on URI.unescapeAndrew White2016-11-021-1/+2
|
* Check against bit string values using multiline regexpRafael Mendonça França2014-07-021-3/+3
| | | | Fix CVE-2014-3482.
* on SchemaCache use the connection getter instead of the obj givenArthur Neves2013-09-091-2/+2
|
* Do not shallow the original exception in exec_cacheRafael Mendonça França2013-07-091-1/+5
| | | | | | | when result_error_field is not defined on result raise the original exception. Fixes #11260
* Merge pull request #10925 from senny/10917_test_to_prevent_regressionYves Senn2013-06-151-3/+5
| | | | | | | regression test + mysql2 adapter raises correct error if conn is closed. Conflicts: activerecord/CHANGELOG.md
* Correctly parse bigint defaults in PostgreSQL, Backpost #10098.Erik Peterson2013-04-111-1/+1
| | | | | | | | Conflicts: activerecord/CHANGELOG.md activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb activerecord/test/cases/schema_dumper_test.rb
* Wrong exception is occured when raising no translatable exceptionkennyj2013-03-201-0/+2
| | | | | Conflicts: activerecord/CHANGELOG.md
* Don't crash exception translation w/ nil result attribute.Steve Jorgensen2013-03-201-1/+1
| | | | | | Exception.result is nil when attempting a query after PostgreSQL disconnect, resulting in new exception: NoMethodError: undefined method `error_field' for nil:NilClass
* Update docs, change_table does not use TableDefinition.Yves Senn2013-02-281-2/+2
| | | | | | | [ci skip] Conflicts: activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb
* Revert "Merge pull request #9208 from dylanahsmith/3-2-mysql-quote-numeric"Steve Klabnik2013-02-262-8/+4
| | | | This reverts commit 921a296a3390192a71abeec6d9a035cc6d1865c8.
* Sqlite preserves primary keys when copying/altering tables.Yves Senn2013-02-231-2/+6
| | | | | | | | Backport #2312. Fixes #9367. I also added a test-case to make sure that renaming or removing a column preserves the primary key.
* active_record: Quote numeric values compared to string columns.Dylan Smith2013-02-072-4/+8
|
* Revert "Work around undiagnosed bug that's draining a relation's bind_values"Carlos Antonio da Silva2013-01-151-1/+0
| | | | This reverts commit 06cc38a2b0d4778746e8a2a2e2b6aa07e1c1c075.
* Revert "Merge pull request #7983 from georgebrock/bug7950-squashed"Carlos Antonio da Silva2013-01-151-4/+4
| | | | | | | | | | | This reverts commit 88a296dccc401da143d90cad54b693ff06bf2b58, reversing changes made to 666a7e34f553cef4c8878362eafc79c7e3f310c3. Conflicts: activerecord/CHANGELOG.md Reason: this has been resulting in some hard to track bugs and is introducing a possible breackage in a stable version.
* connection_parameters is an Array and will never haveRafael Mendonça França2013-01-061-2/+0
| | | | prepared_statements as value
* 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 Backport of #8781 Conflicts: activerecord/CHANGELOG.md activerecord/test/cases/column_test.rb
* 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. 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)
* Backport #8522, Keep index names when using with sqlite3Yves Senn2012-12-191-1/+1
| | | | | | | | Conflicts: activerecord/CHANGELOG.md activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb activerecord/test/cases/migration/rename_column_test.rb
* Merge pull request #8417 from kennyj/fix_8414Rafael Mendonça França2012-12-041-3/+2
| | | | | | Fix #8414. Performance problem with postgresql adapter primary_key function. Conflicts: activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb
* Merge pull request #6397 from kennyj/fix_translate_exceptionAaron Patterson2012-11-301-3/+7
| | | | Fix a problem of translate_exception method in a Japanese (non English) environment.
* Work around undiagnosed bug that's draining a relation's bind_valuesJeremy Kemper2012-11-281-0/+1
|
* schema cache already has the columns as a hash, so use thatAaron Patterson2012-11-261-1/+20
| | | | | | | | | | | | | | | | | | | | | Commits 978ec98c8eff824a60c7e973f369cc7bed1f4d36 and 51676652a3568ad09b06385564de4fdcb13af05e changed database statements to use the schema_cache methods, added on master in c99e34e90d763c52cbe8dc3d950ed1b4db665dc4 and dc973e78560a6514ab172f0ee86dc84a9147d39a But apparently the methods weren't added to schema_cache, resulting in the failure described in #8322 for 3-2-stable. Fixes #8322. Conflicts: activerecord/lib/active_record/connection_adapters/schema_cache.rb
* schema cache already has the columns as a hash, so use thatAaron Patterson2012-11-251-1/+1
|
* speed up fixture loading by querying the schema cache for column namesAaron Patterson2012-11-251-1/+1
|
* Merge pull request #8276 from pwnall/pgsql_text_limitsRafael Mendonça França2012-11-201-0/+7
| | | | | | | Postgresql doesn't accepts limits on text columns Conflicts: activerecord/CHANGELOG.md activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb
* Be a bit less conservative with mysql in adapterCarlos Antonio da Silva2012-11-191-1/+1
| | | | This will allow the new mysql 2.9.0 to be used, fixing our test issues.
* use bind values for join columnsAaron Patterson2012-11-101-4/+4
| | | | | | | | | | This is a backport of 4bc2ae0da1dd812aee759f6d13ad428354cd0e13. It fixes bug #7950. Conflicts: activerecord/lib/active_record/relation/calculations.rb activerecord/lib/active_record/relation/finder_methods.rb
* Fix typo :bomb: [ci skip]Rafael Mendonça França2012-10-291-1/+1
|
* Fix bug when Column is trying to type cast boolean values to integer.Rafael Mendonça França2012-10-291-2/+13
| | | | | | | | This can occur if the user is using :integer columns to store boolean values. Now we are handling the boolean values but it still raises if the value can't type cast to integer and is not a boolean. See #7509. Fixes #8067.
* fixed support for DATABASE_URL for rake db tasksGrace Liu2012-10-291-1/+1
| | | | | | | | | | | | | | | | Backport for #7521 - added tests to confirm establish_connection uses DATABASE_URL and Rails.env correctly even when no arguments are passed in. - updated rake db tasks to support DATABASE_URL, and added tests to confirm correct behavior for these rake tasks. (Removed establish_connection call from some tasks since in those cases the :environment task already made sure the function would be called) - updated Resolver so that when it resolves the database url, it removes hash values with empty strings from the config spec (e.g. to support connection to postgresql when no username is specified). - updated ResolverTest to use current_adapter? to check the type of the current adapter.
* Merge pull request #8057 from frodsan/fix_sqlite_mutate_argRafael Mendonça França2012-10-291-1/+1
| | | | | | SQLite3Adapter#type_cast should not mutate arguments Conflicts: activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb
* Make Active Record tests pass in isolationRafael Mendonça França2012-10-291-2/+1
| | | | Also remove the feature detecting for Ruby 1.9
* Merge pull request #7593 from veader/patch-1Rafael Mendonça França2012-10-281-0/+2
| | | | | | | Decode attributes pulled from URI.parse Conflicts: activerecord/CHANGELOG.md activerecord/lib/active_record/connection_adapters/connection_specification.rb
* Synchronize around deleting from the reserved connections hash.Aaron Patterson2012-10-151-1/+1
| | | | Fixes #7955
* 7914 Using a better way to get the defaults from db.Arturo Pie2012-10-141-12/+7
| | | | | | | | | | | | | | | | Changes: * According to postgreSQL documentation: (http://www.postgresql.org/docs/8.2/static/catalog-pg-attrdef.html) we should not be using 'adsrc' field because this field is unaware of outside changes that could affect the way that default values are represented. Thus, I changed the queries to use "pg_get_expr(adbin, adrelid)" instead of the historical "adsrc" field. * Remove parsing of character type default values for 8.1 formatting since Rails doesn't support postgreSQL 8.1 anymore. * Remove misleading comment unrelated to code.
* #7914 get default value when type uses schema nameArturo Pie2012-10-141-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | PostgreSQL adapter properly parses default values when using multiple schemas and domains. When using domains across schemas, PostgresSQL prefixes the type of the default value with the name of the schema where that type (or domain) is. For example, this query: ``` SELECT a.attname, d.adsrc FROM pg_attribute a LEFT JOIN pg_attrdef d ON a.attrelid = d.adrelid AND a.attnum = d.adnum WHERE a.attrelid = "defaults"'::regclass AND a.attnum > 0 AND NOT a.attisdropped ORDER BY a.attnum; ``` could return something like "'<default_value>'::pg_catalog.text" or "(''<default_value>'::pg_catalog.text)::text" for the text columns with defaults. I modified the regexp used to parse this value so that it ignores anything between ':: and \b(?:character varying|bpchar|text), and it allows to have optional parens like in the above second example.
* Merge pull request #7850 from ↵Rafael Mendonça França2012-10-061-1/+1
| | | | | | | | | senny/5920_postgres_adapter_table_with_capital_letters postgres, quote table names when fetching the primary key (#5920) Conflicts: activerecord/CHANGELOG.md activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb
* ConnectionPool accepts spec key 'checkout_timeout'Jonathan Rochkind2012-09-241-3/+9
| | | | | | | Backport of #6441 cb6f83935 . Old 'wait_timeout' is still supported, but conflicts with mysql2 using that spec key for different thing. 'checkout_timeout' can now be used taking precedence for ConnectionPool over 'wait_timeout'.
* Revert "backport fair connection pool 02b2335563 to 3-2-stable"Rafael Mendonça França2012-09-201-190/+49
| | | | | | | | | | | | | This reverts commit 0693e079708a52b777f2b7872b8e3d467b880a0d. Revert "Cache columns metadata to avoid extra while testing" This reverts commit a82f1e3f5d11c8dfba9f4c911745ec40a7965216. Reason: This is causing failures in the postgresql build. See http://travis-ci.org/#!/rails/rails/builds/2485584 Related with #7675
* backport fair connection pool 02b2335563 to 3-2-stableJonathan Rochkind2012-09-171-49/+190
|
* Backport explain fixes.Rafael Mendonça França2012-09-162-11/+11
| | | | | | | | * Mark as SCHEMA some schema database queries. #7648 * Don't explain queries except normal CRUD sql. #7657 Closes #6458 Closes #7544
* Backport PostgreSQL auto-reconnect test coverageSteve Jorgensen2012-09-131-0/+1
| | | | | | | | | | | | | | | | 6d5f4de4c420ebb906109668f5702a537ac77692 Simulated & actual (manual/skipped) PostgreSQL auto-reconnection tests. 4b1bca04025a66c54e6e9d5eb6e4d4056bfa92f0 Stop being silly with formatting of method aliasing. c381d5cbf959208adeb38e7859ee815dfbd2cf54 Fix just-plain-wrongness of psql auto-reconnect test. 1e17a9d367c54c680368be72f44247ae28b98904 Fix only-once stub logic. f16c2043826ec1991cf94fe17cb671507b7a7f51 Changelog for PostgreSQL auto-reconnect test coverage backport.
* Merge pull request #7582 from tchandy/fix_type_cast_codeRafael Mendonça França2012-09-091-2/+2
|\ | | | | type_cast_code should always convert values to integer calling #to_i
| * ConnectionAdapters::Column.type_cast_code should always convert values to ↵Thiago Pradi2012-09-091-2/+2
| | | | | | | | integer calling #to_i
* | Merge pull request #7337 from adzap/string_to_dummy_timeRafael Mendonça França2012-09-051-1/+7
|/ | | | | | Fix for time type columns with invalid time value Conflicts: activerecord/CHANGELOG.md
* Merge pull request #7388 from ↵Rafael Mendonça França2012-08-181-1/+1
|\ | | | | | | | | ManageIQ/fix_table_remove_passing_array_deprecation Table#remove passed an array to remove_column, which is deprecated.
| * Table#remove passed an array to remove_column, which is deprecated.Joe Rafaniello2012-08-181-1/+1
| | | | | | | | See 02ca9151a043a4fefbb3f22edd05f0cd392fffaa