Commit Graph

59028 Commits

Author SHA1 Message Date
Sean Griffin
b63d532f1e Don't assume all hashes are from multiparameter assignment in composed_of
So this bug is kinda funky. The code path is basically "if we weren't passed an
instance of the class we compose to, and we have a converter, call that".
Ignoring the hash case for a moment, everything after that was roughly intended
to be the "else" clause, meaning that we are expected to have an instance of
the class we compose to. Really, we should be blowing up in that case, as we
can give a much better error message than what they user will likely get (e.g.
`NameError: No method first for String` or something). Still, Ruby is duck
typed, so if the object you're assigning responds to the same methods as the
type you compose to, knock yourself out.

The hash case was added in 36e9be8 to remove a bunch of special cased code from
multiparameter assignment. I wrongly assumed that the only time we'd get a hash
there is in that case. Multiparameter assignment will construct a very specific
hash though, where the keys are integers, and we will have a set of keys
covering `1..part.size` exactly. I'm pretty sure this could actually be passed
around as an array, but that's a different story. Really I should convert this
to something like `class MultiParameterAssignment < Hash; end`, which I might
do soon. However for a change that I'm willing to backport to 4-2-stable, this
is what I want to go with for the time being.

Fixes #25978
2016-08-05 09:52:09 -04:00
David Heinemeier Hansson
320d40123a Merge pull request #26059 from rails/rename-deadlock-detected-to-deadlocked
The problem isn't the detection but the deadlock itself
2016-08-04 15:57:34 -07:00
David Heinemeier Hansson
01a69e27a4 Offer invitations to use retry_on/discard_on for common cases 2016-08-04 14:57:10 -07:00
David Heinemeier Hansson
7443a332a7 Leave internal pgsql name intact as const reference 2016-08-04 14:43:40 -07:00
David Heinemeier Hansson
ac76d551ce The problem isn't the detection but the deadlock itself 2016-08-04 14:39:09 -07:00
Guillermo Iguaran
5b469da6ec Merge pull request #26049 from kamipo/add_gemfile_lock
Add accidentally removed dependency in Gemfile.lock
2016-08-03 18:44:02 -05:00
Ryuta Kamizono
906577db06 Add accidentally removed dependency in Gemfile.lock
Follow up to ca0b6d0d416776655ed7516ac18f126fbde5315a.
2016-08-04 07:55:47 +09:00
David Heinemeier Hansson
4f5a9890b7 Guard against jobs that were persisted before we started counting executions by zeroing out nil counters 2016-08-03 14:30:39 -07:00
Sean Griffin
ca0b6d0d41 Don't require C dependencies on Windows/JRuby 2016-08-03 10:14:26 -04:00
Andrew White
0e762ecdc3 Add :weeks to the list of variable duration parts
Since 434df00 week durations are no longer converted to days. This means
we need to add :weeks to the parts that ActiveSupport::TimeWithZone will
consider being of variable duration to take account of DST transitions.

Fixes #26039.
2016-08-03 14:45:09 +01:00
Rafael Mendonça França
fac9938b91
Merge pull request #25107 from Erol/introduce-new-ar-transaction-error-classes
Introduce new ActiveRecord transaction error classes

Closes #26018
2016-08-03 07:05:22 -03:00
Rafael França
8ada07b2b8 Merge pull request #26026 from kamipo/tx_serialization_error_should_inherit_statement_invalid
`TransactionSerializationError` should inherit `StatementInvalid` for backward compatibility
2016-08-03 07:01:01 -03:00
Rafael França
ba03e6adf3 Merge pull request #26035 from kamipo/avoid_duplicated_set_inverse_instance
Avoid duplicated `set_inverse_instance` for target scope
2016-08-03 06:54:15 -03:00
Kasper Timm Hansen
cdb347bdb3 Merge pull request #26036 from kyatul/doc_string_inquirer
Add documentation for ActiveSupport::StringInquirer [ci skip]
2016-08-03 11:41:26 +02:00
kyatul
1f5a40469e Add documentation for ActiveSupport::StringInquirer [ci skip] 2016-08-03 12:43:52 +05:30
Ryuta Kamizono
954b197056 Avoid duplicated set_inverse_instance for target scope
Because `scope` (`target_scope`) is a `AssociationRelation`.
`AssociationRelation` handles `set_inverse_instance`.

