Commit Graph

15375 Commits

Author SHA1 Message Date
Sean Griffin
aa7a6047c2 Whoops, forgot the changelog entry for the previous commit 2016-07-25 11:13:01 -04:00
Sean Griffin
f0ddf87e4b Correct the behavior of virtual attributes on models loaded from the db
Previously we had primarily tested the behavior of these attributes by
calling `.new`, allowing this to slip through the cracks. There were a
few ways in which they were behaving incorrectly.

The biggest issue was that attempting to read the attribute would
through a `MissingAttribute` error. We've corrected this by returning
the default value when the attribute isn't backed by a database column.
This is super special cased, but I don't see a way to avoid this
conditional. I had considered handling this higher up in
`define_default_attribute`, but we don't have the relevant information
there as users can provide new defaults for database columns as well.

Once I corrected this, I had noticed that the attributes were always
being marked as changed. This is because the behavior of
`define_default_attribute` was treating them as assigned from
`Attribute::Null`.

Finally, with our new implementation, `LazyAttributeHash` could no
longer be marshalled, as it holds onto a proc. This has been corrected
as well. I've not handled YAML in that class, as we do additional work
higher up to avoid YAML dumping it at all.

Fixes #25787
Close #25841
2016-07-25 11:12:06 -04:00
Xavier Noria
95b2a6abc7 adds missing requires 2016-07-24 21:29:29 +02:00
Xavier Noria
7714e83da0 removes spurious line 2016-07-24 00:50:24 +02:00
Xavier Noria
f9f39d5c42 give some love to this test file
It all started noticing some foo.method({ ... }) method calls
in passing. This is a whole pass modernizing this file.

While some string literals are edited where I touched code,
this pass does not uniformizes quotes. A ton are left untouched
on purposes. We have no defined style.
2016-07-23 23:15:26 +02:00
Xavier Noria
99cf755800 systematic revision of =~ usage in AR
Where appropriatei, prefer the more concise Regexp#match?,
String#include?, String#start_with?, or String#end_with?
2016-07-23 20:22:20 +02:00
Étienne Barrié
34672e669d Remove tab chars before commands to be run 2016-07-20 17:01:28 -04:00
Rafael França
f88495d519 Merge pull request #25885 from kamipo/fix_explain_logging_with_binds
Fix explain logging with binds
2016-07-20 12:58:42 -03:00
Rafael França
b1d48d5424 Merge pull request #25786 from kamipo/add_exists_and_update_all_to_collection_proxy
Add `exists?` and `update_all` to `CollectionProxy` for respects an association scope
2016-07-20 12:56:57 -03:00
Rafael França
5757b9dbe7 Merge pull request #25897 from yahonda/remove_set_date_columns_and_modify_attributes_test
Remove Oracle specific tests based on deprecated behaviors
2016-07-20 12:48:18 -03:00
Yasuo Honda
cc4abed844 Oracle TIMESTAMP sql type is associated with Rails DateTime type now
- Refer https://github.com/rsim/oracle-enhanced/pull/845
Remove `set_date_columns` which has been deprecated in Oracle enhanced adapter
 - Refer https://github.com/rsim/oracle-enhanced/pull/869
