Commit Graph

54045 Commits

Author SHA1 Message Date
yui-knk
6011ab853c Define sanitize_sql_for_order for AR and use it inside preprocess_order_args
This commit follows up of 6a6dbb4c51fb0c58ba1a810eaa552774167b758a.
2015-11-02 21:18:18 +09:00
Andrew White
57493eae3d Merge pull request #22090 from kamipo/bigint_default_nil
Allow bigint with default nil for avoiding auto increment primary key
2015-11-02 12:12:45 +00:00
Ryuta Kamizono
1fa6c9e5fb Allow bigint with default nil for avoiding auto increment primary key
Such as #10404, #18206.
2015-11-02 12:12:20 +00:00
Andrew White
fb6f0d406b Merge pull request #22061 from kamipo/remove_default_charset_and_collation
Remove `DEFAULT_CHARSET` and `DEFAULT_COLLATION`
2015-11-02 12:08:19 +00:00
Ryuta Kamizono
322068fe85 Remove DEFAULT_CHARSET and DEFAULT_COLLATION in MySQLDatabaseTasks
This reverts commit f6ca7e4e75408bc42f515fc7206d6c6ff0dce7c6.

The default collation of utf8 in MySQL is the `utf8_general_ci`, and
this should not be changed. This is because, the better collation in the
all locales is not exists, optimal collation in own application is not
known other than themselves.

The `utf8_unicode_ci` is known as Japanese killer in Japan, there are
serious impacts in search of Japanese.

MySQL implements the `utf8_unicode_ci` according to the Unicode
Collation Algorithm (UCA) described at http://www.unicode.org/reports/tr10/,
but the `utf8_unicode_ci` have only partial support for the UCA, only
primary level key comparison implemented (also known as L1 (Base
characters) comparison).

Because L1 (Base characters) comparison does not distinguish between the
presence or absence of the accent, if distinction of the accent is
important there is a serious impact (e.g. Japanese).

Example:

```
> SHOW CREATE TABLE `dicts`\G
*************************** 1. row ***************************
       Table: dicts
Create Table: CREATE TABLE `dicts` (
  `word` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `meaning` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci
1 row in set (0.00 sec)

> INSERT INTO `dicts` VALUES ('ハハ', 'mother'), ('パパ', 'father');
Query OK, 2 rows affected (0.00 sec)

> SELECT * FROM `dicts` WHERE `word` = 'ハハ';
+--------+---------+
| word   | meaning |
+--------+---------+
| ハハ   | mother  |
| パパ   | father  |
+--------+---------+
2 rows in set (0.00 sec)

> CREATE UNIQUE INDEX `unique_index_word` ON `dicts`(`word`);
ERROR 1062 (23000): Duplicate entry 'ハハ' for key 'unique_index_word'
```

