Commit Graph

15384 Commits

Author SHA1 Message Date
Yves Senn
7e6996a1b3 Merge pull request #25958 from kamipo/should_be_target_loaded
Add an assertion to the tests that should be loaded the target.
2016-07-27 09:55:43 +02:00
Yves Senn
d0f8061cae Merge pull request #25408 from kamipo/should_not_reuse_quoted_true
Quoting booleans should return a frozen string
2016-07-27 08:20:22 +02:00
Sean Griffin
d980abdb23 Merge pull request #25523 from kamipo/extract_quoted_binds_type_casted_binds
Extract `type_casted_binds` method
2016-07-26 17:38:17 -04:00
Ryuta Kamizono
a3a6d74c77 Quoting booleans should return a frozen string
If reuse `QUOTED_TRUE` and `QUOTED_FALSE` without frozen, causing the
following issue.

```
Loading development environment (Rails 5.1.0.alpha)
irb(main):001:0> ActiveRecord::Base.connection.quote(true) << ' foo'
=> "1 foo"
irb(main):002:0> ActiveRecord::Base.connection.quote(true) << ' foo'
=> "1 foo foo"
irb(main):003:0> type = ActiveRecord::ConnectionAdapters::AbstractMysqlAdapter::MysqlString.new
=> #<ActiveRecord::ConnectionAdapters::AbstractMysqlAdapter::MysqlString:0x007fd40c15e018 @precision=nil, @scale=nil, @limit=nil>
irb(main):004:0> type.serialize(true) << ' bar'
=> "1 foo foo bar"
irb(main):005:0> type.cast(true) << ' bar'
=> "1 foo foo bar bar"
```
2016-07-27 00:44:16 +09:00
Ryuta Kamizono
92c8f01580 Add an assertion to the tests that should be loaded the target.
These test cases tests exactly mutating loaded target.
2016-07-27 00:32:50 +09:00
Santiago Pastorino
c4b33a7796 Merge pull request #25929 from kamipo/load_target_is_public_method
`load_target` is a public method
2016-07-26 11:43:47 -03:00
Ryuta Kamizono
944c7b9818 Make force_signal37_to_load_all_clients_of_firm to private
This is not a test case.
2016-07-26 13:14:59 +09:00
Ryuta Kamizono
d31c2e2cf8 Extract type_casted_binds method
Because `type_cast` against `binds` always requires
`attr.value_for_database` and this pattern appears frequently.
2016-07-26 09:49:53 +09:00
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
Ryuta Kamizono
beb6b7add7 load_target is a public method
`send` is unnecessary.
2016-07-23 17:14:41 +09: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