Commit Graph

8252 Commits

Author SHA1 Message Date
Rafael Mendonça França d168c1f7a7 Merge pull request #6606 from amatsuda/ar_relation_model_method
AR::Relation#model would be a better API than AR::Relation#klass
2012-08-21 14:43:19 -07:00
José Valim 6bef1469d2 Merge pull request #7225 from rails/eager_load
Improve eager load on Rails
2012-08-21 12:58:25 -07:00
Rafael Mendonça França f89d5e4603 Use a model without counter cache to test read-only attributes 2012-08-21 15:47:02 -03:00
José Valim 2801786e1a Get rid of config.preload_frameworks in favor of config.eager_load_namespaces
The new option allows any Ruby namespace to be registered and set
up for eager load. We are effectively exposing the structure existing
in Rails since v3.0 for all developers in order to make their applications
thread-safe and CoW friendly.
2012-08-21 14:47:19 -03:00
Dave Desrochers ff0d9b93b9 reset_counters() was crashing when there were multiple belongs_to associations with the same foreign key.
This closes #5200.
2012-08-21 14:10:11 -03:00
kennyj 5e47ba0a85 Refactor AR::Result or inherits. Because we have redundant codes about 2012-08-22 01:23:40 +09:00
Yasuo Honda babc24c1b0 Rename to test_mysql_strict_mode_disabled_dont_override_global_sql_mode
Reason since MySQL 5.6.6-m9 the `sql_mode` default value is
`NO_ENGINE_SUBSTITUTION`.
This default parameter change is out of control from Rails.

This test verifies Rails not overriding the default `@@GLOBAL.sql_mode` value
by checking if `@@GLOBAL.sql_mode` is the same as `@@SESSION.sql_mode`.
2012-08-22 00:56:23 +09:00
kennyj 57bef99073 Use instance_accessor: false instead of instance_writer. 2012-08-21 23:40:28 +09:00
Rafael Mendonça França 55d943c567 Add CHANGELOG entry for #6986 2012-08-21 10:18:10 -03:00
kennyj e9d2ad395e Round usec when writing timestamp attribute. 2012-08-21 10:12:13 -03:00
Carlos Antonio da Silva 15e2b80a27 Minor refactoring in Active Record model schema methods
* Use each_key instead of generating intermediate keys array.
* Use each_with_object instead of inject to build hash.
* Use ternary to return instead of if + assignment.
2012-08-21 00:50:43 -03:00
Aaron Patterson e7ffa77932 removing dead code 2012-08-20 16:12:59 -07:00
Aaron Patterson f734ec4807 define singleton methods rather than adding and removing methods 2012-08-20 16:12:09 -07:00
Aaron Patterson 79d21dddd6 remove dead code 2012-08-20 15:32:50 -07:00
Aaron Patterson 503bee0111 initialize instance variables for transactions to remove conditionals 2012-08-20 15:08:49 -07:00
Aaron Patterson 075b91454b This method is useless without a block, so remove test 2012-08-20 15:08:49 -07:00
Aaron Patterson a4697b0cc3 remove unused variable 2012-08-20 15:08:49 -07:00
Aaron Patterson 73eeb51ea5 initialize instance variables to avoid conditionals 2012-08-20 15:08:48 -07:00
Aaron Patterson d0d4ef6e8b fix whitespace errors 2012-08-20 15:08:48 -07:00
Carlos Antonio da Silva 7a8aee08b6 Remove private verify readonly attr method
This method was added to be shared between update_attribute and
update_column in 50725cec39, but since
update_attribute was removed, and update_column has changed to delegate
to update_columns, the method is not used anywhere anymore.

