aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters/abstract
Commit message (Collapse)AuthorAgeFilesLines
...
* | | `create_join_table` should respect `references` column typeRyuta Kamizono2017-02-281-7/+5
| | | | | | | | | | | | | | | | | | | | | | | | Follow up of #26266. The default type of `primary_key` and `references` were changed to `bigint` since #26266. But `create_join_table` column type is still `integer`. It should respect `references` column type.
* | | Merge pull request #25285 from ↵Rafael França2017-02-231-0/+1
|\ \ \ | | | | | | | | | | | | | | | | kamipo/fix_remove_reference_to_multiple_foreign_keys_in_the_same_table Fix `remove_reference` to multiple foreign keys in the same table
| * | | Fix `remove_reference` to multiple foreign keys in the same tableRyuta Kamizono2017-02-111-0/+1
| | |/ | |/|
* | | Deprecate using `#quoted_id` in quotingRyuta Kamizono2017-02-241-0/+2
| | | | | | | | | | | | | | | Originally `quoted_id` was used in legacy quoting mechanism. Now we use type casting mechanism for that. Let's deprecate `quoted_id`.
* | | Fix type casting AR object to respect the primary key cast type's serializationRyuta Kamizono2017-02-241-2/+13
| | |
* | | Correctly dump native timestamp types for MySQLRyuta Kamizono2017-02-231-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The native timestamp type in MySQL is different from datetime type. Internal representation of the timestamp type is UNIX time, This means that timestamp columns are affected by time zone. ``` > SET time_zone = '+00:00'; Query OK, 0 rows affected (0.00 sec) > INSERT INTO time_with_zone(ts,dt) VALUES (NOW(),NOW()); Query OK, 1 row affected (0.02 sec) > SELECT * FROM time_with_zone; +---------------------+---------------------+ | ts | dt | +---------------------+---------------------+ | 2016-02-07 22:11:44 | 2016-02-07 22:11:44 | +---------------------+---------------------+ 1 row in set (0.00 sec) > SET time_zone = '-08:00'; Query OK, 0 rows affected (0.00 sec) > SELECT * FROM time_with_zone; +---------------------+---------------------+ | ts | dt | +---------------------+---------------------+ | 2016-02-07 14:11:44 | 2016-02-07 22:11:44 | +---------------------+---------------------+ 1 row in set (0.00 sec) ```
* | | Ensure test threads share a DB connectioneileencodes2017-02-202-17/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This ensures multiple threads inside a transactional test to see consistent database state. When a system test starts Puma spins up one thread and Capybara spins up another thread. Because of this when tests are run the database cannot see what was inserted into the database on teardown. This is because there are two threads using two different connections. This change uses the statement cache to lock the threads to using a single connection ID instead of each not being able to see each other. This code only runs in the fixture setup and teardown so it does not affect real production databases. When a transaction is opened we set `lock_thread` to `Thread.current` so we can keep track of which connection the thread is using. When we rollback the transaction we unlock the thread and then there will be no left-over data in the database because the transaction will roll back the correct connections. [ Eileen M. Uchitelle, Matthew Draper ]
* | | Improve `create_table force: true`Ryuta Kamizono2017-02-201-2/+2
| |/ |/| | | | | | | Extra `data_source_exists?(table_name)` is unneeded if `drop_table(table_name, if_exists: true)` directly.
* | Merge pull request #26655 from kamipo/fix_remove_expression_indexRafael França2017-02-131-12/+16
|\ \ | | | | | | Fix `remove_index` to be able to remove expression indexes
| * | Fix `remove_index` to be able to remove expression indexesRyuta Kamizono2016-12-251-12/+16
| | | | | | | | | | | | Fixes #26635, #26641.
* | | Merge pull request #26930 from kamipo/index_name_exists_defaultRafael França2017-02-131-6/+7
|\ \ \ | | | | | | | | The `default` arg of `index_name_exists?` makes to optional
| * | | Deprecate passing `default` to `index_name_exists?`Ryuta Kamizono2017-02-131-0/+5
| | | |
| * | | The `default` arg of `index_name_exists?` makes to optionalRyuta Kamizono2017-02-131-6/+2
| | | | | | | | | | | | | | | | | | | | | | | | The `default` arg of `index_name_exists?` is only used the adapter does not implemented `indexes`. But currently all adapters implemented `indexes` (See #26688). Therefore the `default` arg is never used.
* | | | Merge pull request #26630 from kamipo/quoted_binaryRafael França2017-02-131-1/+6
|\ \ \ \ | |/ / / |/| | | Extract `quoted_binary` and use it rather than override `_quote`
| * | | Extract `quoted_binary` and use it rather than override `_quote`Ryuta Kamizono2016-09-271-1/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Each databases have different binary representation. Therefore all adapters overrides `_quote` for quoting binary. Extract `quoted_binary` for quoting binary and use it rather than override `_quote`.
* | | | Schema dumping support for PostgreSQL interval typeRyuta Kamizono2017-02-121-1/+1
| |_|/ |/| | | | | | | | Closes #27979
* | | Refactor `ColumnDefinition` to contain `options` hashRyuta Kamizono2017-02-093-34/+23
| | | | | | | | | | | | | | | | | | Column options are passed as an hash args then used as `options` hash in `add_column_options!`. Converting args to attributes is inconvinient for using options as an hash.
* | | `primary_key` and `references` columns should be identical typeRyuta Kamizono2017-02-072-8/+6
| | | | | | | | | | | | | | | | | | | | | | | | Follow up to #26266. The default type of `primary_key` and `references` were changed to `bigint` since #26266. But legacy migration and sqlite3 adapter should keep its previous behavior.
* | | Merge pull request #27389 from kamipo/fix_mysql_pk_dumping_correctlyJeremy Daer2017-02-061-0/+6
|\ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Restore the behaviour of the compatibility layer for integer-like PKs * kamipo/fix_mysql_pk_dumping_correctly: Restore custom primary key tests lost at #26266 Restore the behaviour of the compatibility layer for integer-like PKs Correctly dump integer-like primary key with default nil
| * | | Correctly dump integer-like primary key with default nilRyuta Kamizono2017-02-041-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The PR #27384 changed integer-like primary key to be autoincrement unless an explicit default. This means that integer-like primary key is restored as autoincrement unless dumping the default nil explicitly. We should dump integer-like primary key with default nil correctly.
* | | | Deprecate `ColumnDumper#migration_keys`Ryuta Kamizono2017-02-072-3/+7
|/ / / | | | | | | | | | | | | | | | `ColumnDumper#migration_keys` was extracted to customize keys for standardized column arguments widths. But the feature was removed in df84e98. The internal method is no longer used for that.
* | | Virtual/generated column support for MySQL 5.7.5+ and MariaDB 5.2.0+Ryuta Kamizono2017-02-013-2/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | MySQL generated columns: https://dev.mysql.com/doc/refman/5.7/en/create-table-generated-columns.html MariaDB virtual columns: https://mariadb.com/kb/en/mariadb/virtual-computed-columns/ Declare virtual columns with `t.virtual name, type: …, as: "expression"`. Pass `stored: true` to persist the generated value (false by default). Example: create_table :generated_columns do |t| t.string :name t.virtual :upper_name, type: :string, as: "UPPER(name)" t.virtual :name_length, type: :integer, as: "LENGTH(name)", stored: true t.index :name_length # May be indexed, too! end Closes #22589
* | | Missing require "active_support/multibyte/chars"Akira Matsuda2017-01-271-0/+1
| | | | | | | | | | | | this probably fixes #25840
* | | Deprecate `initialize_schema_migrations_table` and ↵Ryuta Kamizono2017-01-201-4/+4
| | | | | | | | | | | | | | | | | | `initialize_internal_metadata_table` These internal initialize methods are no longer used internally.
* | | Revert "Merge pull request #27718 from kamipo/remove_internal_public_methods"Matthew Draper2017-01-201-0/+10
| | | | | | | | | | | | | | | This reverts commit 39c77eb1843f79925c7195e8869afc7cb7323682, reversing changes made to 9f6f51be78f8807e18fc6562c57af2fdbf8ccb56.
* | | Remove `initialize_schema_migrations_table` and ↵Ryuta Kamizono2017-01-181-10/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `initialize_internal_metadata_table` internal public methods These internal methods accidentally appeared in the doc, and so almost useless. It is enough to create these internal tables directly, and indeed do so in several places. https://github.com/rails/rails/blob/v5.0.1/activerecord/lib/active_record/schema.rb#L55 https://github.com/rails/rails/blob/v5.0.1/activerecord/lib/active_record/railties/databases.rake#L6 https://github.com/rails/rails/blob/v5.0.1/activerecord/lib/active_record/tasks/database_tasks.rb#L230
* | | SQLite: Foreign Key SupportRyuta Kamizono2017-01-171-3/+3
| | | | | | | | | | | | https://www.sqlite.org/foreignkeys.html
* | | Fix pool_from_any_process to use most recent speceileencodes2017-01-131-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If a process is forked more than once, the pool was grabbing the oldest spec, not the most recent spec. This wasn't noticed before because most folks are lilely forking the process only once. If you're forking the process multiple times however the wrong spec name will be returned and an incorrect connection will be used for the process. This fixes the issue by reversing the list of spec names so we can grab the most recent spec rather than the oldest spec.
* | | class Foo < Struct.new(:x) creates an extra unneeded anonymous classAkira Matsuda2017-01-131-10/+6
| | | | | | | | | | | | because Struct.new returns a Class, we just can give it a name and use it directly without inheriting from it
* | | Merge pull request #25522 from ↵Rafael França2017-01-031-6/+4
|\ \ \ | | | | | | | | | | | | | | | | kamipo/fix_select_rows_method_signature_for_consistency Fix `select_rows` method signature for consistency
| * | | Fix `select_rows` method signature for consistencyRyuta Kamizono2017-01-041-6/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Related #22973, #24708. `select_all`, `select_one`, `select_value`, and `select_values` method signature is `(arel, name = nil, binds = [])`. But `select_rows` is `(sql, name = nil, binds = [])`.
* | | | Deprecate passing `name` to `indexes` like `tables`Ryuta Kamizono2017-01-041-1/+3
|/ / / | | | | | | | | | | | | Passing `name` to `tables` is already deprecated at #21601. Passing `name` to `indexes` is also unused.
* | | Merge pull request #27441 from koic/quoted_insert_version_sqlKasper Timm Hansen2016-12-311-4/+4
|\ \ \ | | | | | | | | Add a quote to an SQL insert statement of schema migration
| * | | Add a quote to an SQL insert statement of schema migrationKoichi ITO2016-12-231-4/+4
| | | |
* | | | Remove deprecated `#insert_sql`, `#update_sql`, and `#delete_sql`Ryuta Kamizono2016-12-301-6/+0
| | | |
* | | | Remove deprecated support to query using commas on LIMITRafael Mendonça França2016-12-291-6/+1
| | | |
* | | | Remove deprecated `name` argument from `#tables`Rafael Mendonça França2016-12-291-1/+1
| | | |
* | | | Remove deprecated support to passing a column to #quoteRafael Mendonça França2016-12-291-11/+1
| | | |
* | | | Fix Rubocop violations and fix documentation visibilityRafael Mendonça França2016-12-282-12/+12
| |_|/ |/| | | | | | | | | | | | | | Some methods were added to public API in 5b14129d8d4ad302b4e11df6bd5c7891b75f393c and they should be not part of the public API.
* | | Privatize unneededly protected methods in Active RecordAkira Matsuda2016-12-242-15/+14
| | |
* | | No need to nodoc private methodsAkira Matsuda2016-12-241-3/+3
| | |
* | | Describe what we are protectingAkira Matsuda2016-12-231-0/+2
|/ /
* | fix QueryCache nil dupRichard Monette2016-12-151-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | make sql statements frozen dup if arel is not our string expect runtime error dont wrap runtime error in invalid log errors will now be treated as runtime errors update changelog
* | Merge pull request #26687 from kamipo/fix_add_index_to_normalize_optionsMatthew Draper2016-12-061-0/+1
|\ \ | | | | | | Fix `add_index` to normalize column names and options
| * | Fix `add_index` to normalize column names and optionsRyuta Kamizono2016-10-031-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently does not work the following code. ```ruby add_index(:people, ["last_name", "first_name"], order: { last_name: :desc, first_name: :asc }) ``` Normalize column names and options to fix the issue.
* | | Change MySQL and Postgresql to use Bigint primary keysJon McCartie2016-12-052-2/+2
| | |
* | | Don't try to run multiple insert queries at onceSean Griffin2016-12-051-5/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | SQLite's default query interface ignores anything after the first semicolon in a query. This is actually quite common behavior in database drivers, especially when dealing with code paths for prepared statements (which we are). While this should only affect SQLite, as I'm not aware of any drivers which don't support multi-insert. Even if this does affect other third party drivers though, I'd prefer not to assume that more than one query can be executed per call to `execute`. Fixes #26948. Close #27242.
* | | Clear available connections immediatelyMatthew Draper2016-11-271-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It'll be re-cleared when it's rebuilt in with_new_connections_blocked's ensure, but we still need to clear it inside this synchronize -- we've disconnected connections that may be available in the queue, and while other threads are not allowed to make *new* connections, they are still allowed to take existing ones from there. This was incorrectly removed in d314646c965b045724e6bdb9d61dcecfabc0ba8f.
* | | Distribute connections to previously blocked threads when we're doneMatthew Draper2016-11-251-19/+17
| | | | | | | | | | | | | | | | | | Two methods block new connections; we were already doing the right thing for clear_reloadable_connections, but it's better placed in with_new_connections_blocked, where it can work for disconnect too.
* | | Merge pull request #27057 from kamipo/fix_race_conditionMatthew Draper2016-11-191-6/+7
|\ \ \ | | | | | | | | | | | | Fix the race condition caused by `with_new_connections_blocked`