2016-07-20 13:10:55 +00:00
Ryuta Kamizono
7d1dc9841c Fix explain logging with binds
`binds` is an array of a query attribute since Active Record 5.0.
2016-07-20 15:26:39 +09:00
Ryuta Kamizono
1a10d38d46 Add exists? and update_all to CollectionProxy for respects an association scope
Fixes #25732.
2016-07-20 14:58:33 +09:00
Rafael França
f980dee24e Merge pull request #25578 from kamipo/move_warning_about_composite_primary_key_to_attribute_methods_primary_key
Move the warning about composite primary key to `AttributeMethods::PrimaryKey`
2016-07-20 02:23:00 -03:00
Rafael França
c9061254de Merge pull request #25889 from kamipo/do_not_dup_binds_in_to_sql
Do not `binds.dup` in `connection#to_sql`
2016-07-20 02:16:38 -03:00
Rafael França
0d42c906c5 Merge pull request #25888 from kamipo/use_conn_to_sql_for_construct_sql
Use `connection#to_sql` for construct an SQL
2016-07-20 02:15:03 -03:00
Rafael Mendonça França
9c6f348d79
Merge pull request #25849 from suginoy/fix_merge_in_scope
Fix the calling `merge` method at first in a scope
2016-07-20 02:11:17 -03:00
Rafael França
b25e18007b Merge pull request #25828 from bogdanvlviv/ref_default_sequence_name
Refactored method `ActiveRecord::ConnectionAdapters::PostgreSQL::SchemaStatements#default_sequence_name`. Refactored test `HasManyAssociationsTest#test_do_not_call_callbacks_for_delete_all`.
2016-07-20 02:03:53 -03:00
Rafael França
e2b71e9f8e Merge pull request #25834 from alpaca-tc/fixes_multiparameter_attributes_on_time_with_time_zone_aware_attributes
Fix bug in method AR TimeZoneConverter#set_time_zone_without_conversion
2016-07-20 00:53:30 -03:00
Rafael França
b72674098b Merge pull request #25869 from kamipo/specificiation_id_was_renamed_to_spec_name
`specificiation_id` was renamed to `spec_name`
2016-07-20 00:51:38 -03:00
Rafael França
82b04fc609 Merge pull request #25868 from kamipo/fix_payload_class_name_to_spec_name
Fix `payload[:class_name]` to `payload[:spec_name]`
2016-07-20 00:51:10 -03:00
alpaca-tc
780535017a Fixes multiparameter attributes conversion with time_zone_aware_attributes and invalid params 2016-07-19 22:35:45 +09:00
Ryuta Kamizono
4ef4d46d0c Do not binds.dup in connection#to_sql
Because `connection#to_sql` does not mutate `binds`.
2016-07-19 20:31:33 +09:00
Ryuta Kamizono
3befc7a9ef Use connection#to_sql for construct an SQL 2016-07-19 20:06:58 +09:00
Ryuta Kamizono
f814585bb2 Pass type_casted_binds to log subscriber for logging bind values properly
Address to 5a302bf553 (commitcomment-18288388).
2016-07-19 14:11:58 +09:00
suginoy
cf2574b1c9 Fix the calling merge method at first in a scope
Changing the order of method chaining `merge` and other query
method such as `joins` should produce the same result.

```ruby
class Topic < ApplicationRecord
  scope :safe_chaininig,   -> { joins(:comments).merge(Comment.newest) }
  scope :unsafe_chaininig, -> { merge(Comment.newest).joins(:comments) } #=> NoMethodError
end
```
2016-07-19 10:19:59 +09:00
Ryuta Kamizono
51598abaf1 Logging type casted binds
Fixes #22398.
2016-07-19 03:06:40 +09:00
Alex Kitchens
31651bff4c [ci skip] Fix grammar in AR::Associations 2016-07-18 10:04:22 -05:00
Xavier Noria
dccc23a503 deprecates the error_on_ignored_order_or_limit instance reader
Albeit the previous existence of this method is not seen in
the patch itself, the declaration

    mattr_accessor :error_on_ignored_order_or_limit, instance_writer: false

