aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters
Commit message (Collapse)AuthorAgeFilesLines
* Merge pull request #27384 from matthewd/bigint-pk-tweaksMatthew Draper2017-01-204-7/+6
|\ | | | | Tweak bigint PK handling
| * Tweak bigint PK handlingMatthew Draper2017-01-184-7/+6
| | | | | | | | | | | | * Don't force PKs on tables that have explicitly opted out * All integer-like PKs are autoincrement unless they have an explicit default
* | 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-173-3/+34
| | | | https://www.sqlite.org/foreignkeys.html
* Translate Foreign Key violation to the specific exception for SQLite3 adapterRyuta Kamizono2017-01-161-0/+21
| | | | | | Raise `ActiveRecord::InvalidForeignKey` when a record cannot be inserted or updated because it references a non-existent record for SQLite3 adapter.
* 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
* Reduce string objects by using \ instead of + or << for concatenating stringsAkira Matsuda2017-01-121-3/+3
| | | | (I personally prefer writing one string in one line no matter how long it is, though)
* Optimizing information_schema query for `foreign_keys`Ryuta Kamizono2017-01-051-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Need `table_name` to avoid all databases scan. See https://dev.mysql.com/doc/refman/5.7/en/information-schema-optimization.html. ``` > EXPLAIN SELECT fk.referenced_table_name AS 'to_table', fk.referenced_column_name AS 'primary_key', fk.column_name AS 'column', fk.constraint_name AS 'name', rc.update_rule AS 'on_update', rc.delete_rule AS 'on_delete' FROM information_schema.key_column_usage fk JOIN information_schema.referential_constraints rc USING (constraint_schema, constraint_name) WHERE fk.referenced_column_name IS NOT NULL AND fk.table_schema = 'activerecord_unittest' AND fk.table_name = 'fk_test_has_pk' AND rc.table_name = 'fk_test_has_pk'\G *************************** 1. row *************************** id: 1 select_type: SIMPLE table: fk partitions: NULL type: ALL possible_keys: NULL key: TABLE_SCHEMA,TABLE_NAME key_len: NULL ref: NULL rows: NULL filtered: NULL Extra: Using where; Open_full_table; Scanned 0 databases *************************** 2. row *************************** id: 1 select_type: SIMPLE table: rc partitions: NULL type: ALL possible_keys: NULL key: TABLE_NAME key_len: NULL ref: NULL rows: NULL filtered: NULL Extra: Using where; Open_full_table; Scanned 1 database; Using join buffer (Block Nested Loop) 2 rows in set, 1 warning (0.00 sec) ``` Fixes #27579.
* Revert "Merge pull request #21233 from ↵Rafael Mendonça França2017-01-032-49/+4
| | | | | | | | | | mtsmfm/disable-referential-integrity-without-superuser-privileges" This reverts commit eeac6151a55cb7d5f799e1ae33aa64a839cbc3aa, reversing changes made to 5c40239d3104543e70508360d27584a3e4dc5baf. Reason: Broke the isolated tests. https://travis-ci.org/rails/rails/builds/188721346
* Merge pull request #21233 from ↵Rafael França2017-01-032-4/+49
|\ | | | | | | | | mtsmfm/disable-referential-integrity-without-superuser-privileges Use `SET CONSTRAINTS` for `disable_referential_integrity` without superuser privileges
| * Use `SET CONSTRAINTS` for `disable_referential_integrity` without superuser ↵Fumiaki MATSUSHIMA2016-12-032-4/+49
| | | | | | | | | | | | | | | | | | privileges ref: 72c1557254 - We must use `authors` fixture with `author_addresses` because of its foreign key constraint. - Tests require PostgreSQL >= 9.4.2 because it had a bug about `ALTER CONSTRAINTS` and fixed in 9.4.2.
* | Merge pull request #25522 from ↵Rafael França2017-01-033-20/+24
|\ \ | | | | | | | | | | | | kamipo/fix_select_rows_method_signature_for_consistency Fix `select_rows` method signature for consistency
| * | Fix `select_rows` method signature for consistencyRyuta Kamizono2017-01-043-20/+24
| | | | | | | | | | | | | | | | | | | | | | | | 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 = [])`.
* | | Remove unneeded requires at active recordRafael Mendonça França2017-01-031-2/+0
| | |
* | | Deprecate passing `name` to `indexes` like `tables`Ryuta Kamizono2017-01-044-2/+22
|/ / | | | | | | | | Passing `name` to `tables` is already deprecated at #21601. Passing `name` to `indexes` is also unused.
* | Compare deserialized values for `PostgreSQL::OID::Hstore` typesJon Moss2017-01-031-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | Per the regression commit below, the commit changes the behavior of `#changed?`to consult the `#changed_in_place?` method on `Type::Value` classes. Per this change, `PostgreSQL::OID::Hstore` needs to override this method in order to compare the deserialized forms of the two arguments. In Ruby, two hashes are considered equal even if their key order is different. This commit helps to bring that behavior to `Hstore` values. Fixes regression introduced by 8e633e505880755e7e366ccec2210bbe2b5436e7 Fixes #27502
* | Consistently apply adapter behavior when serializing arraysSean Griffin2017-01-032-13/+41
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In f1a0fa9 we moved backend specific timestamp behavior out of the type and into the adapter. This was in line with our general attempt to reduce the number of adapter specific type subclasses. However, on PG, the array type performs all serialization, including database encoding in its serialize method. This means that we have converted the value into a string before reaching the database, so no adapter specific logic can be applied (and this also means that timestamp arrays were using the default `.to_s` method on the given object, which likely meant timestamps were being ignored in certain cases as well) Ultimately I want to do a more in depth refactoring which separates database serializer objects from the active model type objects, to give us a less awkward API for introducing the attributes API onto Active Model. However, in the short term, we follow the solution we've applied elsewhere for this. Move behavior off of the type and into the adapter, and use a data object to allow the type to communicate information up the stack. Fixes #27514.
* | Merge pull request #27435 from kamipo/follow_up_25307Sean Griffin2017-01-031-2/+2
|\ \ | | | | | | Active Record supports MySQL >= 5.1.10
| * | Active Record supports MySQL >= 5.1.10Ryuta Kamizono2016-12-221-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Follow up to #25307 and #23458. Related with #27422. We are using `information_schema.referential_constraints` since #25307. The table was introduced in MySQL 5.1.10. MySQL 5.0 is too old. It is enough to support >= 5.1.10 at least. MySQL 5.0 GA was released in Dec 2005 and already EOL in Dec 2011. MySQL 5.1 GA was released in Dec 2008 and already EOL in Dec 2013.
* | | Revert "Merge pull request #27528 from kamipo/extract_casted_booleans"Kasper Timm Hansen2017-01-011-6/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As pointed out by @matthewd this change makes ImmutableString aware of MysqlString's existence whereas previously MysqlString was only overriding public API. cc @kamipo This reverts commit e632c2fa4cb60072a778ce95c952a0fa95e5b074, reversing changes made to 334a7dcf107cd3ff1697163d331d289d6d65dcd7.
* | | Extract `casted_true`/`casted_false` for `Type::ImmutableString`Ryuta Kamizono2017-01-011-14/+6
| | | | | | | | | | | | | | | | | | The only difference between `Type::ImmutableString` and its subclasses is the representation of the casted booleans. Prefer extracting `casted_true`/`casted_false` and override these by subclasses.
* | | Dump array subtype options correctlyRyuta Kamizono2017-01-011-1/+1
| | | | | | | | | | | | | | | Currently schema dumper does not dump array subtype `precision` and `scale` options. This commit fixes the issue.
* | | 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
| | |
* | | `#tables` and `#table_exists?` and returns only tables and not viewsRafael Mendonça França2016-12-294-69/+55
| | |
* | | Remove deprecated `name` argument from `#tables`Rafael Mendonça França2016-12-294-22/+4
| | |
* | | Remove deprecated support to passing a column to #quoteRafael Mendonça França2016-12-291-11/+1
| | |
* | | Sync the visibility of `sql_for_insert` to privateRyuta Kamizono2016-12-291-1/+1
| | | | | | | | | | | | | | | The visibility of all internal protected methods was changed to private since 5b14129.
* | | Merge pull request #27402 from yui-knk/executeRafael França2016-12-281-1/+1
|\ \ \ | | | | | | | | Use `#execute` instead of `@connection.query`
| * | | Use `#execute` instead of `@connection.query`yui-knk2016-12-191-1/+1
| |/ / | | | | | | | | | | | | `@connection.query` bypasses instrumenting "sql.active_record". This behavior preventing us from debugging SQLs which Rails generates.
* | | Fix Rubocop violations and fix documentation visibilityRafael Mendonça França2016-12-287-33/+33
| | | | | | | | | | | | | | | | | | Some methods were added to public API in 5b14129d8d4ad302b4e11df6bd5c7891b75f393c and they should be not part of the public API.
* | | AR::ConnectionAdapters::PostgreSQL::Name#parts is called from other instancesAkira Matsuda2016-12-251-4/+6
| | |
* | | Privatize unneededly protected methods in Active RecordAkira Matsuda2016-12-248-66/+58
| | |
* | | No need to nodoc private methodsAkira Matsuda2016-12-242-14/+14
| | |
* | | Describe what we are protectingAkira Matsuda2016-12-232-0/+4
|/ /
* | Merge pull request #27329 from kamipo/simplify_unsigned_regexEileen M. Uchitelle2016-12-171-2/+1
|\ \ | | | | | | Simplify the regex for `unsigned?` method
| * | Simplify the regex for `unsigned?` methodRyuta Kamizono2016-12-111-2/+1
| | | | | | | | | | | | | | | It is enough to distinguish only the trailing `unsigned` and `unsigned zerofill`.
* | | fix QueryCache nil dupRichard Monette2016-12-152-3/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 #27042 from kirs/yaml-schema-cacheRafael França2016-12-132-0/+38
|\ \ \ | |/ / |/| | Schema cache in YAML
| * | Use YAML to serialize schema cacheKir Shatrov2016-11-272-0/+38
| | |
* | | Merge pull request #25227 from kamipo/numeric_value_out_of_rangeSean Griffin2016-12-102-0/+6
|\ \ \ | | | | | | | | Translate numeric value out of range to the specific exception
| * | | Translate numeric value out of range to the specific exceptionRyuta Kamizono2016-12-062-0/+6
| | | | | | | | | | | | | | | | Raise `ActiveRecord::RangeError` when values that executed are out of range.
* | | | Merge pull request #27278 from kamipo/should_be_sync_primary_key_definitionSean Griffin2016-12-081-1/+1
|\ \ \ \ | | | | | | | | | | Should be sync the `primary_key` definition with actually created
| * | | | Should be sync the `primary_key` definition with actually createdRyuta Kamizono2016-12-061-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Actually the `primary_key` definition is not used but the inconsistency is confusing. Actual definition is `bigint auto_increment PRIMARY KEY` so `UNSIGNED` and `(8)` is unnecessary. See also #21607.
* | | | | [ci skip] Document regex changeAlex Kitchens2016-12-061-0/+1
| |/ / / |/| | |
* | | | Translate NOT NULL violation to the specific exceptionRyuta Kamizono2016-12-063-0/+9
| | | | | | | | | | | | | | | | | | | | Raise `ActiveRecord::NotNullViolation` when a record cannot be inserted or updated because it would violate a not null constraint.
* | | | Merge pull request #26687 from kamipo/fix_add_index_to_normalize_optionsMatthew Draper2016-12-062-0/+2
|\ \ \ \ | |/ / / |/| | | Fix `add_index` to normalize column names and options