| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
| |
- mysql will add a 2 bytes margin to the statement, so given a `max_allowed_packet` set to 1024 bytes, a 1024 bytes fixtures will no be inserted (mysql will throw an error)
- Preventing this by decreasing the max_allowed_packet by 2 bytes when doing the comparison with the actual statement size
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
- The `insert_fixtures` method can be optimized by making a single multi statement query for all fixtures having the same connection instead of doing a single query per table
- The previous code was bulk inserting fixtures for a single table, making X query for X fixture files
- This patch builds a single **multi statement query** for every tables. Given a set of 3 fixtures (authors, dogs, computers):
```ruby
# before
%w(authors dogs computers).each do |table|
sql = build_sql(table)
connection.query(sql)
end
# after
sql = build_sql(authors, dogs, computers)
connection.query(sql)
```
- `insert_fixtures` is now deprecated, `insert_fixtures_set` is the new way to go with performance improvement
- My tests were done with an app having more than 700 fixtures, the time it takes to insert all of them was around 15s. Using a single multi statement query, it took on average of 8 seconds
- In order for a multi statement to be executed, mysql needs to be connected with the `MULTI_STATEMENTS` [flag](https://dev.mysql.com/doc/refman/5.7/en/c-api-multiple-queries.html), which is done before inserting the fixtures by reconnecting to da the database with the flag declared. Reconnecting to the database creates some caveats:
1. We loose all open transactions; Inside the original code, when inserting fixtures, a transaction is open. Multple delete statements are [executed](https://github.com/rails/rails/blob/a681eaf22955734c142609961a6d71746cfa0583/activerecord/lib/active_record/fixtures.rb#L566) and finally the fixtures are inserted. The problem with this patch is that we need to open the transaction only after we reconnect to the DB otherwise reconnecting drops the open transaction which doesn't commit all delete statements and inserting fixtures doesn't work since we duplicated them (Primary key duplicate exception)...
- In order to fix this problem, the transaction is now open directly inside the `insert_fixtures` method, right after we reconnect to the db
- As an effect, since the transaction is open inside the `insert_fixtures` method, the DELETE statements need to be executed here since the transaction is open later
2. The same problem happens for the `disable_referential_integrity` since we reconnect, the `FOREIGN_KEY_CHECKS` is reset to the original value
- Same solution as 1. , the disable_referential_integrity can be called after we reconnect to the transaction
3. When the multi statement query is executed, no other queries can be performed until we paginate over the set of results, otherwise mysql throws a "Commands out of sync" [Ref](https://dev.mysql.com/doc/refman/5.7/en/commands-out-of-sync.html)
- Iterating over the set of results until `mysql_client.next_result` is false. [Ref](https://github.com/brianmario/mysql2#multiple-result-sets)
- Removed the `active_record.sql "Fixture delete"` notification, the delete statements are now inside the INSERT's one
- On mysql the `max_allowed_packet` is looked up:
1. Before executing the multi-statements query, we check the packet length of each statements, if the packet is bigger than the max_allowed_packet config, an `ActiveRecordError` is raised
2. Otherwise we concatenate the current sql statement into the previous and so on until the packet is `< max_allowed_packet`
|
|\
| |
| | |
Quote colum_names when building select:
|
| |
| |
| |
| |
| |
| |
| |
| | |
- #30980 introcuded a change to not use `Arel.star` when model have ignored columns, a query used to look like `SELECT *. FROM developers` whereas now it would like `SELECT column1, column2 FROM developers`
- If a column has the same name has a reserved database specific keyword (such as key, where ...) then the query would fail because the names aren't quoted
- Quoting almost always happen unless we use a `from` clause in the query https://github.com/rails/rails/blob/9965b98dc0d58a86e10b4343bb6e15e01661a8c3/activerecord/lib/active_record/relation/query_methods.rb#L1052
- This PR cast all columns name to symbols in order for the quoting logic to be picked up https://github.com/rails/rails/blob/9965b98dc0d58a86e10b4343bb6e15e01661a8c3/activerecord/lib/active_record/relation/query_methods.rb#L1054-L1055
- A reproduction script can be found here https://gist.github.com/Edouard-chin/f56d464a0adcb76962afc1a9134a1536
|
|\ \
| | |
| | | |
Revert "only install ffmpeg and mupdf on activestorage builds"
|
| | |
| | |
| | |
| | | |
This reverts commit 6ec0ed67d9afcc666ad0424b10e9903f63e60714.
|
|\ \ \
| |/ /
|/| | |
[ci skip] Fix Active Support Changelog about :race_condition_ttl
|
|/ / |
|
|\ \
| | |
| | | |
Remove stale comment about `ActiveRecord::SchemaDumper.ignore_tables` [skip ci]
|
|/ / |
|
| |
| |
| |
| | |
Follow up of #31390.
|
|\ \
| | |
| | | |
Prevent race condition when resetting time stubs
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
If the current thread is preempted after the stub has been removed but
before the original method has been restored, then the other thread will
get a `NoMethodError` when it tries to call the method.
Using `silence_redefinition_of_method` instead of `undef_method` ensures
that either the stub or the original method is always in place.
|
|\ \ \
| |/ /
|/| | |
Fix secrets command deprecation message
|
| | | |
|
|\ \ \
| |/ /
|/| | |
[ci skip] Update routing guide for Direct & resolved routes
|
| | |
| | |
| | |
| | | |
* Added the direct method to routing guide.
|
| | | |
|
| | |
| | |
| | |
| | | |
This reverts commit a80f81af055f02bf4625c90470aa90441cf6fc24.
|
|\ \ \
| | | |
| | | | |
`create_fixtures` doesn't work since at least a94220b
|
| | |/
| |/|
| | |
| | |
| | |
| | |
| | | |
a94220b66c9e4890007f66b092b25f8a64a19d31:
- The namespacing should be `ActiveRecord::FixtureSet`
- I might be missing something but I'm not sure why `create_fixtures` is useful for nowaday (unless for testing rails internal /shrug) and since it's been that long it wasn't working I think it should be fine to just fire it
|
|\ \ \
| | | |
| | | | |
Return `nil` instead of `false` if raise `Azure::Core::Http::HTTPError`
|
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
* If it raise error `Azure::Core::Http::HTTPError`, return `nil` instead of `false` in
`ActiveStorage::Service::AzureStorageService#delete`.
* Other services behave as same as this.
|
|\ \ \ \
| |_|/ /
|/| | |
| | | |
| | | | |
yhirano55/update_instrumentation_guide_for_active_storage_service
[ci skip] Update instrumentation guide for ActiveStorage
|
| | |/
| |/|
| | |
| | | |
* Added `service_delete_prefixed.active_storage`.
|
|/ /
| |
| |
| | |
Execute a single mogrify command with multiple options rather than one command per option. Permit the use of all mogrify options, not just the ones that fall through to MiniMagick::Image#method_missing.
|
|\ \
| | |
| | | |
StreamingTemplateRenderer fails to forward I18n.locale in layouts
|
| | |
| | |
| | |
| | | |
stores the current locale in Thread.current[:local] (see: https://github.com/svenfuchs/i18n/blob/master/lib/i18n.rb#L23). StreamingTemplateRenderer is implemented with Fiber which have its own stack of locals and can not access Thread.current.locals(keys, see: https://ruby-doc.org/core-2.2.0/Thread.html#class-Thread-label-Fiber-local+vs.+Thread-local).
|
|\ \ \
| | | |
| | | | |
`webpack` is assigned but never used in webpack.config.js
|
| | |/
| |/|
| | |
| | | |
* Removed webpack const, so it is assigned but never used in webpack.config.js.
|
|\ \ \
| |/ /
|/| | |
Remove whitespace
|
|/ / |
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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
|
|\ \
| | |
| | | |
Change the system tests to set Puma as default server only when the user haven't specified manually another server.
|
|/ /
| |
| |
| | |
haven't specified manually another server.
|
| |
| |
| |
| | |
default headers set.
|
|\ \
| | |
| | | |
CI against JRuby 9.1.15.0
|
| | |
| | |
| | |
| | |
| | | |
JRuby 9.1.15.0 has been released:
http://jruby.org/2017/12/07/jruby-9-1-15-0.html
|
|\ \ \
| | | |
| | | | |
docs: add example for a nil name in link_to
|
| | | | |
|
|\ \ \ \
| |_|/ /
|/| | | |
Fix Rails environment when running tests with Ruby
|
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
Option parsing happens too late to have any impact on the Rails
environment. Rails accesses the environment name and memoizes it too
early in the boot process for a commandline option to have any impact on
the database connection, so we'll change this test to set the
environment from an environment variable (and ensure it still works when
running tests with `ruby`)
|
| | | |
| | | |
| | | |
| | | | |
This reverts commit 9a80f52541ed2c93ebef02909ecab3aaf9127150.
|
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
When tests are run with just `ruby`, the RAILS_ENV is set to
`development` too early, and we connect to the development database
rather than the test database.
|
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
I frequently run tests with `ruby`, not with a runner like `rake` or
`rails`. When running the test with just `ruby` the `RAILS_ENV`
environment variable did not get set to "test", and this would cause the
tests to fail (and even mutate the development database!)
This commit adds integration tests for running tests with just `ruby`
and ensures the environment gets defaulted to "test". I also added a
test to ensure that passing an environment to `-e` actually works (and
fixed that case too).
An interesting / annoying thing is that Minitest picks up it's plugins
by asking RubyGems for a list of files:
https://github.com/seattlerb/minitest/blob/ca6a71ca901016db09a5ad466b4adea4b52a504a/lib/minitest.rb#L92-L100
This means that RubyGems needs to somehow know about the file before it
can return it to Minitest. Since we are not packaging Rails as a Gem
before running the integration tests on it (duh, why would you do
that?), RubyGems doesn't know about the file, so it can't tell Minitest,
so Minitest doesn't automatically require it. This means I had to
manually require and insert the plugin in our integration test. I've
left comments about that in the test as well.
Ugh.
|
| | | | |
|
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
`connection.primary_key` also return composite primary keys, so
`from_primary_key_column` may not be found even if `from_primary_key` is
presented.
```
% ARCONN=sqlite3 be ruby -w -Itest
test/cases/adapters/sqlite3/sqlite3_adapter_test.rb -n
test_copy_table_with_composite_primary_keys
Using sqlite3
Run options: -n test_copy_table_with_composite_primary_keys --seed 19041
# Running:
E
Error:
ActiveRecord::ConnectionAdapters::SQLite3AdapterTest#test_copy_table_with_composite_primary_keys:
NoMethodError: undefined method `type' for nil:NilClass
/path/to/rails/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb:411:in
`block in copy_table'
```
This change fixes `copy_table` to do not lose composite primary keys.
|
|\ \ \ \
| | | | |
| | | | |
| | | | |
| | | | | |
JackMc/fix-chrome-referrer-invalidauthenticitytoken
Fix issue #30658 by checking explicitly for 'null' referrer
|
| | | | | |
|