https://github.com/rails/rails/blob/v5.0.0/activerecord/lib/active_record/association_relation.rb#L31-L33

See also #26022.
2016-08-03 15:20:04 +09:00
David Heinemeier Hansson
d46d61e46e Merge pull request #25991 from rails/retry-and-discard-jobs
Add retry_on/discard_on for better exception handling
2016-08-02 15:05:16 -07:00
David Heinemeier Hansson
b53da9e90b Amend the CHANGELOG 2016-08-02 15:04:45 -07:00
David Heinemeier Hansson
7efd77fae5 Fix tests against ActiveSupport::Durations 2016-08-02 14:27:01 -07:00
Kasper Timm Hansen
7f00b8fa97 Merge pull request #26022 from kamipo/remove_unnecessary_set_inverse_instance
Remove unnecessary `set_inverse_instance` in finder methods
2016-08-02 22:09:33 +02:00
Rafael Mendonça França
fdc52ddb76
Add 4.2.Z back to the maintenance list
Some Rails core members agreed to continue to maintain 4.2 until 5.1 is
released.

[ci skip]
2016-08-02 17:07:01 -03:00
David Heinemeier Hansson
2762ebd846 Merge branch 'master' into retry-and-discard-jobs 2016-08-02 12:28:56 -07:00
David Heinemeier Hansson
111227c0df Please Rubocup 2016-08-02 12:28:16 -07:00
Akira Matsuda
31c1ed95d3 Show supported DBs first in rails new --help 2016-08-03 03:36:35 +09:00
Arthur Neves
88cdecc050
Remove extra connection pool creation 2016-08-02 13:46:07 -04:00
Vijay Dev
4d288f0b43 Merge branch 'master' of github.com:rails/docrails 2016-08-02 17:38:56 +00:00
Kasper Timm Hansen
70b995a77f Fix wrong assignment.
Screwed up both the left and right hand sides!
2016-08-02 16:52:18 +02:00
Ryuta Kamizono
f78eda63ed TransactionSerializationError should inherit StatementInvalid for backward compatibility
Originally `TransactionSerializationError` was `StatementInvalid` in
Rails 5.0. It should keep backward compatibility.
2016-08-02 23:52:02 +09:00
Kasper Timm Hansen
1d542e47d1 Set always_permitted_parameters.
The tests were written with the common false value seen in Rails apps,
show that intent in the code.

Should also fix the build on 5-0-stable.
2016-08-02 16:22:57 +02:00
Kasper Timm Hansen
b71732c84a Move the YAML hook closer to init_with.
Looked odd, so completely detached from the other necessary part of
the implementation.
2016-08-02 16:20:08 +02:00
Kasper Timm Hansen
0e0cff0f27 Replace implicit formats with a case statement.
The coder that Psych passes in has a `tag` method we can use to detect
which serialization format we're reviving for. Use it and make it clearer
alongside the `load_tags` fiddling.
2016-08-02 15:53:45 +02:00
Kasper Timm Hansen
6eb978234c Let Psych 2.0.9+ deserialize 2.0.8 serialized parameters.
If we were to serialize an `ActionController::Parameters` on Psych 2.0.8, we'd get:

```yaml
--- !ruby/hash:ActionController::Parameters
key: :value
```

Because 2.0.8 didn't store instance variables, while 2.0.9 did:
8f84ad0fc7

That, coupled with 2.0.8 calling `new` instead of `allocate` meant parameters was
deserialized just fine:
af308f8307

However, if users have 2.0.8 serialized parameters, then upgrade to Psych 2.0.9+ and
Rails 5, it would start to blow up because `initialize` will never be called, and thus
`@parameters` will never be assigned. Hello, `NoMethodErrors` on `NilClass`! :)

To fix this we register another variant of the previous serialization format and take
it into account in `init_with`.

I've tested this in our app and previously raising code now deserializes like a champ.
I'm unsure how to test this in our suite because we use Psych 2.0.8 and don't know how
to make us use 2.0.9+ for just one test.
2016-08-02 14:54:25 +02:00
Kasper Timm Hansen
6b441559b1 Merge pull request #26017 from kaspth/parameters-yaml-format-backwardscompatibility
Make Parameters support legacy YAML encodings.
2016-08-02 12:50:26 +02:00
Ryuta Kamizono
a76ebe5019 Remove unnecessary set_inverse_instance in finder methods
Because `scope` (`target_scope`) is a `AssociationRelation`.
`AssociationRelation` handles `set_inverse_instance`.