We should omit the collation entirely rather than providing a default.
Then the choice is the responsibility of the server and MySQL distribution.
2015-11-02 20:44:48 +09:00
Andrew White
10a80e39fe Merge pull request #22130 from k0kubun/left-joins-changelog
Add CHANGELOG entry for #22125 [ci skip]
2015-11-02 11:09:34 +00:00
Takashi Kokubun
2a90d60c94 Add CHANGELOG entry for #22125 [ci skip] 2015-11-02 11:08:00 +00:00
Andrew White
5b7afb81ae Merge pull request #22131 from yui-knk/move_test_to_inheritance_test
Move some AR test cases to inheritance_test.rb
2015-11-02 10:59:56 +00:00
Andrew White
46b08da0ea Merge pull request #22149 from samphilipd/master
Update changelog for #22122
2015-11-01 21:40:06 +00:00
Sam Davies
2e43eefa94 Update changelog for #22122 2015-11-01 17:52:03 -03:00
Richard Schneeman
9e78eb18e5 Merge pull request #22147 from jwworth/pull-request/double-string
Fix double word 'string' [ci skip]
2015-11-01 11:24:46 -06:00
Jake Worth
1f47adcc29 Fix double word 'string' [ci skip] 2015-11-01 11:20:59 -06:00
Andrew White
d53de10cb3 Merge pull request #22083 from thejamespinto/idempotent-route-generator
Route generator should be idempotent
2015-11-01 09:01:49 +00:00
Vijay Dev
b217354dbb Merge branch 'master' of github.com:rails/docrails 2015-10-31 17:01:41 +00:00
Arun Agrawal
e913834e92 Merge pull request #22140 from jwworth/pull-request/fix-double-word
Fix double word 'be' [ci skip]
2015-10-31 17:55:11 +01:00
Jake Worth
1c44d96867 Fix double word 'be' [ci skip] 2015-10-31 11:52:39 -05:00
Arun Agrawal
53ac41e48b Merge pull request #22136 from y-yagi/fix_changelog_format
minor formatting changes [ci skip]
2015-10-31 07:07:15 +01:00
yuuji.yaginuma
a9402862a1 minor formatting changes [ci skip]
* add newline for display the fenced code block
* add "#" in the comments section
2015-10-31 14:52:24 +09:00
Thiago Pinto
a9f9e1dd98 Route generator should be idempotent - closes #22082 2015-10-31 01:16:38 -02:00
yui-knk
2fe8baf9b2 Move some AR test cases to inheritance_test.rb
These methods are defined in inheritance.rb

* `abstract_class?`
* `descends_from_active_record?`
* `compute_type`
2015-10-31 08:30:18 +09:00
Aaron Patterson
e76c38ef10 split process from mailer instantiation
this allows us to construct mailer objects without possibly disastrous
side-effects.
2015-10-30 14:53:19 -07:00
Sean Griffin
d2315d0c3b Merge pull request #22125 from k0kubun/left_joins
Alias left_joins to left_outer_joins
2015-10-30 14:05:11 -06:00
Rafael Mendonça França
d52baa8514 Add tasks to automatize CHANGELOG headers 2015-10-30 18:03:18 -02:00
Rafael Mendonça França
08225104d1 ✂️ 2015-10-30 17:50:53 -02:00
Sean Griffin
eb6cdcab39 Merge pull request #21251 from rodzyn/more_param_parser_tests
Add test for parsing application/vnd.api+json
2015-10-30 13:44:04 -06:00
Rafael França
35caf46e86 Merge pull request #22128 from Sirupsen/config-for-env
rails/application: allow passing an env to config_for
2015-10-30 17:02:15 -02:00
Simon Eskildsen
e58c96766f rails/application: allow passing an env to config_for 2015-10-30 18:57:54 +00:00
Aaron Patterson
cb848c8dd7 don't sleep in tests
we should be using a countdown latch instead of rolling our own
busy-loop.
2015-10-30 10:30:21 -07:00
Sean Griffin
61205422ba Merge pull request #22122 from samphilipd/sam/manual_locking_on_schema_migrations
Make migrations concurrent safe (using advisory locks)
2015-10-30 11:05:40 -06:00
Sam Davies
2c2a875546 Use advisory locks to prevent concurrent migrations
- 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.
2015-10-30 14:04:16 -03:00
Sean Griffin
3cd49570c5 Fix test failures caused by #12071
This assumes only one query was ever executed, but it appears to
sometimes be loading schema information. We can just look at the array
of queries, rather than the "first" one that was run
2015-10-30 10:53:37 -06:00
Takashi Kokubun
d3411ad361 Alias left_joins to left_outer_joins 2015-10-31 01:37:35 +09:00
Sean Griffin
6c61ae816a Merge pull request #11872 from AvnerCohen/log_namespace
When testing cache issues, it is useful to log the actual key, including namespace
2015-10-30 09:44:54 -06:00
Sean Griffin
e038975c29 Merge pull request #12071 from Crunch09/outer_joins
added ActiveRecord::Relation#outer_joins
2015-10-30 09:42:02 -06:00
Rafael Mendonça França
67417f1821 Add version constraint to database gem in generated application
We are using the same version constraint in the database adapters so
when a new version of the adapter that doesn't work with the version of
rails is released we don't break new applications.
2015-10-29 22:09:23 -02:00
Aaron Patterson
8941831733 Revert "ActionController::Base#process() now only takes an action name"
This reverts commit 9f93a5efbba3e1cbf0bfa700a17ec8d1ef60d7c6.
2015-10-29 16:18:27 -07:00
Sean Griffin
21a386bb07 Ensure has_and_belongs_to_many works with belongs_to_required_by_default
Before this commit, if
`ActiveRecord::Base.belongs_to_required_by_default` is set to `true`,
then creating a record through `has_and_belongs_to_many` fails with the
cryptic error message `Left side must exist`. This is because
`inverse_of` isn't working properly in this case, presumably since we're
doing trickery with anonymous classes in the middle.

