aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters
Commit message (Collapse)AuthorAgeFilesLines
* Merge pull request #22748 from Azzurrio/masterMatthew Draper2016-02-221-1/+1
|\ | | | | Fix NoMethodError preparable for Arel::Visitors::PostgreSQL
| * Fix NoMethodError preparable for Arel::Visitors in case prepared statements ↵Azzurrio2016-02-221-1/+1
| | | | | | | | is falsy
* | Merge pull request #23769 from kamipo/remove_alias_exec_without_stmt_exec_querySantiago Pastorino2016-02-211-2/+0
|\ \ | | | | | | Remove `alias exec_without_stmt exec_query`
| * | Remove `alias exec_without_stmt exec_query`Ryuta Kamizono2016-02-191-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This alias was for compatibility with legacy mysql adapter. But the return value of both methods is already inconsistent. `exec_query` returns `ActiveRecord::Result` instance. But `exec_without_stmt` returns `[result_set, affected_rows]` https://github.com/rails/rails/blob/v4.2.5.1/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb#L335-L364 Legacy mysql adapter was already removed in Rails 5.0. I think we can remove this inconsistent alias.
* | | eliminate warnings about multiple primary keys on habtm join tablesAaron Patterson2016-02-191-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | habtm join tables commonly have two id columns and it's OK to make those two id columns a primary key. This commit eliminates the warnings for join tables that have this setup. ManageIQ/manageiq#6713
* | | Merge pull request #23525 from kamipo/remove_unused_requireSean Griffin2016-02-181-1/+0
|\ \ \ | |/ / |/| | Remove unused require
| * | Remove unused requireRyuta Kamizono2016-02-061-1/+0
| | | | | | | | | | | | | | | `require 'active_support/core_ext/benchmark'` was added by 4ecdf24. But currently unused anymore.
* | | Remove needless `case_insensitive_comparison` in mysql2 adapterRyuta Kamizono2016-02-172-7/+4
| | | | | | | | | | | | Simply it is sufficient to override `can_perform_case_insensitive_comparison_for?`.
* | | Let t.foreign_key use the same `to_table` twiceGeorge Millo2016-02-151-2/+2
| |/ |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously if you used `t.foreign_key` twice within the same `create_table` block using the same `to_table`, all statements except the final one would fail silently. For example, the following code: def change create_table :flights do |t| t.integer :from_id, index: true, null: false t.integer :to_id, index: true, null: false t.foreign_key :airports, column: :from_id t.foreign_key :airports, column: :to_id end end Would only create one foreign key, on the column `from_id`. This commit allows multiple foreign keys to the same table to be created within one `create_table` block.
* | Ensure prepared statement caching still occurs with Adequate RecordSean Griffin2016-02-112-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | In Rails 5, we're much more restrictive about when we do or don't cache a prepared statement. In particular, we never cache when we are sending an IN statement or a SQL string literal However, in the case of Adequate Record, we are *always* sending a raw SQL string, and we *always* want to cache the result. Fixes #23507 /cc @tgxworld
* | Add numeric type in the doc [ci skip]Ryuta Kamizono2016-02-081-3/+3
| | | | | | | | Follow up to #23508.
* | Merge pull request #23547 from kamipo/schema_type_returns_symbolSean Griffin2016-02-073-8/+8
|\ \ | | | | | | `schema_type` returns symbol rather than string
| * | `schema_type` returns symbol rather than stringRyuta Kamizono2016-02-083-8/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | A return value of `schema_type` is used by: 1. primary key type: using as `symbol.inspect` 2. normal column type: using as `symbol.to_s` It is better to return symbol.
* | | Merge pull request #23508 from meinac/add_numeric_type_into_migrationsSean Griffin2016-02-071-0/+2
|\ \ \ | |/ / |/| | Added numeric helper into `SchemaStatements` for MySQL and PostgreSQL
| * | Added numeric helper into migrations.Mehmet Emin İNAÇ2016-02-071-0/+2
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | With this addition, you can add a column into the table like: ``` create_table(:numeric_types) do |t| t.numeric :foo, precision: 10, scale: 2, default: 2.0 end ``` The result of the migration above is same with: ``` create_table(:numeric_types) do |t| t.decimal :foo, precision: 10, scale: 2, default: 2.0 end ```
* / MariaDB does not support JSON typeRyuta Kamizono2016-02-061-1/+1
|/ | | | Fixes #22980.
* Remove the assumption of schema in DATABASE_URLJeremy Baker2016-02-041-1/+1
| | | | | | | | | | | | | | | | | If you set the DATABASE_URL environment variable to `mydatabase` by accident, you end up getting a series of errors that are hard to trace. For example: ``` warning: already initialized constant ActiveRecord::Base::OrmAdapter ``` Turns out the cascade of errors is due to the error raised by `.tr` being called on `nil`. This commit makes sure that `scheme` is set before calling `.tr` on it. My previous iteration used `@uri.scheme.try(:tr, '-', '_')` but using the `&&` logical operator is a fair bit faster: http://stackoverflow.com/questions/26655032/try-vs-performance With this change, the error message becomes much more understandable: ``` FATAL: database "mydatabase" does not exist (ActiveRecord::NoDatabaseError) ```
* Merge pull request #23460 from ↵Sean Griffin2016-02-031-1/+1
|\ | | | | | | | | kamipo/innodb_supports_fulltext_and_spatial_indexes InnoDB supports FULLTEXT and Spatial Indexes [ci skip]
| * InnoDB supports FULLTEXT and Spatial Indexes [ci skip]Ryuta Kamizono2016-02-041-1/+1
| | | | | | | | | | https://dev.mysql.com/doc/refman/5.7/en/innodb-fulltext-index.html https://dev.mysql.com/doc/refman/5.7/en/creating-spatial-indexes.html
* | Merge pull request #23458 from kamipo/activerecord_supports_mysql_5.0_and_upSean Griffin2016-02-031-10/+7
|\ \ | | | | | | Active Record supports MySQL >= 5.0
| * | Active Record supports MySQL >= 5.0Ryuta Kamizono2016-02-041-10/+7
| |/ | | | | | | | | Currently some features uses `information_schema` (e.g. foreign key support). `information_schema` introduced since MySQL 5.0.
* / SQLite 2 support has been dropped [ci skip]Ryuta Kamizono2016-02-042-3/+0
|/
* Mention supported PG version in the error message.Prathamesh Sonpatki2016-02-031-1/+1
|
* The minimum supported version of PostgreSQL is now >= 9.1Remo Mueller2016-02-021-3/+2
|
* Fix corrupt transaction state caused by `before_commit` exceptionsJeremy Daer2016-02-011-2/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | When a `before_commit` callback raises, the database is rolled back but AR's record of the current transaction is not, leaving the connection in a perpetually broken state that affects all future users of the connection: subsequent requests, jobs, etc. They'll think a transaction is active when none is, so they won't BEGIN on their own. This manifests as missing `after_commit` callbacks and broken ROLLBACKs. This happens because `before_commit` callbacks fire before the current transaction is popped from the stack, but the exception-handling path they hit assumes that the current transaction was already popped. So the database ROLLBACK is issued, but the transaction stack is left intact. Common cause: deadlocked `#touch`, which is now implemented with `before_commit` callbacks. What's next: * We shouldn't allow active transaction state when checking in or out from the connection pool. Verify that conns are clean. * Closer review of txn manager sad paths. Are we missing other spots where we'd end up with incorrect txn state? What's the worst that can happen if txn state drifts? How can we guarantee it doesn't and contain the fallout if it does? Thanks for @tomafro for expert diagnosis!
* Avoid extra `show variables` in migrationRyuta Kamizono2016-02-012-8/+10
| | | | | | | | | | | | | `initialize_schema_migrations_table` is called in every migrations. https://github.com/rails/rails/blob/v5.0.0.beta1/activerecord/lib/active_record/migration.rb#L1080 https://github.com/rails/rails/blob/v5.0.0.beta1/activerecord/lib/active_record/schema.rb#L51 This means that extra `show variables` is called regardless of the existence of `schema_migrations` table. This change is to avoid extra `show variables` if `schema_migrations` table exists.
* Extract `ExplainPrettyPrinter` to appropriate filesRyuta Kamizono2016-02-017-119/+137
|
* `OID::Money.precision` is unused since #15239Ryuta Kamizono2016-01-312-8/+0
| | | | | | | | p PostgreSQLAdapter::OID::Money.precision # => 19 p PostgreSQLAdapter::OID::Money.new.precision # => nil
* Revert "Merge pull request #23346 from kamipo/refactor_oid_money_precision"Rafael Mendonça França2016-01-302-5/+9
| | | | | | | This reverts commit ff835f90800a3e4122d64606cb328908c2e0e071, reversing changes made to c4d85dfbc71043e2a746acd310e32f4f04db801a. Reason: This broke the tests. We will add back after investigated.
* Merge pull request #23345 from ↵Rafael França2016-01-301-0/+6
|\ | | | | | | | | yui-knk/warning_when_composite_primary_key_is_detected Warn if `AR.primary_key` is called for a table who has composite prim…
| * Warn if `AR.primary_key` is called for a table who has composite primary keyyui-knk2016-01-301-0/+6
| | | | | | | | | | | | | | | | If `AR.primary_key` is called for a table who has composite primary key, the method returns `nil`. This behavior sometimes generates invalid SQL. The first time developers notice to invalid SQL is when they execute SQL. This commit enables developers to know they are doing something dangerous as soon as possible.
* | Merge pull request #23349 from kamipo/refactor_column_existsRafael França2016-01-301-7/+8
|\ \ | | | | | | Refactor `column_exists?` in `SchemaStatements`
| * | Refactor `column_exists?` in `SchemaStatements`Ryuta Kamizono2016-01-301-7/+8
| |/
* | Merge pull request #23355 from kamipo/fix_bigint_for_enum_columnsRafael França2016-01-301-1/+1
|\ \ | | | | | | Fix `bigint?` for Enum columns in MySQL
| * | Fix `bigint?` for Enum columns in MySQLRyuta Kamizono2016-01-311-1/+1
| |/ | | | | | | Follow up to #22896.
* | Merge pull request #23353 from ↵Rafael França2016-01-301-6/+0
|\ \ | | | | | | | | | | | | kamipo/remove_unused_lost_connection_error_messages Remove unused `LOST_CONNECTION_ERROR_MESSAGES`
| * | Remove unused `LOST_CONNECTION_ERROR_MESSAGES`Ryuta Kamizono2016-01-311-6/+0
| |/ | | | | | | | | `LOST_CONNECTION_ERROR_MESSAGES` was added by f384582. But currently unused from anywhere.
* | Merge pull request #23347 from yui-knk/explicitly_define_columns_as_interfaceRafael França2016-01-301-1/+3
|\ \ | | | | | | Explicitly define `columns` method as an interface
| * | Explicitly define `columns` method as an interfaceyui-knk2016-01-301-1/+3
| |/ | | | | | | | | | | `ActiveRecord::ConnectionAdapters::SchemaStatements#columns` is defined here as an interface method here. So changes to raise `NotImplementedError` same as `tables`, `views` ...etc.
* / Refactor `OID::Money.precision`Ryuta Kamizono2016-01-302-9/+5
|/
* Merge pull request #23252 from kamipo/remove_limit_11Rafael França2016-01-291-1/+0
|\ | | | | Remove `limit: 11` as backward-compatibility with Rails 2.0
| * Remove `limit: 11` as backward-compatibility with Rails 2.0Ryuta Kamizono2016-01-271-1/+0
| | | | | | | | | | | | | | Integer limit as a byte size was introduced from Rails 2.1. `limit: 11` is not a byte size, but take care for backward-compatibility with Rails 2.0 (a892af6). Integer limit out of range should be allowed to raise by #6349. I think we should remove this backward-compatibility.
* | Merge pull request #23188 from jcoleman/ar-connection-execute-docs-clarificationRafael França2016-01-292-1/+7
|\ \ | | | | | | Clarify DatabaseStatements#execute docs re: memory usage.
| * | Clarify DatabaseStatements#execute docs re: memory usage.James Coleman2016-01-222-1/+7
| | |
* | | Fix a bug with initialize schema_migrations tableMikhail Grachev2016-01-281-1/+1
| | | | | | | | | | | | | | | | | | | | | This line causes an error when executing the command: `rails db:drop db:create db:schema:load` ActiveRecord::StatementInvalid: PG::SyntaxError: ERROR: syntax error at or near "{" LINE 1: ...NSERT INTO "schema_migrations" (version) VALUES (#{v}), (#{v...
* | | INSERT INTO schema_migrations in 1 SQLAkira Matsuda & Naoto Koshikawa2016-01-271-10/+8
| |/ |/| | | | | | | | | | | We found that inserting all 600 schema_migrations for our mid-sized app takes about a minute on a cloud based CI environment. I assume that the original code did not use multi-row-insert because SQLite3 was not supporting the syntax back then, but it's been supported since 3.7.11: http://www.sqlite.org/releaselog/3_7_11.html
* | Pare back default `index` option for the migration generatorPrathamesh Sonpatki2016-01-241-1/+1
|/ | | | | | | | | | - Using `references` or `belongs_to` in migrations will always add index for the referenced column by default, without adding `index:true` option to generated migration file. - Users can opt out of this by passing `index: false`. - Legacy migrations won't be affected by this change. They will continue to run as they were before. - Fixes #18146
* Merge pull request #20005 from kamipo/default_expression_supportRafael França2016-01-166-20/+36
|\ | | | | Add `:expression` option support on the schema default
| * Fix extract default with CURRENT_TIMESTUMPRyuta Kamizono2016-01-131-2/+6
| |
| * Fix extract default with CURRENT_DATERyuta Kamizono2016-01-131-3/+8
| | | | | | | | The default 'now'::date is CURRENT_DATE.