| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
| |
- key was a poor choice of name. A key implies something that will
unlock a lock. The concept is actually more like a 'lock identifier'
- mysql documentation calls this a 'lock name'
- postgres documentation calls it a 'lock_id'
- Updated variable names to reflect the preferred terminology for the database in
question
|
|
|
|
|
|
|
|
|
|
| |
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?`.
|
| |
|
|
|
|
|
|
| |
This test case was definded by 51de8cee82d61541725ff4c2462b083f37e64017.
`float` and `double` is registered in abstract_mysql_adapter.rb,
we should test not only for mysql adapter, but mysql2 adapter.
|
|\
| |
| |
| |
| | |
samphilipd/sam/manual_locking_on_schema_migrations
Make migrations concurrent safe (using advisory locks)
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
- Addresses issue #22092
- Works on Postgres and MySQL
- Uses advisory locks because of two important properties:
1. The can be obtained outside of the context of a transaction
2. They are automatically released when the session ends, so if a
migration process crashed for whatever reason the lock is not left
open perpetually
- Adds get_advisory_lock and release_advisory_lock methods to database
adapters
- Attempting to run a migration while another one is in process will
raise a ConcurrentMigrationError instead of attempting to run in
parallel with undefined behavior. This could be rescued and
the migration could exit cleanly instead. Perhaps as a configuration
option?
Technical Notes
==============
The Migrator uses generate_migrator_advisory_lock_key to build the key
for the lock. In order to be compatible across multiple adapters there
are some constraints on this key.
- Postgres limits us to 64 bit signed integers
- MySQL advisory locks are server-wide so we have to scope to the
database
- To fulfil these requirements we use a Migrator salt (a randomly
chosen signed integer with max length of 31 bits) that identifies
the Rails migration process as the owner of the lock. We multiply
this salt with a CRC32 unsigned integer hash of the database name to
get a signed 64 bit integer that can also be converted to a string
to act as a lock key in MySQL databases.
- It is important for subsequent versions of the Migrator to use the
same salt, otherwise different versions of the Migrator will not see
each other's locks.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
The first one is quite straightforward. We want to give the proper error
message in the case where a top level constant exists, but we're looking
for a nested one. We just need to port over the change to use
`subclass.name` into these changes.
The second set of failures, which are only present in the mysql adapter
tests, are stranger to me. The failure occurs because we were
previously comparing `subclass.name == self.name` instead of `subclass
== self`. However, I don't think that we need to support creating
anonymous classes which share a table with a class that uses STI,
overrides `name` to return the same name as athe class that we have no
other relationship with, when not assigned to a constant so it could
never be used anyway...
The commits around why that exist give no context, and I think they're
just poorly written tests (WTF does `test_schema` mean anyway, and why
does calling `.first` on some anonymous class test it?). We'll just
disable STI on that class.
|
|/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This solves the following issue:
```
$ bin/test
Using sqlite3
/Users/senny/Projects/rails/activerecord/test/cases/adapters/mysql2/sp_test.rb:16:in `<class:Mysql2StoredProcedureTest>': undefined method `version' for #<ActiveRecord::ConnectionAdapters::SQLite3Adapter:0x007f8bab4b5b70> (NoMethodError)
from /Users/senny/Projects/rails/activerecord/test/cases/adapters/mysql2/sp_test.rb:5:in `<top (required)>'
from /Users/senny/Projects/rails/activesupport/lib/active_support/dependencies.rb:302:in `require'
from /Users/senny/Projects/rails/activesupport/lib/active_support/dependencies.rb:302:in `block in require'
from /Users/senny/Projects/rails/activesupport/lib/active_support/dependencies.rb:268:in `load_dependency'
from /Users/senny/Projects/rails/activesupport/lib/active_support/dependencies.rb:302:in `require'
from /Users/senny/Projects/rails/railties/lib/rails/test_unit/test_requirer.rb:11:in `block in require_files'
from /Users/senny/Projects/rails/railties/lib/rails/test_unit/test_requirer.rb:10:in `each'
from /Users/senny/Projects/rails/railties/lib/rails/test_unit/test_requirer.rb:10:in `require_files'
from /Users/senny/Projects/rails/railties/lib/rails/test_unit/minitest_plugin.rb:69:in `plugin_rails_init'
from /Users/senny/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/minitest-5.3.3/lib/minitest.rb:73:in `block in init_plugins'
from /Users/senny/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/minitest-5.3.3/lib/minitest.rb:71:in `each'
from /Users/senny/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/minitest-5.3.3/lib/minitest.rb:71:in `init_plugins'
from /Users/senny/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/minitest-5.3.3/lib/minitest.rb:122:in `run'
from bin/test:19:in `<main>'
```
|
|\
| |
| | |
Add stored procedure test in mysql2
|
| | |
|
|/
|
|
|
|
| |
Currently `tinyblob` is dumped to `t.binary "tiny_blob", limit: 255`.
But `t.binary ... limit: 255` is generating SQL to `varchar(255)`.
It is incorrect. This commit fixes this problem.
|
|\
| |
| | |
Allow mysql and mysql2 tests run by database user with password
|
| | |
|
| |
| |
| |
| |
| |
| | |
`pk_and_sequence_for` is implemented for PG and MySQL adapters (not
implemented for Sqlite3 adapter). But MySQL adapters are not using
`pk_and_sequence_for` already.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
We should not run MysqlAdapter tests when running with `sqlite3_mem`.
This also moves the test-case outside the MysqlAdapter namespace. This
will prevent the following error when running everything:
```
1) Error:
TestAdapterWithInvalidConnection#test_inspect_on_Model_class_does_not_raise:
TypeError: superclass mismatch for class MysqlAdapter
```
|
| | |
|
| | |
|
|\ \
| | |
| | |
| | | |
Add `unsigned` support for numeric data types in MySQL
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
In the case of using `unsigned` as the type:
create_table :foos do |t|
t.unsigned_integer :unsigned_integer
t.unsigned_bigint :unsigned_bigint
t.unsigned_float :unsigned_float
t.unsigned_decimal :unsigned_decimal, precision: 10, scale: 2
end
|
| |/
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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
|
|\ \
| | |
| | |
| | | |
Move `explain` into `AbstractMysqlAdapter`
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
Common methods in both mysql adapters are should be added to
`AbstractMysqlAdapter`, but some methods had been added to
`Mysql2Adapter`. (8744632f, 0306f82e, #14359)
Some methods already moved from `Mysql2Adapter` to
`AbstractMysqlAdapter`. (#17601, #17998)
Common methods in both mysql adapters are remaining only the `explain`
method in `Mysql2Adapter`.
|
|\ \ \
| | | |
| | | | |
Remove unnecessary display width
|
| | |/
| |/|
| | |
| | |
| | |
| | |
| | | |
The **(11)** does not affect the storage size of the data type, which for an
INT will always be 4 bytes. It affects the **display width**.
http://www.tocker.ca/2015/07/02/proposal-to-deprecate-mysql-integer-display-width-and-zerofill.html
|
| | |
| | |
| | |
| | |
| | | |
Some test cases are testing only mysql adapter. We should test mysql2
adapter also.
|
|/ /
| |
| |
| |
| | |
`@connection` in `StatementPool` is only used for PG adapter.
No need for abstract `StatementPool` class.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
As described in the "Follow Coding Conventions" section in our
contribution guide (http://edgeguides.rubyonrails.org/contributing_to_ruby_on_rails.html#follow-the-coding-conventions)
we favor `assert_not` over `refute`.
While we don't usually make stylistic changes on it's own I opted to do
it in this case. The reason being that test cases are usually copied as
a starting point for new tests. This results in a spread of `refute` in
files that have been using it already.
|
| |
| |
| |
| | |
this fixes a failing test case
|
| |
| |
| |
| | |
support it. Fixes #19711
|
| | |
|
| |
| |
| |
| | |
Related with #17370.
|
| | |
|
|\ \
| | |
| | |
| | | |
Correctly dump `:options` on `create_table` for MySQL
|
| | | |
|
|/ / |
|
| |
| |
| |
| |
| |
| | |
`use_transactional_fixtures` was deprecated in favor of
`use_transactional_tests` in Rails 5.0. This removes one warning while
running test suite.
|
|\ \
| | |
| | |
| | | |
Add charset and collation options support for MySQL string and text columns.
|
| |/
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
columns
Example:
create_table :foos do |t|
t.string :string_utf8_bin, charset: 'utf8', collation: 'utf8_bin'
t.text :text_ascii, charset: 'ascii'
end
|
|/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
I’m renaming all instances of `use_transcational_fixtures` to
`use_transactional_tests` and “transactional fixtures” to
“transactional tests”.
I’m deprecating `use_transactional_fixtures=`. So anyone who is
explicitly setting this will get a warning telling them to use
`use_transactional_tests=` instead.
I’m maintaining backwards compatibility—both forms will work.
`use_transactional_tests` will check to see if
`use_transactional_fixtures` is set and use that, otherwise it will use
itself. But because `use_transactional_tests` is a class attribute
(created with `class_attribute`) this requires a little bit of hoop
jumping. The writer method that `class_attribute` generates defines a
new reader method that return the value being set. Which means we can’t
set the default of `true` using `use_transactional_tests=` as was done
previously because that won’t take into account anyone using
`use_transactional_fixtures`. Instead I defined the reader method
manually and it checks `use_transactional_fixtures`. If it was set then
it should be used, otherwise it should return the default, which is
`true`. If someone uses `use_transactional_tests=` then it will
overwrite the backwards-compatible method with whatever they set.
|
|
|
|
|
| |
Lowercase raw SQL has been replaced by 07b659c already. This commit
replaces everything else of raw SQL.
|
|
|
|
|
|
|
| |
/cc @yahonda
This makes it easier for third party adapters to run our tests,
even if that database does not support IF EXISTS.
|
| |
|
|
|
|
| |
The datetime precision tests for any adapters is duplicated.
|
|
|
|
| |
onwards.
|
|
|
|
|
|
|
|
| |
`bound_attributes` is now used universally across the board, removing
the need for the conversion layer. These changes are mostly mechanical,
with the exception of the log subscriber. Additional, we had to
implement `hash` on the attribute objects, so they could be used as a
key for query caching.
|
|\
| |
| |
| |
| |
| |
| |
| |
| | |
kamipo/format_datetime_string_according_to_precision
Format the datetime string according to the precision of the datetime field.
Conflicts:
activerecord/CHANGELOG.md
|
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Incompatible to rounding behavior between MySQL 5.6 and earlier.
In 5.5, when you insert `2014-08-17 12:30:00.999999` the fractional part
is ignored. In 5.6, it's rounded to `2014-08-17 12:30:01`:
http://bugs.mysql.com/bug.php?id=68760
|
|/ |
|
|
|
|
|
| |
The behavior tested by the removed lines is sufficiently covered
elsewhere.
|
|
|
|
|
|
|
| |
When table has a composite primary key, the `primary_key` method for
sqlite3 and postgresql was only returning the first field of the key.
Ensures that it will return nil instead, as AR dont support composite pks.
|