aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters
Commit message (Collapse)AuthorAgeFilesLines
* Fix `bigint?` for Enum columns in MySQLRyuta Kamizono2016-01-311-1/+1
| | | | Follow up to #22896.
* 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.
| * Add expression support on the schema defaultRyuta Kamizono2016-01-134-15/+22
| | | | | | | | | | | | | | | | Example: create_table :posts do |t| t.datetime :published_at, default: -> { 'NOW()' } end
* | Merge pull request #23067 from ↵Rafael França2016-01-162-22/+14
|\ \ | | | | | | | | | | | | kamipo/sql_for_insert_returns_values_for_passing_to_exec_insert `sql_for_insert` returns values for passing to `exec_insert`
| * | `sql_for_insert` returns values for passing to `exec_insert`Ryuta Kamizono2016-01-152-22/+14
| | |
* | | `last_insert_id_value` and `last_insert_id` are unused anymoreRyuta Kamizono2016-01-151-9/+1
|/ / | | | | | | These methods are private and unused from anywhere.
* / `substitute_at` is no longer usedRyuta Kamizono2016-01-141-6/+0
|/ | | | Arel handles substitution for bind parameters by now.
* fix regression when loading fixture files with symbol keys.Yves Senn2016-01-131-2/+3
| | | | Closes #22584.
* Extract `MySQL::TypeMetadata` class to ↵Ryuta Kamizono2016-01-112-28/+34
| | | | `connection_adapters/mysql/type_metadata.rb`
* Extract `MySQL::Column` class to `connection_adapters/mysql/column.rb`Ryuta Kamizono2016-01-112-46/+52
|
* Refactor tz aware types, add support for PG rangesSean Griffin2016-01-082-1/+12
| | | | | | | | | | | | | | | | | This is an alternate implementation to #22875, that generalizes a lot of the logic that type decorators are going to need, in order to have them work with arrays, ranges, etc. The types have the ability to map over a value, with the default implementation being to just yield that given value. Array and Range give more appropriate definitions. This does not automatically make ranges time zone aware, as they need to be added to the `time_zone_aware` types config, but we could certainly make that change if we feel it is appropriate. I do think this would be a breaking change however, and should at least have a deprecation cycle. Closes #22875. /cc @matthewd
* Merge pull request #22967 from schneems/schneems/generic-metadataSean Griffin2016-01-082-0/+5
|\ | | | | Prevent destructive action on production database
| * [ci skip] Add comment to remove silenced code.schneems2016-01-071-0/+1
| |
| * Prevent destructive action on production databaseschneems2016-01-071-0/+4
| | | | | | | | | | | | | | This PR introduces a key/value type store to Active Record that can be used for storing internal values. It is an alternative implementation to #21237 cc @sgrif @matthewd. It is possible to run your tests against your production database by accident right now. While infrequently, but as an anecdotal data point, Heroku receives a non-trivial number of requests for a database restore due to this happening. In these cases the loss can be large. To prevent against running tests against production we can store the "environment" version that was used when migrating the database in a new internal table. Before executing tests we can see if the database is a listed in `protected_environments` and abort. There is a manual escape valve to force this check from happening with environment variable `DISABLE_DATABASE_ENVIRONMENT_CHECK=1`.
* | Merge pull request #22973 from kamipo/fix_select_values_method_signatureRafael França2016-01-082-4/+4
|\ \ | | | | | | Fix `select_values` method signature for consistency
| * | Fix `select_values` method signature for consistencyRyuta Kamizono2016-01-082-4/+4
| | |
* | | `{update|delete}_sql` are almost the same as `{update|delete}`Ryuta Kamizono2016-01-084-25/+2
|/ / | | | | | | Simply `{update|delete}_sql` aliases to `{update|delete}`.
* | Remove `delete_sql` in sqlite3 adapterRyuta Kamizono2016-01-071-5/+0
| | | | | | | | | | `sql += " WHERE 1=1"` was introduced in 69cb942. But it is not needed. ref https://www.sqlite.org/lang_delete.html
* | Refactor `connection.insert_sql`Ryuta Kamizono2016-01-074-35/+10
| | | | | | | | `connection.insert_sql` is almost the same as `connection.insert`.
* | Merge pull request #22921 from prathamesh-sonpatki/fix-add-referenceRafael França2016-01-061-0/+1
|\ \ | | | | | | Autoload ReferenceDefinition class in abstract adapter so that it can be used by #add_reference in schema_statements
| * | Autoload ReferenceDefinition class in abstract adapter so that it can be ↵Prathamesh Sonpatki2016-01-051-0/+1
| | | | | | | | | | | | | | | | | | used by #add_reference in schema_statements - Fixes #22916.
* | | Merge pull request #21688 from kamipo/add_text_and_blob_shorthand_methodsRafael Mendonça França2016-01-061-0/+24
|\ \ \ | | | | | | | | | | | | Add short-hand methods for text and blob types in MySQL
| * | | Add short-hand methods for text and blob types in MySQLRyuta Kamizono2016-01-051-0/+24
| |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In Pg and Sqlite3, `:text` and `:binary` have variable unlimited length. But in MySQL, these have limited length for each types (ref #21591, #21619). This change adds short-hand methods for each text and blob types. Example: create_table :foos do |t| t.tinyblob :tiny_blob t.mediumblob :medium_blob t.longblob :long_blob t.tinytext :tiny_text t.mediumtext :medium_text t.longtext :long_text end
* | | Merge pull request #22920 from kamipo/fix_connection_createRafael França2016-01-054-6/+1
|\ \ \ | |/ / |/| | Fix `connection#create` in PG adapter
| * | Fix `connection#create` in PG adapterRyuta Kamizono2016-01-054-6/+1
| | | | | | | | | | | | | | | | | | Originally `connection#create` had aliased to `connection#insert` in PG adapter. But it was broken by #7447. Re-alias `create` to `insert` for fixing it.
* | | Merge pull request #22896 from kamipo/fix_unsigned_and_blob_or_text_columnRafael França2016-01-041-3/+3
|\ \ \ | |/ / |/| | Fix `unsigned?` and `blob_or_text_column` for Enum columns in MySQL
| * | Fix `unsigned?` and `blob_or_text_column?` for Enum columns in MySQLRyuta Kamizono2016-01-041-3/+3
| | |
* | | Merge pull request #22821 from shosti/set-null-transactionArthur Nogueira Neves2016-01-041-0/+1
|\ \ \ | |/ / |/| | Allow add_to_transaction with null transaction
| * | Allow add_to_transaction with null transactionEmanuel Evans2015-12-281-0/+1
| | | | | | | | | | | | Fixes https://github.com/rails/rails/issues/22819
* | | Refactor `case_{sensitive|insensitive}_comparison`Ryuta Kamizono2016-01-012-17/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Before: ``` SELECT 1 AS one FROM "topics" WHERE "topics"."title" = 'abc' LIMIT $1 [["LIMIT", 1]] ``` After: ``` SELECT 1 AS one FROM "topics" WHERE "topics"."title" = $1 LIMIT $2 [["title", "abc"], ["LIMIT", 1]] ```
* | | Merge pull request #22848 from derekprior/dp-postgresql-versionRafael França2015-12-301-5/+5
|\ \ \ | | | | | | | | Make `postgresql_version` public
| * | | Make `postgresql_version` publicDerek Prior2015-12-301-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is useful to libraries that want to feature gate based on the version of PostgreSQL the user is connected to. For instance, I want to know if the user is connected to a version of Postgres that supports concurrent materialized view refreshes. I could add that as a method on the adapter as a PR, but rails has no need for this itself. Rails is already using the postgresql_version for its own feature gating and this makes that possible for other libraries.
* | | | Merge pull request #22241 from kamipo/add_columns_for_distinct_for_mysql57Rafael França2015-12-302-5/+23
|\ \ \ \ | | | | | | | | | | Add `columns_for_distinct` for MySQL 5.7 with ONLY_FULL_GROUP_BY
| * | | | Add `columns_for_distinct` for MySQL 5.7 with ONLY_FULL_GROUP_BYRyuta Kamizono2015-12-232-2/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In MySQL 5.7.5 and up, ONLY_FULL_GROUP_BY affects handling of queries that use DISTINCT and ORDER BY. It requires the ORDER BY columns in the select list for distinct queries, and requires that the ORDER BY include the distinct column. See https://dev.mysql.com/doc/refman/5.7/en/group-by-handling.html
| * | | | Avoid `distinct` if a subquery has already materializedRyuta Kamizono2015-12-231-3/+5
| | | | | | | | | | | | | | | | | | | | Follow up to #19359 and avoid #22241.
* | | | | Merge pull request #22803 from kamipo/improve_select_one_in_mysql2_adapterRafael França2015-12-301-27/+9
|\ \ \ \ \ | | | | | | | | | | | | Improve `select_one` in `Mysql2Adapter`
| * | | | | Remove outdated commentRyuta Kamizono2015-12-271-28/+0
| | | | | | | | | | | | | | | | | | | | | | | | These `select_*` methods improved already.
| * | | | | Improve `select_one` in `Mysql2Adapter`Ryuta Kamizono2015-12-271-0/+10
| | |_|/ / | |/| | | | | | | | | | | | | | | | | | Avoid instanciate `ActiveRecord::Result` and calling `ActiveRecord::Result#hash_rows` for the performance.
* | | | | Merge pull request #22547 from kamipo/fix_create_table_info_cacheRafael França2015-12-291-2/+6
|\ \ \ \ \ | |/ / / / |/| | | | Correctly cache create_table_info
| * | | | Correctly cache create_table_infoRyuta Kamizono2015-12-171-2/+6
| | |_|/ | |/| | | | | | | | | | Follow up to #21664.
* | | | Fix varbinary with default ''Ryuta Kamizono2015-12-241-13/+0
| |_|/ |/| | | | | | | | | | | | | | | | | A `(?:var)?binary` with default '' is a correct definition. Remove `missing_default_forged_as_empty_string?` method for fixing this issue because this method is a workaround for older mysql legacy adapter (19c99ac, f7015336).