| Commit message (Collapse) | Author | Age | Files | Lines |
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Currently, `test_copy_table_with_composite_primary_keys` test fails
depending on execution order. The reproduction step is as follows.
```
$ ARCONN=sqlite3_mem bin/test -w -n "/^(?:CalculationsTest#(?:test_#skip_query_cache\\!_for_a_simple_calculation)|PrimaryKeyAnyTypeTest#(?:test_any_type_primary_key)|ActiveRecord::ConnectionAdapters::SQLite3AdapterTest#(?:test_copy_table_with_composite_primary_keys))$/" --seed 41545
```
The column info is cached by `PrimaryKeyAnyTypeTest#test_any_type_primary_key`,
and the test seems to have failed due to the influence.
So clear cache after testing so as not to affect other tests.
Related: https://travis-ci.org/rails/rails/jobs/313730163#L1788
|
| |
|
|
|
|
|
|
|
| |
Otherwise using reserved words as composite primary key names will be
failed as an invalid SQL.
Fixes #30518.
|
|
|
|
|
|
| |
I was added a table options after `force: :cascade` in #17569 for not
touching existing tests (reducing diff). But `force: :cascade` is not an
important information. So I prefer to place a table options before
`force: :cascade`.
|
|\ |
|
| | |
|
|\| |
|
| |
| |
| |
| |
| | |
This reverts commit 3420a14590c0e6915d8b6c242887f74adb4120f9, reversing
changes made to afb66a5a598ce4ac74ad84b125a5abf046dcf5aa.
|
| | |
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
The `raw_write_attribute` method is used to update a record's attributes
to reflect the new state of the database in `update_columns`. The hash
provided to `update_columns` is turned into an UPDATE query directly,
which means passing an `id` key results in an update to the `id` column,
even if the model uses a different attribute as its primary key. When
updating the record, we don't want to apply the `id` column change to
the primary key attribute, since that's not what happened in the query.
Without the code to handle this case, `write_attribute_with_type_cast`
no longer contains any logic shared between `raw_write_attribute` and
`write_attribute`, so we can inline the code into those two methods.
|
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Currently the methods of `AttributeMethods::PrimaryKey` are overwritten
by `define_attribute_methods`. It will be broken if a table that
customized primary key has non primary key id column.
It should not be overwritten if a table has any primary key.
Fixes #29350.
|
|/
|
|
|
|
|
|
|
|
|
| |
- The test `PrimaryKeyAnyTypeTest#test_any_type_primary_key` was failing
if ran after running all tests from `CompositePrimaryKeyTest`.
- This was happening because `CompositePrimaryKeyTest` was changing the
primary key of the barcodes table which was cached in schema cache.
- As we were always going to drop the `barcodes` table at the end of
tests in both `PrimaryKeyTest` and `CompositePrimaryKeyTest`, solved
this issue by using different table name for tests in
`CompositePrimaryKeyTest`.
|
|\
| |
| | |
Raise NotImplementedError when using empty_insert_statement_value with Oracle
|
| |
| |
| |
| | |
Refer: https://github.com/rsim/oracle-enhanced/pull/1180
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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)
```
|
|/ |
|
|
|
|
|
|
|
|
|
|
|
|
| |
`supports_primary_key?` was added to determine if `primary_key` is
implemented in the adapter in f060221. But we already use `primary_key`
without `supports_primary_key?` (207f266, 5f3cf42) and using
`supports_primary_key?` has been removed in #1318. This means that
`supports_primary_key?` is no longer used in the internal and Active
Record doesn't work without `primary_key` is implemented (all adapters
must implement `primary_key`).
Closes #27977
|
|
|
|
|
|
|
| |
Currently schema dumper lost the unsigned option when primary key is
defined as bigint with unsigned. This commit fixes the issue.
Closes #27960
|
|
|
|
|
| |
`test_composite_primary_key_out_of_order` should use `barcodes_reverse`
table.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
primary_keys(table) needs to query various metadata tables in Postgres to
determine the primary key for the table. Previously, it did so using a
complex common table expression against pg_constraint and pg_attribute.
This patch simplifies the query by joining pg_index against pg_attribute
instead of going through pg_constraint. This avoids an expensive unnest,
window function query, and common table expression.
EXPLAINing these queries in Postgres against a database with a single
table with a composite primary key shows a 66% reduction in the plan and
execute latencies. This is significant during application startup time,
especially against very large schemas, where these queries would be even
slower and more numerous.
Closes #27949
|
| |
|
|
|
|
|
| |
Some custom primary key tests (added at #17631, #17696, #18220, #18228)
were lost at #26266. Restore the tests to improve test coverage.
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
| |
`supports_primary_key?` method is defined in `AbstractAdapter` so does
not raise any errors.
|
|\
| |
| | |
Make `:auto_increment` option works on `:bigint`
|
| |
| |
| |
| | |
Follow up to #27272.
|
| | |
|
|/ |
|
|
|
|
|
|
| |
Using `:auto_increment` option for abstracting the DB-specific auto
incremental types. It is worth to ease to implement the compatibility
layer.
|
| |
|
| |
|
|
|
|
|
| |
The current code base is not uniform. After some discussion,
we have chosen to go with double quotes by default.
|
|
|
|
|
|
|
|
|
|
|
| |
Actually schema dumper/creation supports composite primary key (#21614).
Therefore it should not show the warning about composite primary key in
connection adapter.
This change moves the warning to `AttributeMethods::PrimaryKey` and
suppress the warning for habtm join table.
Fixes #25388.
|
|\
| |
| | |
Pass `pk: false` to `connection.insert` explicitly if do not have a primary key
|
| |
| |
| |
| |
| |
| | |
Because causing an extra query by `sql_for_insert` for guessing a
primary key.
https://github.com/rails/rails/blob/v5.0.0/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb#L121-L125
|
|/
|
|
| |
Fixes #25300.
|
|
|
|
|
|
|
| |
Follow up to #18228.
In MySQL and PostgreSQL, primary key is to be `NOT NULL` implicitly.
But in SQLite it must be specified `NOT NULL` explicitly.
|
| |
|
| |
|
| |
|
| |
|
|\
| |
| |
| |
| | |
yui-knk/warning_when_composite_primary_key_is_detected
Warn if `AR.primary_key` is called for a table who has composite prim…
|
| |
| |
| |
| |
| |
| |
| |
| | |
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.
|
|/ |
|
| |
|
|
|
|
|
|
|
|
|
|
| |
Reported on #21509, how views is treated by `#tables` are differ
by each adapters. To fix this different behavior, after Rails 5.0
is released, deprecate `#tables`.
And `#table_exists?` would check both tables and views.
To make their behavior consistent with `#tables`, after Rails 5.0
is released, deprecate `#table_exists?`.
|
|
|
|
| |
Such as #10404, #18206.
|
|\
| |
| |
| | |
Add `unsigned` support for numeric data types in MySQL
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Example:
create_table :foos do |t|
t.integer :unsigned_integer, unsigned: true
t.bigint :unsigned_bigint, unsigned: true
t.float :unsigned_float, unsigned: true
t.decimal :unsigned_decimal, unsigned: true, precision: 10, scale: 2
end
|