was present before. It was removed recently in 210012f.
2016-07-18 10:45:54 +02:00
Xavier Noria
b097a48c5f adds coverage for the deprecation of error_on_ignored_order 2016-07-18 10:37:15 +02:00
Xavier Noria
8f84d092c4 Merge pull request #25866 from prathamesh-sonpatki/rm-deprecated-mattr-accessor
Followup of changes done to `error_on_ignored_order`
2016-07-18 09:48:37 +02:00
Prathamesh Sonpatki
210012f615
Remove mattr_accessor for deprecated config error_on_ignored_order_or_limit.
- It adds lot of warnings while running the tests. After 451437c6f5 it is not needed.
- Added reader method with deprecation warning for backward compatibility.
2016-07-18 09:29:55 +05:30
bogdanvlviv
872350a54f Refactored test HasManyAssociationsTest#test_do_not_call_callbacks_for_delete_all 2016-07-17 21:58:13 +03:00
bogdanvlviv
6bb46ae2e8 Refactored method ActiveRecord::ConnectionAdapters::PostgreSQL::SchemaStatements#default_sequence_name 2016-07-17 21:52:36 +03:00
Ryuta Kamizono
dad95ba68c specificiation_id was renamed to spec_name 2016-07-18 03:48:38 +09:00
Ryuta Kamizono
38cd2aae43 Fix payload[:class_name] to payload[:spec_name]
Follow up to #20818.

`retrieve_connection` is passed `spec_name` instead of `klass` since #24844.
2016-07-17 22:04:06 +09:00
Ryuta Kamizono
4985947206 No need public_send 2016-07-17 21:14:01 +09:00
Rafael Mendonça França
9d0491937e
Check if the logger exists before trying to use it 2016-07-17 05:13:56 -03:00
Rafael França
9fcfb86c42 Merge pull request #20818 from jeremywadsack/use_transactional_fixtures_all_databases
Use notification to ensure that lazy-loaded model classes have transactions
2016-07-17 04:19:23 -03:00
Prathamesh Sonpatki
91251fdcbd
CHANGELOG for https://github.com/rails/rails/pull/25257 [ci skip]
- Also minor weekly CHANGELOG cleanup.
2016-07-17 11:27:06 +05:30
Rafael França
c1e38d68a2 Merge pull request #25815 from greysteil/add-newline-between-structure-versions
Add newline between each migration in `structure.sql`
2016-07-16 20:01:27 -03:00
Prathamesh Sonpatki
4c9f8ff10f
Fix wrong test name
- Followup of https://github.com/rails/rails/pull/23179
2016-07-16 15:16:50 +05:30
Yamaguchi.Tomoki
68d35960f3 [ci skip] fix a typo 2016-07-15 19:43:58 +09:00
Grey Baker
60ff98184e Add newline between each migration in structure.sql
Keeps schema migration inserts as a single commit, so we still get all of the
benefits of 42dd2336b3,
but allows for easier git diff-ing. Fixes #25504.
2016-07-14 16:49:03 +01:00
Xavier Noria
5494af0c0f small reword [ci skip] 2016-07-14 09:42:10 +02:00
Xavier Noria
2bf36970a0 removes a unnecessary limit call
We are setting a limit unconditionally just below,
which overrides any existing one anyway.
2016-07-13 20:55:37 +02:00
Xavier Noria
451437c6f5 adds support for limits in batch processing 2016-07-13 18:23:13 +02:00
Jeremy Wadsack
31a8588a01 Create connection.active_record notification and use that to ensure that lazy-
loaded model classes have their connections wrapped in transactions.

See #17776

In Rails 4 config.eager_load was changed to false in the test environment. This
means that model classes that connect to alternate databases with
establish_connection are not loaded at start up. If use_transactional_fixtures
is enabled, transactions are wrapped around the connections that have been
established only at the start of the test suite. So model classes loaded later
don't have transactions causing data created in the alternate database not to
be removed.

This change resolves that by creating a new connection.active_record
notification that gets fired whenever a connection is established. I then added
a subscriber after we set up transactions in the test environment to listen for
additional connections and wrap those in transactions as well.
2016-07-12 23:35:29 -07:00
Rafael França
3df3d80ade Merge pull request #25794 from mechanicles/rails-to-Rails
rails -> Rails [ci skip]
2016-07-12 03:58:17 -03:00
Santosh Wadghule
d8575289a2 rails -> Rails [ci skip] 2016-07-12 12:21:36 +05:30