Rather than following this rabbit hole to try and get `inverse_of` to
work in a case that we know is not publicly supported, we can just turn
off this validation to match the behavior of 4.2 and earlier.
2015-10-29 16:53:49 -06:00
Aaron Patterson
9f93a5efbb ActionController::Base#process() now only takes an action name
rather than an action name and *args.  The *args were not being used in regular
applications outside tests.  This causes a backwards compatibility
issue, but reduces array allocations for most users.
2015-10-29 15:40:18 -07:00
Aaron Patterson
82328a563f switch to JSON.dump to avoid infinite recursion 2015-10-29 14:42:52 -07:00
Sean Griffin
7f41321cbd Add a changelog entry for #13008 2015-10-29 15:29:37 -06:00
Sean Griffin
6a6dbb4c51 Merge pull request #13008 from ktheory/sanitize_order
Support SQL sanitization in AR::QueryMethods#order
2015-10-29 15:29:06 -06:00
eileencodes
42eb37ab51 use dispatch instead of process to run requests though
`dispatch` sets the request and response on the controller for us
automatically, so the test harness doesn't need to know the internals of
how request / response is set.

Conflicts:
	actionpack/lib/action_controller/test_case.rb
2015-10-29 14:24:25 -07:00
eileencodes
b329fbb5f2 Remove unnecessary method 2015-10-29 14:12:19 -07:00
Sean Griffin
83e00c642b Merge pull request #19511 from larskanis/replace_const_conn_params
PostgreSQL, Replace static connection param list by libpq's dynamic list
2015-10-29 15:05:30 -06:00
Andrew White
a25c2cbbec Merge pull request #22121 from gocardless/patch-2
Set standard_conforming_strings with SET
2015-10-29 20:59:53 +00:00
Harry Marr
6a9323bca4 Don't disable errors when turning standard_conforming_strings on 2015-10-29 20:30:48 +00:00
Andrew White
97b3603fb6 Merge pull request #22119 from philr/time_with_zone_documentation
ActiveSupport::TimeWithZone documentation
2015-10-29 20:18:47 +00:00
Sean Griffin
a59a4fbdb0 Never pass nil to order
This is part of a refactoring to make it easier to allow `order` to use
sanitize like just about everything else on relation. The deleted test
doesn't give any reasoning as to why passing `nil` to `order` needs to
be supported, and it's rather nonsensical. I can almost see allowing an
empty string being passed (though I'm tempted to just disallow it...)
2015-10-29 13:43:23 -06:00
Yves Senn
38061a7bec Merge pull request #22106 from jamis/fix_default_fixture_class_names
default value for FixtureSet.fixture_class_names ought to be a Class
2015-10-29 19:37:33 +01:00
Phil Ross
028b4e3ce3 Fix the example given in the documentation for TimeWithZone#-
The stated value of `now` would actually give the same result for
`now - 24.hours` and `now - 1.day`. Use an alternative value for
`now` that demonstrates the difference between subtracting
`24.hours` and `1.day`.
2015-10-29 17:51:21 +00:00