| Commit message (Collapse) | Author | Age | Files | Lines |
|\
| |
| |
| |
| |
| |
| |
| |
| | |
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
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
The PR #27384 changed migration compatibility behaviour.
```ruby
class CreateMasterData < ActiveRecord::Migration[5.0]
def change
create_table :master_data, id: :integer do |t|
t.string :name
end
end
end
```
Previously this migration created non-autoincremental primary key
expected. But after the PR, the primary key changed to autoincremental,
it is unexpected.
This change restores the behaviour of the compatibility layer.
|
|/
|
|
|
|
|
| |
```
go get -u github.com/client9/misspell/cmd/misspell
misspell -w -error -source=text .
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
|
| |
This message could be generated by `assert_predicate`, https://github.com/rails/rails/commit/1853a4f2c8b2bddfbde6aae80abb08310295201c#commitcomment-20546113
but I'd rather handwrite the message string if I could reduce magic from the code by doing so.
|
|
|
|
|
|
| |
`initialize_internal_metadata_table`
These internal initialize methods are no longer used internally.
|
|
|
|
|
| |
This reverts commit 39c77eb1843f79925c7195e8869afc7cb7323682, reversing
changes made to 9f6f51be78f8807e18fc6562c57af2fdbf8ccb56.
|
| |
|
|
|
|
|
|
| |
These are followups for 307065f959f2b34bdad16487bae906eb3bfeaf28,
but TBH I'm personally not very much confortable with this style.
Maybe we could override assert_equal in our test_helper not to warn?
|
|
|
|
|
|
|
|
|
|
|
|
| |
`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
|
|\
| |
| | |
Fix UUID primary key with default nil in legacy migration
|
| |
| |
| |
| |
| |
| | |
UUID primary key with no default value feature (#10404, #18206) was lost
in legacy migration caused by #25395 got merged. Restore the feature
again in legacy migration.
|
| | |
|
| |
| |
| |
| | |
(I personally prefer writing one string in one line no matter how long it is, though)
|
|/
|
|
|
|
|
|
|
|
|
|
|
| |
Mysql2ConnectionTest#test_execute_after_disconnect was originally added to
catch a NoMethodError occuring in execute when the Mysql2Adapter has a nil
`@connection`. Pull request #26869 removed the error message check in that
test because the error message changed in the mysql2 gem, which caused the
test to fail. Now the test wouldn't catch the original bug since the
NoMethodError would get turned into a ActiveRecord::StatementInvalid
exception.
Check the cause of the StatementInvalid exception to make sure it is of the
correct type.
|
|
|
|
|
|
|
|
|
|
| |
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
|
|\
| |
| |
| |
| | |
mtsmfm/disable-referential-integrity-without-superuser-privileges
Use `SET CONSTRAINTS` for `disable_referential_integrity` without superuser privileges
|
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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.
|
| |
| |
| |
| |
| | |
Passing `name` to `tables` is already deprecated at #21601.
Passing `name` to `indexes` is also unused.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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.
|
| |
| |
| |
| |
| | |
Currently schema dumper does not dump array subtype `precision` and
`scale` options. This commit fixes the issue.
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
|\ \
| | |
| | | |
Simplify the regex for `unsigned?` method
|
| | |
| | |
| | |
| | |
| | | |
It is enough to distinguish only the trailing `unsigned` and
`unsigned zerofill`.
|
|/ /
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
This fixes the following warning.
```
test/caching_test.rb:986: warning: parentheses after method name is interpreted as
test/caching_test.rb:986: warning: an argument list, not a decomposed argument
test/cases/adapters/mysql2/reserved_word_test.rb:146: warning: parentheses after method name is interpreted as
test/cases/adapters/mysql2/reserved_word_test.rb:146: warning: an argument list, not a decomposed argument
```
Ref: https://github.com/ruby/ruby/commit/65e27c8b138d6959608658ffce2fa761842b8d24
|
| |
| |
| |
| | |
Raise `ActiveRecord::RangeError` when values that executed are out of range.
|
|\ \
| | |
| | | |
Fix `add_index` to normalize column names and options
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
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.
|
| |/
|/| |
|
| |
| |
| |
| | |
Fixes #27125.
|
| |
| |
| |
| |
| | |
If it's enabled globally, it's on regardless of how individual threads
are set.
|
| | |
|
| |
| |
| |
| | |
Follow up to #25395.
|
|\ \
| | |
| | | |
Suppress migration message in the test
|
| | | |
|
|/ / |
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Since 9.4, PostgreSQL recommends using `pgcrypto`'s `gen_random_uuid()`
to generate version 4 UUIDs instead of the functions in the `uuid-ossp`
extension.
These changes uses the appropriate UUID function depending on the
underlying PostgreSQL server's version, while maintaining
`uuid_generate_v4()` in older migrations.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
- Due to `assert_nothing_raised` this test was not really testing
anything.
- So updated it to assert that the query gives expected result.
- Also in general we can use `connection.unprepared_statement` for
testing queries w/o prepared statements but it can't be used in this
case. This test cases was added because when prepared_statements
config is set to false, then DetermineIfPreparableVisitor module
does not extended by Arel visitor resulting into an error. Ref: https://github.com/rails/rails/pull/22748.
- Because DetermineIfPreparableVisitor module does not get added to the
visitor chain only if prepared_statements is false while **setting up
connection**, not when `unprepared_statement` is used.
- I have also added an assertion for making sure that prepared_config
is set to false from the start, so that nobody accidentally removes
the connection setup using `arunit_without_prepared_statements` and
replaces it with stubs or unprepared_statement.
|
| |
| |
| |
| | |
Follow up to #27109.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
- The query needs to be executed for hitting `select_all` so made sure
that query gets executed.
- Also instead of changing instance variable, just add new
configuration for prepared_statements: false and use it for this
test.
- This way we don't have to touch the internals of AR code and still
disable prepared statements config for this test.
|
|\ \
| | |
| | | |
use `force_encoding` instread of `encode!` to avoid `UndefinedConversionError`
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
`PG::TextEncoder::Array#encode` returns the encoded value with `ASCII-8BIT`.
But in some cases, trying to convert `ASCII-8BIT` to `UTF-8` cause an error.
```ruby
"{\xE3\x83\x95\xE3\x82\xA1\xE3\x82\xA4\xE3\x83\xAB}".encode!(Encoding::UTF_8)
# => Encoding::UndefinedConversionError: "\xE3" from ASCII-8BIT to UTF-8
```
Should use `force_encoding` to avoid this error.
Follow up to 7ba3a48df5bfdc5e98506bb829f937e03b55a5b3
Ref: https://github.com/rails/rails/pull/23619#issuecomment-189924036
|
| | | |
|
| | | |
|
|/ /
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
As reported via #26904, there is a regression in how values for
Postgres' HStore column type are being processed, beginning in Rails 5.
Currently, the way that Active Record checks whether or not values need
to be serialized and put into the correct storage format is whether or
not it is a `Hash` object. Since `ActionController::Parameters` no
longer inherits from `Hash` in Rails 5, this conditional now returns
false. To remedy this, we are now checking to see whether the `value`
parameters being passed in responds to a certain method, and then
calling the `serialize` method, except this time with a real Hash
object. Keeping things DRY!
Fixes #26904.
|