Also remove "key.to_s" conversion when raising readonly error, since
the key is being interpolated.
2012-08-19 17:24:12 -03:00
Ernie Miller bf80522be4 Fix "last equality wins" logic in relation merge
This is a real fix (as compared to the band-aid in b127d86c), which uses
the recently-added equality methods for ARel nodes. It has the side
benefit of simplifying the merge code a bit.
2012-08-19 08:06:31 -04:00
Carlos Antonio da Silva f9fc26e800 Merge pull request #7377 from brainopia/use_inversed_parent_for_first_and_last_child
Use inversed parent for first and last child of has_many association
2012-08-18 18:11:11 -07:00
brainopia c9c5566ace Use inversed parent for first and last child of has_many association 2012-08-18 18:11:28 +04:00
Carlos Antonio da Silva ec01242a21 Get rid of some arguments by using the accessors
Cleans up a lot of noise from arguments being passed from one method to
another.
2012-08-18 09:55:38 -03:00
Carlos Antonio da Silva ec31680106 Move multiparameter attribute logic to a class
This should make it easier to refactor and improve this code, and remove
complexity with params going around here and there.
2012-08-18 09:55:38 -03:00
Carlos Antonio da Silva 95f6b1245d Some more cleanup to use Hash#values_at, and some method docs 2012-08-18 09:55:37 -03:00
Carlos Antonio da Silva 022d7b3846 Use cached column information to instantiate time object 2012-08-18 09:55:37 -03:00
Carlos Antonio da Silva ef52d34d07 Refactor blank date parameter validation 2012-08-18 09:55:37 -03:00
Carlos Antonio da Silva 5021c13cea Refactor missing parameter validation based on position 2012-08-18 09:55:37 -03:00
Carlos Antonio da Silva a0f9dc7657 Reuse already fetched column to check for :time
Avoid doing a new column lookup for the attribute, since we already have
the column to check for the klass.
2012-08-18 09:55:37 -03:00
Carlos Antonio da Silva 2a700a03ce Refactor some code in multiparameter assignment
Move some methods to the top to better organize them, since they're used
right at the beginning of the multiparameter assignment method chain.
2012-08-18 09:55:23 -03:00
Carlos Antonio da Silva 5bd96de625 Extract nested parameter assignment to a separate method 2012-08-18 09:51:20 -03:00
Aaron Patterson 366eb7216e Merge pull request #7380 from ernie/fix-nomethoderror-on-non-attribute-equalities
Fix merge error when Equality LHS is non-attribute
2012-08-17 14:17:36 -07:00
Jon Leighton 1f633c78ea Pull more serialize code into a lazy included module 2012-08-17 18:40:39 +01:00
Jon Leighton 5ecb02f6dd don't call method unless we need to 2012-08-17 18:22:29 +01:00
Jon Leighton 49cb4ed845 align them assignments 2012-08-17 18:22:29 +01:00
Jon Leighton 8cbad0293b Optimize for the happy path
Checking respond_to? incurs overhead, and most of the time when
assigning attributes it will return true. So just handle the
NoMethodError instead.
2012-08-17 18:22:29 +01:00
Jon Leighton 2ff47c4897 Avoid #any?
any? will check that each item in the array is truthy, as opposed to
!empty? which will simply check that the array has length. For an empty
array, !empty? still seems to be faster than any?
2012-08-17 18:22:29 +01:00
Jon Leighton 8fcd9b6e86 The default value can be set once in #column_defaults
Rather than doing it every time an instance is instantiated.
2012-08-17 18:22:29 +01:00
Jon Leighton f396c01db2 Optimize instantiation for models which don't use serialize
Those z's were hard to type.
2012-08-17 18:22:29 +01:00
Jon Leighton 1b2c907727 Avoid deep_dup when intantiating.
deep_dup is slow. we only need to dup the values, so just do that
directly.
2012-08-17 18:22:29 +01:00
Aaron Patterson 3e8ab910ce column default extraction should handle newlines.
Fixes #7374
2012-08-17 10:21:35 -07:00
Rafael Mendonça França 8f4ee48687 Merge pull request #7352 from aripollak/microsecond-timestamp
Fix occasional microsecond conversion inaccuracy
2012-08-17 10:19:33 -07:00
Ernie Miller b127d86c18 Fix merge error when Equality LHS is non-attribute
This is at best a band-aid for a more proper fix, since it won't truly
handle the removal of the previous equality condition of these other
nodes. I'm planning to put in some work on ARel toward supporting that
goal.

Related: rails/arel#130, ernie/squeel#153, ernie/squeel#156
2012-08-17 11:31:23 -04:00
Jon Leighton c6bbc10fae Increase benchmark time to 20 seconds.
I think that 5 seconds was a bit low for our purposes.

Also enable it to be configured via env vars.

We also need to scale the number of records up/down depending on how
long we're running the benchmark for.
2012-08-17 15:09:01 +01:00
Jon Leighton 1411fc1986 Use benchmark/ips to measure AR performance
This means we can more easily compare numbers, and we don't have to
specify a single N for all reports, which previously meant that some
tests were running many more/fewer iterations than necessary.
2012-08-17 11:41:50 +01:00
Jon Leighton 17bb324f38 Renaming active_record_deprecated_finders to activerecord-deprecated_finders
For consistency with the other AR extension plugins we are creating.
2012-08-17 10:21:52 +01:00
Ari Pollak 53ca22f2e1 Fix occasional microsecond conversion inaccuracy
ActiveRecord::ConnectionAdapters::Column#microseconds did an unnecessary
conversion to from Rational to float when calculating the integer number
of microseconds. Some terminating decimal numbers in base10 are
repeating decimal numbers in base2 (the format of float), and
occasionally this causes a rounding error.
Patch & explanation originally from Logan Bowers.
2012-08-15 13:21:57 -04:00
Carlos Antonio da Silva bf5f6562c0 Remove duplicated changelog entry [ci skip] 2012-08-15 12:48:38 -03:00
Carlos Antonio da Silva dd64f0a010 Move changelog entry to the top [ci skip] 2012-08-15 12:47:20 -03:00