https://github.com/rails/rails/blob/v5.0.0/activerecord/lib/active_record/association_relation.rb#L31-L33
2016-08-02 16:53:06 +09:00
David Heinemeier Hansson
3118911335 Not needed 2016-08-01 20:29:29 -07:00
David Heinemeier Hansson
9d8d4ee05e Allow for custom handling of exceptions that persist beyond the retry attempts 2016-08-01 16:51:11 -07:00
David Heinemeier Hansson
0be5d5d4c4 Add exponentially_longer and custom wait algorithms 2016-08-01 16:44:29 -07:00
David Heinemeier Hansson
08a92d47b0 Use descriptive exception names 2016-08-01 16:09:16 -07:00
David Heinemeier Hansson
a4fc7dc957 Executions counting is not a serialization concern
Let’s do it when we actually execute instead. Then the tests dealing
with comparable serializations won’t fail either!
2016-08-01 16:02:50 -07:00
Kasper Timm Hansen
31448f2b7f Make Parameters support legacy YAML encodings.
By changing ActionController::Parameter's superclass, Rails 5 also changed
the YAML serialization format.

Since YAML doesn't know how to handle parameters it would fallback to its
routine for the superclass, which in Rails 4.2 was Hash while just Object
in Rails 5. As evident in the tags YAML would spit out:

4.2: !ruby/hash-with-ivars:ActionController::Parameters
5.0: !ruby/object:ActionController::Parameters

Thus when loading parameters YAML from 4.2 in Rails 5, it would parse a
hash dump as it would an Object class.

To fix this we have to provide our own `init_with` to be aware of the past
format as well as the new one. Then we add a `load_tags` mapping, such that
when the YAML parser sees `!ruby/hash-with-ivars:ActionController::Parameters`,
it knows to call our `init_with` function and not try to instantiate it as
a normal hash subclass.
2016-08-01 21:52:18 +02:00
Sean Griffin
c205e3fca3 Merge pull request #25986 from kamipo/remove_unnecessary_methods_for_null_relation
Remove unnecessary methods for `NullRelation`
2016-08-01 13:37:22 -04:00
Santiago Pastorino
7732cf5b0f Merge pull request #26004 from y-yagi/remove_unnecessary_require_and_extend
remove unnecessary require and extend
2016-08-01 11:16:59 -03:00
Kasper Timm Hansen
de55a09840 Merge pull request #26001 from yui-knk/warning
Suppress warnings
2016-08-01 14:19:36 +02:00
Kasper Timm Hansen
465e34bbad Merge pull request #26013 from y-yagi/remove_old_links_about_debugger
remove old links from debugging guide [ci skip]
2016-08-01 11:12:51 +02:00
yuuji.yaginuma
987df0fea0 remove old links from debugging guide [ci skip] 2016-08-01 16:38:55 +09:00
yuuji.yaginuma
e3fc35b5d6 remove unnecessary require and extend
`rack/test` is require at the top of file.
https://github.com/rails/rails/blob/master/railties/test/railties/engine_test.rb#L3

In addtion, `Rack::Test::Methods` is include in class, extend is unnecessary.
https://github.com/rails/rails/blob/master/railties/test/railties/engine_test.rb#L9
2016-07-31 16:25:39 +09:00
yui-knk
29fa06a234 Suppress warnings
This commit suppressed
`warning: instance variable @session_store not initialized`.
e5a6f7ee9e951dbe0e4e9ea2c0743b4dfb135c57 introduced these
warnings.
2016-07-31 14:57:47 +09:00
David Heinemeier Hansson
779148d390 Reraise instead of swallow exceptions that occur beyond the retry attempts 2016-07-29 15:15:31 -07:00
David Heinemeier Hansson
f931290e58 Proper logging when we bail on retrying after X attempts 2016-07-29 15:07:50 -07:00
David Heinemeier Hansson
815b730b1b Merge pull request #25992 from rails/revert-25914-jm/not_in
Revert "Adds `not_in?` onto Object"
2016-07-29 14:45:38 -07:00