Commit Graph

10703 Commits

Author SHA1 Message Date
Aaron Patterson
a11882ce40 remove delegate methods that are not used 2013-10-13 17:59:53 -07:00
Aaron Patterson
e6dfff2af5 push the node->AR cache up one level 2013-10-13 17:54:50 -07:00
Rafael Mendonça França
2384148cbe Merge pull request #12486 from cjolly/newline-eof-structure-sql
newline at end of structure.sql file
2013-10-13 17:48:42 -07:00
Chad Jolly
3430dafbc8 newline at end of structure.sql file 2013-10-13 18:38:48 -06:00
Aaron Patterson
66a6a6b45a eliminate single use method 2013-10-13 17:03:48 -07:00
Aaron Patterson
158197b91d eliminate duplicate code from to_sql
I don't really like passing the block, but this seems easiest for now
2013-10-13 16:56:30 -07:00
Aaron Patterson
d00f9692b8 calling construct_relation_for_association_find is no longer necessary 2013-10-13 16:53:28 -07:00
Aaron Patterson
7fe6d24506 push up select exclusion 2013-10-13 16:51:10 -07:00
Aaron Patterson
5e4031ef3d JoinDependency will take care of making things unique 2013-10-13 16:42:49 -07:00
Dmitry Polushkin
04e3b41e2f Add a note to the changelog for #9499 2013-10-13 21:54:07 +01:00
Dmitry Polushkin
3a6cf83b9a add inversed accessor to association class 2013-10-13 21:51:40 +01:00
Dmitry Polushkin
05b178085a inversed instance should not be reloaded after stale state was changed
check at association reader that record is inverted and should not be reloaded because of stale was changed at target record
2013-10-13 21:51:40 +01:00
Rafael Mendonça França
dcff027a52 Merge pull request #12518 from vipulnsward/remove_count_options
`Relation#count` doesn't use options anymore.
2013-10-13 12:56:47 -07:00
Rafael Mendonça França
3a2093984f Add nodoc to method 2013-10-13 16:54:04 -03:00
Rafael Mendonça França
95cb54a29e Merge pull request #12508 from jetthoughts/12415_generate_subqueries_for_relation_from_binding_params
Generate subquery for Relation passed as array condition for where

Conflicts:
	activerecord/CHANGELOG.md
2013-10-13 16:45:30 -03:00
Paul Nikitochkin
bc293ff690 Generate subquery for Relation passed as array condition for where
Instead of executing 2 queries for fetching records filtered by array condition with Relation,
added generation of subquery to current query.

This behaviour will be consistent when passes Relation as hash condition to where

Closes: #12415
2013-10-13 22:13:50 +03:00
Rafael Mendonça França
0b2884a8ae Merge pull request #12456 from razielgn/ar-test-fixes
Fixed MRI dependent stuff in AR tests
2013-10-13 12:09:12 -07:00
Rafael Mendonça França
c56dc753b4 Merge pull request #12511 from jetthoughts/informative_raise_message_for_incorrect_association
Make missed association exception message more informative
2013-10-13 12:01:27 -07:00
Paul Nikitochkin
625cd69a8b Make missed association exception message more informative
Add target class name, which should have missed association on preload,
into exception message to simplify detecting problem part.
2013-10-13 21:56:44 +03:00
Vipul A M
42d3d3c217 Stop accepting options for Relation#average, Relation#minimum, Relation#maximum, Relation#calculate, perform_calculation, NullRelation#calculate as they isn't used anymore. 2013-10-14 00:04:10 +05:30
Vipul A M
4ce643dbb5 Relation#count doesn't use options anymore. 2013-10-13 21:27:21 +05:30
Vipul A M
73ec210e4c Drop unused iterator var 2013-10-13 20:54:09 +05:30
Rafael Mendonça França
0df9149fd6 Merge pull request #11791 from versioncontrol/includes_with_persistent_select
Includes with persistent select, fixes #11773
2013-10-12 21:17:26 -07:00
Aaron Patterson
485eec407a remove dead code 2013-10-11 19:03:03 -07:00
Aaron Patterson
d7ddaa530f remove useless code
turns out that the activerecord object will always have the same id as
the row from which it was constructed
2013-10-11 18:58:29 -07:00
Aaron Patterson
b69b9de4bd the parent hash keeps the records unique already 2013-10-11 18:48:43 -07:00
Aaron Patterson
cfbb6eeb4c keep track of AR objects we've made as we walk the tree
Remove duplicate removal code because we avoid adding duplicates as we
walk the tree the first time
2013-10-11 18:38:19 -07:00
Aaron Patterson
d9a7f86666 push up the loaded target checking 2013-10-11 18:02:20 -07:00
Aaron Patterson
8c155a6562 we always have a model now 2013-10-11 17:38:11 -07:00
Aaron Patterson
50e6b69018 extract conditional to the caller 2013-10-11 17:27:34 -07:00
Aaron Patterson
68c08111fb we always have a reflection and it is on the node 2013-10-11 16:46:28 -07:00
Aaron Patterson
5bef5cfd44 fix variable name. we're constructing a model, not an association 2013-10-11 16:39:14 -07:00
Aaron Patterson
5d663a7122 reflections know if they are collections, so ask
We don't need to poke at the macro to figure out if we should look for a
cached record or not
2013-10-11 15:53:25 -07:00
Aaron Patterson
8219691ef2 belongs_to can be treated the same way as has_one 2013-10-11 15:30:25 -07:00
Aaron Patterson
3a8892aae2 cache the primary key / typcast lookup on the stack 2013-10-11 11:44:04 -07:00
Aaron Patterson
32fcdb3b9e remove dead code / make duplicate code more obvious 2013-10-11 11:29:52 -07:00
Aaron Patterson
085bb239f8 pull parent and alias tacker from the nodes.
For now, we'll set the tables on the nodes manually.
2013-10-11 11:07:15 -07:00
Aaron Patterson
2550acc779 decouple the join_constraints method from the parent pointer 2013-10-11 11:07:15 -07:00
Aaron Patterson
cc362fe17b no reason to do this column addition and subtraction business 2013-10-11 11:06:58 -07:00
Aaron Patterson
34c3c64ecc refactor a little so we can remove some methods 2013-10-10 16:00:07 -07:00
Aaron Patterson
6537e5044c the parent node is on the stack, so use it
we don't need to walk back up the node's parents when we have the parent
on the stack
2013-10-10 14:59:36 -07:00
Aaron Patterson
c4d0e69ad2 pass the parent node to the construct method 2013-10-10 14:57:45 -07:00
Aaron Patterson
0c6c026dec nodes do not need to be sorted 2013-10-10 14:53:50 -07:00
Aaron Patterson
ff5f328bdf delete unused code
Now that we merge trees from the top down, we don't need to search
through the whole tree for particular nodes, just walk it and merge.
2013-10-10 14:50:12 -07:00
Aaron Patterson
223082e588 merge JoinDependency as outer joins
Merge JoinDependency objects as outer joins
2013-10-10 14:46:15 -07:00
Aaron Patterson
d20ccb7e63 stuff the join dependency object in the "anything goes" hash. 2013-10-10 14:12:04 -07:00
Aaron Patterson
e4ec9ce78d stop splatting things back and forth 2013-10-10 10:11:18 -07:00
Aaron Patterson
82d81bbfcb simplify each method.
Stop writing terrible code Aaron.  This is Ruby, not Scheme
2013-10-10 10:09:15 -07:00
Aaron Patterson
0061c5e1ef stop creating a bunch of relation objects when we can slap all the joins on at once 2013-10-09 17:47:09 -07:00
Rafael Mendonça França
ebe9cd8e61 Merge branch 'builder-instances' 2013-10-09 20:59:45 -03:00
Rafael Mendonça França
2a10a1efed Method visibility will not make difference here 2013-10-09 20:59:15 -03:00
Rafael Mendonça França
d0163e99d9 Remove builder instances
All the job can be done at class level so we can avoid some object
allocation
2013-10-09 20:56:05 -03:00
Rafael Mendonça França
c1cd342456 Extract the scope building to a class method 2013-10-09 20:48:28 -03:00
Rafael Mendonça França
1a30b1ed40 Remove unneeded reader 2013-10-09 20:27:52 -03:00
Rafael Mendonça França
19c3677882 Move wrap_scope to class level 2013-10-09 20:21:38 -03:00
Rafael Mendonça França
a929d78d7b Move macro to class level 2013-10-09 20:17:59 -03:00
Rafael Mendonça França
3c27b6ee7e Make validate_options a class method 2013-10-09 20:15:00 -03:00
Rafael Mendonça França
b83f3645c0 Make valid_options a class method 2013-10-09 20:10:21 -03:00
Aaron Patterson
729d3c0599 no need to to_sym 2013-10-09 16:09:59 -07:00
Aaron Patterson
b64d64a648 Merge branch 'tree'
* tree: (22 commits)
  remove dead code
  add some convenient methods for avoiding array allocations
  hide join_constraints inside the JoinDependency object
  speed up match?
  expose the root node and call it
  just skip the join if it's already there
  speed up finding existing nodes
  make node search more efficient
  remove == so we can see where walking up parents occurs
  push parent up to the superclass
  convert JoinBase to a tree and remove the Node class
  names are guaranteed to be symbols
  eliminate function that is only used in one place
  we will always detect the same node, so just pass the node in
  we do not need to to_s the name all the time
  parent is guaranteed to be the same
  reduce number of comparisons and array allocations
  rename the variable to make more sense with a tree
  walk the tree rather than generating a hash and walking it
  do not convert the tree to a list just for the first node
  ...
2013-10-09 15:36:47 -07:00
Aaron Patterson
7473c62508 remove dead code 2013-10-09 15:26:22 -07:00
Aaron Patterson
0cfb1de458 add some convenient methods for avoiding array allocations 2013-10-09 15:25:19 -07:00
Aaron Patterson
752a06ea8d hide join_constraints inside the JoinDependency object 2013-10-09 15:21:34 -07:00
Aaron Patterson
92f95bbb33 speed up match? 2013-10-09 15:15:02 -07:00
Aaron Patterson
c6c4869612 expose the root node and call it 2013-10-09 15:14:55 -07:00
Aaron Patterson
a64f1ea08c just skip the join if it's already there
Remove the annoying `find_or_build` stuff.
2013-10-09 15:08:22 -07:00
Aaron Patterson
4852a05ce6 speed up finding existing nodes
The node must be a child of the parent passed in, so only search
children of the parent node
2013-10-09 14:51:38 -07:00
Aaron Patterson
e73fbdf804 make node search more efficient
Rather than search every node in the tree, comparing that node and all
of its parents every time, start at the root from both sides and work
our way down the tree
2013-10-09 14:38:14 -07:00
Aaron Patterson
9b15db51b7 remove == so we can see where walking up parents occurs 2013-10-09 13:51:13 -07:00
Aaron Patterson
217aedf1bf push parent up to the superclass
We always want a linked list back to the root node.
2013-10-09 11:23:45 -07:00
Aaron Patterson
40ad4397c1 convert JoinBase to a tree and remove the Node class 2013-10-09 11:14:58 -07:00
Arun Agrawal
91fe499275 Using flat_map instead of map and flatten
original commit 8998441967a8cfc6e4302c29664ab9d0acd77704

Reverted here ec8ef1e1055c4e1598da13f49d30261f07f4a9b4
2013-10-09 14:38:44 +02:00
Yves Senn
09b3b76f77 Merge pull request #12473 from claudiob/document-after-touch
Add documentation for after_touch [ci skip]
2013-10-09 02:09:52 -07:00
Rafael Mendonça França
0ee7331c35 Define the association extensions without need to have a builder
instance
2013-10-09 00:48:56 -03:00
Rafael Mendonça França
941516dabc ✂️ 2013-10-09 00:05:38 -03:00
Rafael Mendonça França
23517aa9a4 Push define_accessors to class level since we don't need anythig from
the instance
2013-10-08 23:59:44 -03:00
Rafael Mendonça França
d300256ca4 Use the reflection name instead of the accessor 2013-10-08 23:56:53 -03:00
Rafael Mendonça França
cae842e662 Move add_counter_cache_methods to class level 2013-10-08 23:53:00 -03:00
Rafael Mendonça França
bfa82499d6 Move define_constructors to class level 2013-10-08 23:52:46 -03:00
Rafael Mendonça França
6157f74295 Move define_writers to class level since we don't need anything from the
instance
2013-10-08 23:49:40 -03:00
Rafael Mendonça França
154c606824 Move define_readers to class method since it doesn't need nothing from
the instance
2013-10-08 23:44:42 -03:00
Rafael Mendonça França
2f6cc48b34 Fix the indentation 2013-10-08 23:26:15 -03:00
Aaron Patterson
78e7bffc4f names are guaranteed to be symbols 2013-10-08 19:14:12 -07:00
Aaron Patterson
5a0cca739a eliminate function that is only used in one place 2013-10-08 19:09:13 -07:00
Aaron Patterson
99ff735eea we will always detect the same node, so just pass the node in 2013-10-08 19:06:49 -07:00
Aaron Patterson
4292f6051d we do not need to to_s the name all the time 2013-10-08 19:03:51 -07:00
Aaron Patterson
d0e36c6b85 parent is guaranteed to be the same
since we are searching a tree, the current level should be consistent,
so we don't have to inspect the parent class / table
2013-10-08 18:03:42 -07:00
Aaron Patterson
155fd955ac reduce number of comparisons and array allocations
Just inspecting the children nodes will reduce the number of comparisons
we have to do (since it is limited to the child size)
2013-10-08 18:02:06 -07:00
claudiob
72a3dd85e4 Add documentation for after_touch [ci skip] 2013-10-08 17:57:53 -07:00
Aaron Patterson
86640e1ddc rename the variable to make more sense with a tree 2013-10-08 17:51:42 -07:00
Aaron Patterson
cf4e412d74 walk the tree rather than generating a hash and walking it 2013-10-08 17:44:03 -07:00
Aaron Patterson
236a6716a9 do not convert the tree to a list just for the first node 2013-10-08 17:24:06 -07:00
Aaron Patterson
868457488d generate the association hash from the top down
This prevents us from walking back up the parent tree once for each
leaf.
2013-10-08 17:23:53 -07:00
Aaron Patterson
6484ab2f8b store join parts in a tree 2013-10-08 17:00:22 -07:00
Aaron Patterson
8c0ba7b69b join parts in build are *always* new, so don't bother checking 2013-10-08 16:25:44 -07:00
Aaron Patterson
d6ce327502 stop looking up the reflection multiple times 2013-10-08 16:25:43 -07:00
Aaron Patterson
96a366cd9b cache join associations and join base on the stack
No reason to decompose the join objects on every iteration
2013-10-08 15:46:06 -07:00
Aaron Patterson
eeda42fc11 use the API rather than accessing underlying data structures 2013-10-08 15:39:02 -07:00
Aaron Patterson
c04a8192fd associations is always a hash 2013-10-08 15:35:55 -07:00
Aaron Patterson
d0be8a0480 keys are always symbols 2013-10-08 15:33:10 -07:00
Aaron Patterson
2a2707f98b we can get a list of reflections from the join parts, so let's remove
the @reflections ivar.
2013-10-08 15:22:32 -07:00
Aaron Patterson
e98a877d6c transform the association input so we can avoid type checks later.
We should consider moving the input munging outside the class
instantiation
2013-10-08 15:13:12 -07:00
Aaron Patterson
d5ab292ed6 we know the keys are scalars, so avoid some typechecking 2013-10-08 14:25:41 -07:00
Aaron Patterson
db5a5eaeec this method is only ever called with a reflection
Stop typechecking the parameter.  We know the type.
2013-10-08 14:21:51 -07:00
Aaron Patterson
7e5c5e4d8c don't access the reflections hash
The reflections hash is supposed to be private, so let's use the API.
2013-10-08 14:10:57 -07:00
Aaron Patterson
95603695ec build association tree thing on demand.
`instantiate` is only called once, so there is no reason to cache the
data structure on the instance and mutate itself.
2013-10-08 13:44:48 -07:00
Aaron Patterson
ebe4f80512 hide join_parts internals from other classes 2013-10-08 11:31:05 -07:00
Aaron Patterson
84499eb4bd decouple JoinAssociation from JoinDependency 2013-10-08 11:26:29 -07:00
Aaron Patterson
bf8628df0a @associations can never have an array, so remove the dead code 2013-10-08 10:51:45 -07:00
Aaron Patterson
40898c8c19 typecast records returned from the db rather than to_sing everything 2013-10-08 10:49:53 -07:00
Edo Balvers
7cab255a97 Fixes #11773 when using includes combined with select, the select statement was overwritten. 2013-10-08 16:41:53 +02:00
Federico Ravasio
0aeb11e575 Allow methods arity below -1 in assert_responds.
Every method from MRI's core classes is written in C. This means
Method#arity always returns -1 for methods with a variable number of
arguments. This is not the case with Rubinius, where, for example
Array#slice! is implemented in Ruby and has arity -2, since is
defined as def slice!(start, length = undefined)
2013-10-08 00:15:11 +02:00
Federico Ravasio
d8537ef1ec Assert presence of "frozen" in error message, not the full MRI message.
Related to all the other issues regarding message independent assertions
to make Rails compatible with other Ruby implementations other than MRI.

The best way here would be to have a specific error raised when modifying
frozen objects, like FrozenObjectError or something. But since Ruby
doesn't provide such a thing, we must limit the assertion to the lowest
common denominator, which is word "frozen".
2013-10-08 00:15:07 +02:00
Aaron Patterson
d2d6e4a980 extract the string handling part to a method.
We know the structure passed in to the `construct` method will be a
hash, so we don't need to test it all the time.  The key value will be a
symbol or string, so handle it with the special method
2013-10-07 15:12:40 -07:00
Aaron Patterson
77e5c1262c remove more dead code
We control the inputs to `construct`, so the wrong type shouldn't be
passed in ever.
2013-10-07 15:03:08 -07:00
Aaron Patterson
3270bea4f3 this code is never used, remove it 2013-10-07 14:40:22 -07:00
Federico Ravasio
afd0a8ab5f Just change ENV and restore it afterwards.
Stubbing ENV[] is not safe outside MRI. At some point after the
stubbing has occurred a backtrace is printed to the ActiveSupport
warning log: there Rubinius accesses ENV['RBX_NOCOLOR'] to determine
if it should print the backtrace with colors or not, causing the
stub to fail. Other implementations might access ENV in a different
way too, we just can't predict it.
The only thing we can do here is to actually set the ENV with what
we want and restore it afterwards.
2013-10-07 10:15:23 +02:00
Aaron Patterson
2ae9166d8f log the statement name along with the SQL 2013-10-04 16:51:35 -07:00
Aaron Patterson
98e001641f log every sql statement, even when they error 2013-10-04 15:53:13 -07:00
Aaron Patterson
19fc88646b prepare the statement inside the begin / rescue block 2013-10-04 15:41:59 -07:00
Aaron Patterson
a0420d4733 rm LogIntercepter 2013-10-04 15:19:27 -07:00
Aaron Patterson
46c57ec4d9 stop adding singleton methods to the SQLite3 connection 2013-10-04 15:18:53 -07:00
Aaron Patterson
6828ae7779 stop adding singleton methods to the mysql2 adapter 2013-10-04 15:16:49 -07:00
Aaron Patterson
cc04a4a903 stop adding singleton methods to the PG connection 2013-10-04 15:13:14 -07:00
Aaron Patterson
ffbefc7e55 wrap logging around the actual query call itself.
This is to be consistent with the way the mysql2 adapter times queries
2013-10-04 14:43:57 -07:00
Arthur Neves
37cd223cb6 add regression test for set_inverse_instance on add_to_target 2013-10-04 14:01:45 -03:00
Aaron Patterson
2de0ccafdd
inject down the hash cache 2013-10-03 15:58:22 -07:00
Aaron Patterson
1a193bdc63 hashes are ordered, so we do not need to sort 2013-10-03 15:28:08 -07:00
Aaron Patterson
18a74f9bba Always pass parameters to build
We always know the parameters in advance, so we don't need to build it
in to the method signature
2013-10-03 15:17:50 -07:00
Aaron Patterson
8e1b363167 Set the join type on construction
We always set the join type immediately after construction, just make it
part of the constructor and we can skip that step
2013-10-03 15:13:55 -07:00
Aaron Patterson
6141d0c4b8 simplify the JoinAssociation constructor, check validity *before* 2013-10-03 15:08:33 -07:00
Aaron Patterson
4c0f023ea3 parent is always passed in, so make it non-optional 2013-10-03 15:06:11 -07:00
Aaron Patterson
8a4ea4a4a5 require the files we need so the classes are stand-alone 2013-10-03 15:03:40 -07:00
Aaron Patterson
838be5266d Merge pull request #12435 from sikachu/master-port-12084
Port test from cf1904f to avoid future regression
2013-10-03 11:13:55 -07:00
Prem Sichanugrist
68421f330b Port test from cf1904f to avoid future regression
Related issue: #11939, #12084
2013-10-03 14:11:12 -04:00
Aaron Patterson
680464bd2f map the association chain to table names 2013-10-03 11:04:29 -07:00
Vipul A M
a4f086dd9d intiantiated => instantiated [ci-skip] 2013-10-03 10:46:41 +05:30
Aaron Patterson
7768c2a7f3 fix the variable name 2013-10-02 19:01:16 -07:00
Aaron Patterson
cb0aa02e74 preheat habtm column cache 2013-10-02 17:22:28 -07:00
Aaron Patterson
da06ae88ab add missing require 2013-10-02 17:04:02 -07:00
Aaron Patterson
e1467333a1 remove some duplicate code 2013-10-02 16:42:42 -07:00
Aaron Patterson
244446fcc5 add a note to the changelog 2013-10-02 16:06:59 -07:00
Aaron Patterson
5864b9a894 remove HABTM associations 2013-10-02 16:03:45 -07:00
Aaron Patterson
957d7ae037 remove HABTM special cases from reflections 2013-10-02 15:59:13 -07:00
Aaron Patterson
a03ea3ff97 remove the HABTM preloader 2013-10-02 15:57:13 -07:00
Aaron Patterson
88c0093778 remove HABTM special cases from associations classes 2013-10-02 15:53:56 -07:00
Aaron Patterson
99185f0004 remove HABTM special cases from the fixtures 2013-10-02 15:51:29 -07:00
Aaron Patterson
8e4afa4eb1 repurpose the HABTM builder class 2013-10-02 15:49:36 -07:00
Aaron Patterson
dca2fb3680 goodbye has_and_belongs_to_many1, we will miss you! 2013-10-02 15:43:50 -07:00
Aaron Patterson
d3089adb1a keep track of the left and right reflections and expose those 2013-10-02 15:43:22 -07:00
Aaron Patterson
7963c5d841 have the builder create the middle reflection 2013-10-02 15:40:11 -07:00
Aaron Patterson
0af978d334 call the class method to define the callbacks 2013-10-02 15:31:26 -07:00
Aaron Patterson
7a38eae007 Merge branch 'master' into habtm
* master:
  we can define callbacks without a builder instance
  push methods that don't depend on the instance to the class
  get the name from the reflection
  cache the name and options on the stack
  decouple belongs_to callback definition from the builder instance.
  add_before_destroy_callbacks doesn't depend on the instance, so push it to the class.
  valid_options doesn't depend on the instance, so push it to the class
  use the information on the reflection to determine whether callbacks should be added
  Running all isolated test for actionview
  association builder is no longer needed for counter cache, so remove it
  push constructable? on to the reflection
  Adds the Rails maintenance policy to the Guides
  name is on the reflection, so just use the reflection
  decouple define_callback from the instance
  Added activemodel as a explicit dependency
  unify `Fixes` notes in AR changelog. [ci skip].
  improving `reload` doc wording. #12418 [ci skip]
  Update AR reload doc for the case of manually set primary key attribute [ci skip]
2013-10-02 15:28:59 -07:00
Aaron Patterson
b86a4965b8 we can define callbacks without a builder instance 2013-10-02 15:28:50 -07:00
Aaron Patterson
73ee85f39d push methods that don't depend on the instance to the class 2013-10-02 15:28:50 -07:00
Aaron Patterson
07d522b1be get the name from the reflection 2013-10-02 15:28:50 -07:00
Aaron Patterson
32bacb1ce8 cache the name and options on the stack 2013-10-02 15:28:50 -07:00
Aaron Patterson
ea11af9568 decouple belongs_to callback definition from the builder instance.
All the information is on the reflection, so just get it there.
2013-10-02 15:28:50 -07:00
Aaron Patterson
743f1a9094 add_before_destroy_callbacks doesn't depend on the instance, so push it
to the class.
2013-10-02 15:28:49 -07:00
Aaron Patterson
22f05afb2d valid_options doesn't depend on the instance, so push it to the class 2013-10-02 15:28:49 -07:00
Aaron Patterson
a88a5d7370 use the information on the reflection to determine whether callbacks should be added 2013-10-02 15:28:49 -07:00
Aaron Patterson
438e172a45 association builder is no longer needed for counter cache, so remove it 2013-10-02 14:55:29 -07:00
Aaron Patterson
75beb6c7c3 push constructable? on to the reflection 2013-10-02 14:52:59 -07:00
Aaron Patterson
5d8b7760ee name is on the reflection, so just use the reflection 2013-10-02 14:38:05 -07:00
Aaron Patterson
c2b3371838 decouple define_callback from the instance 2013-10-02 14:34:57 -07:00
Aaron Patterson
0091808a08 move habtm translation to a builder class 2013-10-02 14:12:03 -07:00
Aaron Patterson
14e9e57fdb get the left and right association names from the join model 2013-10-02 11:47:02 -07:00
Aaron Patterson
d15165196c define the join model without using closures on the methods 2013-10-02 11:22:59 -07:00
Yves Senn
dfe40cdcab unify Fixes notes in AR changelog. [ci skip]. 2013-10-02 15:36:20 +02:00
Yves Senn
3b0d34ca17 improving reload doc wording. #12418 [ci skip] 2013-10-02 10:18:02 +02:00
Anatoli Makarevich
7f1e8759c3 Update AR reload doc for the case of manually set primary key attribute [ci skip] 2013-10-02 08:14:58 +04:00
Aaron Patterson
636a909985 decouple the HABTM builder 2013-10-01 16:15:04 -07:00
Aaron Patterson
c00173b325 only pass options to the habtm builder 2013-10-01 15:42:28 -07:00
Aaron Patterson
ad7b5efb55 Squashed commit of the following:
commit 02d3b059608c30e98136fde78bc710928f080566
Author: Aaron Patterson <aaron.patterson@gmail.com>
Date:   Mon Sep 30 15:31:39 2013 -0700

    habtm works in terms of hm:t

commit 71ac336bbb41f5047a4ee307883a95eca7195742
Author: Aaron Patterson <aaron.patterson@gmail.com>
Date:   Mon Sep 30 15:27:07 2013 -0700

    passing before_add callbacks

commit d846a7bf9872a79c3aa8082917abe806278fa159
Author: Aaron Patterson <aaron.patterson@gmail.com>
Date:   Fri Sep 27 17:57:53 2013 -0700

    reducing diff against master

commit 96bd97de47d61a71c368ae367bc59a2dbec3c9ab
Author: Aaron Patterson <aaron.patterson@gmail.com>
Date:   Fri Sep 27 17:52:35 2013 -0700

    fixing more tests

commit 0620399fc231df87c5f08664db1c37e5c1fa5a05
Author: Aaron Patterson <aaron.patterson@gmail.com>
Date:   Fri Sep 27 17:32:52 2013 -0700

    self-referential tables in hm:t are allowed to have the same pk

commit 48eb90e27921d10b6ba3e400ab2c784ed75d5ec4
Author: Aaron Patterson <aaron.patterson@gmail.com>
Date:   Fri Sep 27 17:03:19 2013 -0700

    translating more options

commit 5cace7b2cb546fd6b096543bfc49c4b7197ad21a
Author: Aaron Patterson <aaron.patterson@gmail.com>
Date:   Fri Sep 27 17:01:02 2013 -0700

    handling more hm:t cases

commit 69985ca2cabff2c3f58f5d0a7eb12d7b414c1a01
Merge: d417ec8 3e0a60e
Author: Aaron Patterson <aaron.patterson@gmail.com>
Date:   Fri Sep 27 16:57:12 2013 -0700

    Merge branch 'master' into rmhbtm

    * master: (21 commits)
      adding a test to demonstrate how to use STI subclasses on the far right side of a hm:t association along with preloading.
      Fixed grammatical typo in configuring.md guide.
      Getting Started Guide: Fix code container in Chapter 5.2 [ci-skip]
      Getting Started Guide: Update sentence in Chapter 5.8 [ci-skip]
      Add new line after create action on CommentsController code example
      Adds template dependencies rake task from cache_digests gem.
      [ci skip] Update scaffold output and change some words.
      [ci skip] escape unintended url in docs
      Getting Started Guide: post.rb -> Post
      [ci skip] Add missing periods and update link name and some wording.
      quote `false` reference in querying guide.
      Getting Started Guide: update link_to string argument to use single-quote mark, following document style [ci skip]
      Fix small typo in docs
      changelog entry
      fix .find when inverse is set
      update changelog for #12359
      Make sure inverse_of is visible on the has_many callbacks
      Getting Started Guide: posts_controller -> PostsController [ci skip]
      [ci skip] Correct the explanation of the example for find_or_create_by when used with create_with in ActiveRecord Querying guide
      added "id: false" to HABTM join table example
      ...

commit d417ec82e8f83c32124d1c1a19824d023cfdf015
Author: Aaron Patterson <aaron.patterson@gmail.com>
Date:   Wed Sep 25 16:49:08 2013 -0700

    another case is passing

commit 5c68280500962e4b2b6819dd863ebe8b398e5834
Author: Aaron Patterson <aaron.patterson@gmail.com>
Date:   Wed Sep 25 16:21:22 2013 -0700

    this seems to work

commit e458c5e55c04a2444e96aca1ff192be42bc4ce7f
Author: Aaron Patterson <aaron.patterson@gmail.com>
Date:   Wed Sep 25 16:13:07 2013 -0700

    add another case

commit fc6203b0d49c847b8efb1cc33d358897625f2115
Author: Aaron Patterson <aaron.patterson@gmail.com>
Date:   Wed Sep 25 15:51:45 2013 -0700

    delete center records on habtm

commit 9af5156098f6bc8f8ce8eb559a51137960b4938b
Merge: 3a60b03 e2fd64f
Author: Aaron Patterson <aaron.patterson@gmail.com>
Date:   Wed Sep 25 11:33:13 2013 -0700

    Merge branch 'master' into rmhbtm

    * master: (100 commits)
      remove initialize method
      extract association resetting to a method
      hash insertion order doesn't matter anymore, so only loop over the owners once
      always populate the preloaded records instance variable so we can remove the @associated_records_by_owner ivar
      keep preloaded records in a list rather than extract from a hash
      Getting Started Guide: Hello Rails! -> Hello, Rails! and wrap code tag
      push slice loading to it's own method so we can remove the type casting code
      Add CHANGELOG entry for #12344
      Add regression test to #12343
      Fix typo in number_to_human docs: you -> your
      guarantee that `klass` is not nil inside the preloader objects
      [Documentation] Add a missing validation to I18n docs
      Use the given name in html_options for the hidden field in collection_check_boxes
      eliminate unused ivar
      all records have a preloaded, so eliminate that conditional
      eliminate the `loaded?` conditional
      push preloaded test up to the factory method so we can eliminate conditionals from the individual preloaded classes
      assign_attributes should return if argument is blank.
      No need the else clause
      Use join to concat the both side of the AST
      ...

commit 3a60b038a40532397b6c204dfb09d6d43a9336ac
Author: Aaron Patterson <aaron.patterson@gmail.com>
Date:   Wed Sep 18 17:50:11 2013 -0700

    start with a clean slate

commit f30d3631af11ea6144d3ae7a068a7c0072e93a82
Author: Aaron Patterson <aaron.patterson@gmail.com>
Date:   Wed Sep 18 17:30:59 2013 -0700

    make sure the class name goes on the rhs belongs_to

commit f7516b724014504ddb2e706fea1b5438dc5332c3
Author: Aaron Patterson <aaron.patterson@gmail.com>
Date:   Wed Sep 18 16:31:40 2013 -0700

    remove unused variable

commit 61ffc5b9854dc2fe83ee502b17ba8028270ff8a7
Merge: 6cf41cd 460eb83
Author: Aaron Patterson <aaron.patterson@gmail.com>
Date:   Wed Sep 18 16:25:17 2013 -0700

    Merge branch 'master' into rmhbtm

    * master:
      support objects with blank string primary keys
      ActiveRecord::Base#<=> has been removed.  Primary keys may not be in order, or even be numbers, so sorting by id doesn't make sense.  Please use `sort_by` and specify the attribute you wish to sort with.  For example, change:
      do what the superclass does in the case that objects do not match

commit 6cf41cd98a82e6f4fe6d868ad323df3d72a9748f
Author: Aaron Patterson <aaron.patterson@gmail.com>
Date:   Wed Sep 18 15:06:28 2013 -0700

    heating up habtm cache

commit d7f6c3aa491f27ba71fdb2b9d0b9d1780664f4dc
Merge: c68c904 56bfd8a
Author: Aaron Patterson <aaron.patterson@gmail.com>
Date:   Wed Sep 18 14:07:51 2013 -0700

    Merge branch 'master' into rmhbtm

    * master: (58 commits)
      Fix an issue where router can't recognize downcased url encoding path.
      There's no need to do this
      Remove tzinfo dependency from Action Pack
      [ci skip] Improve readability of 4.3's NOTE in migration.md.
      Removes unused code related to DatabaseTasks.
      [ci skip] Consistency wording of 9.6 in form_helpers.md
      [ci skip] Update plugins.md
      Removing ActiveSupport::Concern, it's not needed
      Fixing comment typo in ActionController::Base
      Don't require using application_name before options
      Collapse where constraints to one where constraint
      Custom flash should be defined only for the class that defines it and it's subclasses.
      Fix typos: the indefinite articles(a -> an)
      Missing destroy command
      Update 3_2_release_notes.md
      Add CHANGELOG entry for #11698
      Add CHANGELOG entry for #12149
      Use the Rails binary when generating task
      Remove unnecessary loop
      "generates" applies to "collection radio" so it should be singular
      ...

commit c68c904866ef9562c3bd9b54574206a416184414
Merge: 0f5d8e0 71cf717
Author: Aaron Patterson <aaron.patterson@gmail.com>
Date:   Wed Sep 11 17:45:53 2013 -0700

    Merge branch 'master' into rmhbtm

    * master:
      these are not real developer objects, so counting them doesn't make sense.  Let's load the object to ensure it's an array and count the array.
      Remove conditional adding a new method
      Fix inverted conditional
      Remove invalid comment
      Check if the SQL is not a prepared statement
      Whitespaces
      Revert "Add meta tag with charset information to application layout."
      Avoid empty transaction from setting has_one association on new record.
      Reduce Duration#inspect to a single series of transformations
      Relation#merge should not lose readonly(false) flag.
      Reduce allocations when extracting AR models
      Perf: avoid dupes add fallback logic for coders

commit 0f5d8e0febd3128cf4121ff36f1764b9284d9f7d
Author: Aaron Patterson <aaron.patterson@gmail.com>
Date:   Wed Sep 11 11:43:29 2013 -0700

    everything works with extensions

commit d003c103b5908fb3a6427f39bddd1748ef2c2576
Merge: 5768c38 7e0cac1
Author: Aaron Patterson <aaron.patterson@gmail.com>
Date:   Wed Sep 11 11:23:59 2013 -0700

    Merge branch 'master' into rmhbtm

    * master:
      fix deleting join models with no pk
      remove sentence err
      [ci skip] 'previous version of Rails' is gramatically incorrect
      Add meta tag with charset information to application layout.
      add a comment for sanity of other people to come

commit 5768c38d53fd66a97814faaea8e07c70722b310f
Author: Aaron Patterson <aaron.patterson@gmail.com>
Date:   Tue Sep 10 15:11:05 2013 -0700

    habtms with a scope seem to be working

commit 5ee9108d95c544d4befd682a72139383d0780d68
Merge: d5478e6 e64b5da
Author: Aaron Patterson <aaron.patterson@gmail.com>
Date:   Tue Sep 10 11:55:48 2013 -0700

    Merge branch 'master' into rmhbtm

    * master:
      ask the association for records rather than calling `send`

commit d5478e64bbf80337ec35462368edabb373feeb74
Author: Aaron Patterson <aaron.patterson@gmail.com>
Date:   Tue Sep 10 11:54:39 2013 -0700

    ask the association for records rather than calling `send`

commit 93020bc1ad51363c3f400370f91c9494690dcea8
Merge: 11b3d5f d68419a
Author: Aaron Patterson <aaron.patterson@gmail.com>
Date:   Tue Sep 10 11:30:03 2013 -0700

    Merge branch 'master' into rmhbtm

    * master:
      Use Ruby 2.0 caller_locations instead of caller if available
      Update Rails 3.2.x guide link [ci skip]
      Be sure to restore the default I18n.locale after changed its value in a test
      Fixes typo in Object#try!
      More unused associations in AR test models
      ✂️ [ci skip]
      change function def self.table_name to self.table_name
      Clean up unused associations in AR test model
      Reset ActionView::Base.logger instead of AC::Base.logger
      Refactor handling of action normalization
      Don't mutate the Base settings by merge!ing the given value
      Make AC standalone rendering work
      use assert_empty in activemodel conditional validation test cases
      Removed unused modules and classes
      Removed unnecessary require
      Remove helper fixtures not used in any test
      Back AV description in gemspec
      Fix order dependent test
      grab executable from rubygems
      Fixed API task file

commit 11b3d5fa45b57fc4e7dddb09be583498b120b185
Author: Aaron Patterson <aaron.patterson@gmail.com>
Date:   Mon Sep 9 16:19:48 2013 -0700

    change query count since we are using hm:t associations

commit f59daebedab3ed13f31c99244ff71a4a5d6e554b
Author: Aaron Patterson <aaron.patterson@gmail.com>
Date:   Mon Sep 9 15:35:07 2013 -0700

    delegate compute_type to a real AR class

commit c84a40d2ed76e5843b994c5a2b9e29ced3816511
Author: Aaron Patterson <aaron.patterson@gmail.com>
Date:   Mon Sep 9 15:29:51 2013 -0700

    define callbacks with the builder

commit d08b1b6b3efc9ed8b0d5476892f048fbffb39e40
Merge: acebec1 0c5d0be
Author: Aaron Patterson <aaron.patterson@gmail.com>
Date:   Mon Sep 9 15:17:40 2013 -0700

    Merge branch 'master' into rmhbtm

    * master:
      let the class cache object clean up user input
      make @bitsweat happy. ❤️

commit acebec128e108ac2b4855e540d8764629670cb83
Merge: 2de68a4 e1cbd42
Author: Aaron Patterson <aaron.patterson@gmail.com>
Date:   Mon Sep 9 14:47:30 2013 -0700

    Merge branch 'master' into rmhbtm

    * master:
      stop using deprecated api in the tests

commit 2de68a464641f76067743957f889ac87dff395a0
Merge: 7504df9 1385ae1
Author: Aaron Patterson <aaron.patterson@gmail.com>
Date:   Mon Sep 9 14:34:37 2013 -0700

    Merge branch 'master' into rmhbtm

    * master:
      Remove BasicRendering tests
      Remove remaining coupling with AV in MimeResponds
      Remove BasicRendering and remove template functionality from AbsC::Rendering
      Improves a sentence in guides/security
      [ci skip] Change link name of Rails i18n wiki.
      Typo in Changelog.
      Fix fixtures regression that required table names to map to classes only, not class names
      Use MiniTest::Unit::TestCase instead of Minitest::Test
      Use Ruby on Rails Coding Conventions for code examples in the guides

commit 7504df92f21ed3d5da7c2760d760f026728ed04d
Author: Aaron Patterson <aaron.patterson@gmail.com>
Date:   Mon Sep 9 14:34:02 2013 -0700

    fake class name should be a valid class name

commit 6609620ea86dc0fb7c4bbfb0db950f6e3fc75b56
Author: Aaron Patterson <aaron.patterson@gmail.com>
Date:   Fri Sep 6 15:52:03 2013 -0700

    move another habtm

commit 2c95a36e2c3dfe92f2930f3cca44bc4452732a23
Author: Aaron Patterson <aaron.patterson@gmail.com>
Date:   Fri Sep 6 15:50:18 2013 -0700

    use the habtm name to generate the rhs name on the join model

commit bd963f720b1db19b0bec186bc33bef9203d8b011
Author: Aaron Patterson <aaron.patterson@gmail.com>
Date:   Fri Sep 6 15:47:29 2013 -0700

    don't hardcode the name

commit 461759e2caf66f23dca4eff988648bf769a2b533
Author: Aaron Patterson <aaron.patterson@gmail.com>
Date:   Fri Sep 6 15:45:27 2013 -0700

    we do not need to specify the fk

commit 9c223f01db6e36adbb7570e2aa1bcaec1d142c87
Author: Aaron Patterson <aaron.patterson@gmail.com>
Date:   Fri Sep 6 15:44:08 2013 -0700

    just call the left side :left_side

commit 5661622a82154eff877fe0993bfffad13dacad7a
Author: Aaron Patterson <aaron.patterson@gmail.com>
Date:   Fri Sep 6 15:40:36 2013 -0700

    initial habtm implementation is working
2013-10-01 15:40:40 -07:00
Yves Senn
78fcc5fd1a extract adapter savepoint implementations into abstract/savepoints.rb. 2013-09-30 15:46:04 +02:00
Yves Senn
032998ad74 change the savepoint interface to allow passing the name. 2013-09-30 15:29:40 +02:00
Yves Senn
12720c77f5 Make .next_migration_number reusable for third party AR generators. 2013-09-30 15:03:55 +02:00
Yves Senn
93899335ae fix test_sqlite3_mem test run.
marshalling between processes does not work with an in-memory db.
This breaks the `test_sqlite3_mem` run (see stacktrace below).
After that failure most tests start to fail randomly.

```
/Users/senny/Projects/rails/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb:512:in `table_structure': Could not find table 'posts' (ActiveRecord::StatementInvalid)
	from /Users/senny/Projects/rails/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb:399:in `columns'
	from /Users/senny/Projects/rails/activerecord/lib/active_record/connection_adapters/schema_cache.rb:93:in `block in prepare_default_proc'
	from /Users/senny/Projects/rails/activerecord/lib/active_record/connection_adapters/schema_cache.rb:44:in `yield'
	from /Users/senny/Projects/rails/activerecord/lib/active_record/connection_adapters/schema_cache.rb:44:in `columns'
	from /Users/senny/Projects/rails/activerecord/lib/active_record/model_schema.rb:208:in `columns'
	from /Users/senny/Projects/rails/activerecord/lib/active_record/model_schema.rb:249:in `column_defaults'
	from /Users/senny/Projects/rails/activerecord/lib/active_record/locking/optimistic.rb:171:in `column_defaults'
	from /Users/senny/Projects/rails/activerecord/lib/active_record/core.rb:167:in `initialize'
	from /Users/senny/Projects/rails/activerecord/lib/active_record/inheritance.rb:27:in `new'
	from /Users/senny/Projects/rails/activerecord/lib/active_record/inheritance.rb:27:in `new'
	from /Users/senny/Projects/rails/activerecord/test/cases/base_test.rb:1368:in `block in test_marshal_between_processes'
	from /Users/senny/Projects/rails/activerecord/test/cases/base_test.rb:1366:in `fork'
	from /Users/senny/Projects/rails/activerecord/test/cases/base_test.rb:1366:in `test_marshal_between_processes'
	from /Users/senny/Projects/rails/.bundle/gems/minitest-5.0.8/lib/minitest/test.rb:110:in `block (3 levels) in run'
	from /Users/senny/Projects/rails/.bundle/gems/minitest-5.0.8/lib/minitest/test.rb:208:in `capture_exceptions'
	from /Users/senny/Projects/rails/.bundle/gems/minitest-5.0.8/lib/minitest/test.rb:107:in `block (2 levels) in run'
	from /Users/senny/Projects/rails/.bundle/gems/minitest-5.0.8/lib/minitest/test.rb:260:in `time_it'
	from /Users/senny/Projects/rails/.bundle/gems/minitest-5.0.8/lib/minitest/test.rb:106:in `block in run'
	from /Users/senny/Projects/rails/.bundle/gems/minitest-5.0.8/lib/minitest.rb:296:in `on_signal'
	from /Users/senny/Projects/rails/.bundle/gems/minitest-5.0.8/lib/minitest/test.rb:280:in `with_info_handler'
	from /Users/senny/Projects/rails/.bundle/gems/minitest-5.0.8/lib/minitest/test.rb:105:in `run'
	from /Users/senny/Projects/rails/.bundle/gems/minitest-5.0.8/lib/minitest.rb:268:in `block (2 levels) in run'
	from /Users/senny/Projects/rails/.bundle/gems/minitest-5.0.8/lib/minitest.rb:267:in `each'
	from /Users/senny/Projects/rails/.bundle/gems/minitest-5.0.8/lib/minitest.rb:267:in `block in run'
	from /Users/senny/Projects/rails/.bundle/gems/minitest-5.0.8/lib/minitest.rb:296:in `on_signal'
	from /Users/senny/Projects/rails/.bundle/gems/minitest-5.0.8/lib/minitest.rb:285:in `with_info_handler'
	from /Users/senny/Projects/rails/.bundle/gems/minitest-5.0.8/lib/minitest.rb:266:in `run'
	from /Users/senny/Projects/rails/activesupport/lib/active_support/test_case.rb:31:in `block in __run'
	from /Users/senny/Projects/rails/activesupport/lib/active_support/test_case.rb:31:in `map'
	from /Users/senny/Projects/rails/activesupport/lib/active_support/test_case.rb:31:in `__run'
	from /Users/senny/Projects/rails/.bundle/gems/minitest-5.0.8/lib/minitest.rb:115:in `run'
	from /Users/senny/Projects/rails/.bundle/gems/minitest-5.0.8/lib/minitest.rb:46:in `block in autorun'
```

/cc @tenderlove
2013-09-30 09:08:07 +02:00
Rafael Mendonça França
414d1eaf6c Merge pull request #12383 from marclennox/master
Fixed issue #12327
2013-09-29 06:36:43 -07:00
Rafael Mendonça França
f90a5888ba Merge pull request #12398 from thedarkone/thread-safety-stuff
Thread safety fixes
2013-09-28 17:16:25 -07:00
Rafael Mendonça França
8771a565d3 Merge pull request #11496 from jetthoughts/11376_has_many_assoc_respect_scope_on_build
Removed where_values_hash from AR::NullRelation
2013-09-28 17:12:13 -07:00
Rafael Mendonça França
c2ee6a079e Merge pull request #12396 from arthurnn/cleanup_logsubs
Cleanup identitymap logger from LogSubscriber
2013-09-28 16:40:45 -07:00
Vijay Dev
33434f69c4 Merge branch 'master' of github.com:rails/docrails 2013-09-28 23:28:16 +05:30
thedarkone
28572f59f8 Use TS::Cache instead of Mutex + Hash.
TS::Cache#compute_if_absent guarantees that only a single thread will get to execute the provided block for a given key.
2013-09-28 19:19:07 +02:00
Arthur Neves
260f965890 Cleanup identitymap logger from LogSubscriber
Also renaming ivar @odd_or_even to @odd
2013-09-28 12:00:19 -04:00
Paul Nikitochkin
8fb0de2cae Removed where_values_hash from AR::NullRelation
In order to build associated records for owners which has not been saved
need to get where values to use as default attributes.
But for new record owner uses `ActiveRecord::NullRelation` which
override `where_values_hash` to return empty hash stub.

`where_values_hash` is not used to invoke any sql query, but good to
build others chains (even will be never executed) like:

```ruby
  post          = Post.new
  admin_comment = post.admin_comments.build

  assert_equal 'Admin', admin_comment.author
```

Closes #11376, #11676, #11675
2013-09-28 11:21:34 +03:00
kennyj
8e814a0ac0 Renamed generated_feature_methods to generated_association_methods. 2013-09-28 12:26:23 +09:00
Aaron Patterson
3e0a60e4e2 adding a test to demonstrate how to use STI subclasses on the far right
side of a hm:t association along with preloading.
2013-09-27 16:56:49 -07:00
Marc Lennox
747ccb0f7c Fixed issue #12327 2013-09-27 14:26:17 -04:00
Arthur Neves
dfd3b8096e changelog entry 2013-09-25 19:19:10 -04:00
Arthur Neves
645af000a4 fix .find when inverse is set
.find([1]) should return an Array of entries, even when a invese object is in memory already
2013-09-25 19:06:00 -04:00
Rafael Mendonça França
d1e36842ba Merge pull request #12359 from arthurnn/inverse_on_callbacks
Make sure inverse_of is visible on the has_many callbacks
2013-09-25 12:06:04 -07:00
Arthur Neves
25ada9b541 update changelog for #12359 2013-09-25 14:46:24 -04:00
Aaron Patterson
e2fd64fe46 Merge branch 'master' into preload
* master: (62 commits)
  Getting Started Guide: Hello Rails! -> Hello, Rails! and wrap code tag
  Add CHANGELOG entry for #12344
  Add regression test to #12343
  Fix typo in number_to_human docs: you -> your
  [Documentation] Add a missing validation to I18n docs
  Use the given name in html_options for the hidden field in collection_check_boxes
  assign_attributes should return if argument is blank.
  No need the else clause
  Use join to concat the both side of the AST
  Add a CHANGELOG entry about Web Console inclusion
  added column type to example in section 2.3
  Include web-console in new projects Gemfile
  ActiveRecord::ConnectionAdapters::Column.string_to_time method respects string with timezone. Closes #12278.
  add test_scoped_root_as_name
  Getting Started Guide: update RubyGems Guides link [ci skip]
  Deprecate unused quoted_locking_column method.
  Update references to wycats/thor to erikhuda/thor.
  bcrypt-ruby v3.1.2 supports Ruby 2.0 on Windows
  Fix the model name in the association basics guides
  We shouldn't override PostgreSQLAdapter's superclass inheritance while monkeypatching
  ...
2013-09-25 11:25:36 -07:00
Arthur Neves
3af4ae82e5 Make sure inverse_of is visible on the has_many callbacks 2013-09-25 14:24:27 -04:00
Aaron Patterson
70e48a6ac3 remove initialize method 2013-09-25 11:21:28 -07:00
Aaron Patterson
ea87eb70b1 extract association resetting to a method 2013-09-25 11:21:08 -07:00
Aaron Patterson
7140891175 hash insertion order doesn't matter anymore, so only loop over the
owners once
2013-09-25 10:46:08 -07:00
Aaron Patterson
57112fb7e7 always populate the preloaded records instance variable so we can remove
the @associated_records_by_owner ivar
2013-09-25 10:40:50 -07:00
Aaron Patterson
be91bb2640 keep preloaded records in a list rather than extract from a hash 2013-09-25 10:34:49 -07:00
Andrew White
f398285835 Merge pull request #12290 from kennyj/fix_12278
Closes #12278. AR::ConnectionAdapters::Column.string_to_time method respects string with timezone.
2013-09-24 21:37:53 -07:00
Aaron Patterson
4c045876da push slice loading to it's own method so we can remove the type casting
code
2013-09-24 17:21:19 -07:00
Rafael Mendonça França
43d600ee20 Add regression test to #12343 2013-09-24 20:59:26 -03:00
Aaron Patterson
c4e1fdd9b2 guarantee that klass is not nil inside the preloader objects 2013-09-24 14:57:15 -07:00
Aaron Patterson
e9d2ff6959 eliminate unused ivar 2013-09-24 11:39:16 -07:00
Aaron Patterson
4a78541555 all records have a preloaded, so eliminate that conditional 2013-09-24 11:37:17 -07:00
Aaron Patterson
2075f39d72 eliminate the loaded? conditional 2013-09-24 11:36:14 -07:00
Aaron Patterson
b93d09dbc5 push preloaded test up to the factory method so we can eliminate
conditionals from the individual preloaded classes
2013-09-24 11:28:28 -07:00
wangjohn
3ecf26f48a assign_attributes should return if argument is blank.
If you are passed an empty hash, then assign_attributes doesn't need to
do any work and can just return early. This should fix the failing Agile
Web Development tests.
2013-09-24 13:22:59 -05:00
kennyj
8dd5a582f5 ActiveRecord::ConnectionAdapters::Column.string_to_time method respects string with timezone. Closes #12278. 2013-09-25 00:08:40 +09:00
Rafael Mendonça França
16c7873c44 Merge pull request #9860 from wangjohn/update_attributes_throws_error_with_nil
Raising an error when nil is passed to update_attributes.

Conflicts:
	activerecord/CHANGELOG.md
2013-09-24 11:56:50 -03:00
kennyj
bb54fcdfad Deprecate unused quoted_locking_column method. 2013-09-24 21:56:52 +09:00
Aaron Patterson
bb9554ad62 we can't sort by lhs since the middle records have difference classes
and possibly different rules for finding those objects
2013-09-23 18:15:38 -07:00
Aaron Patterson
9b47142ce1 adding a test for sti on middle tables with sorting on RHS 2013-09-23 18:13:08 -07:00
Aaron Patterson
9e60f0f630 pass the preloader down so we only have to construct one 2013-09-23 17:10:23 -07:00
Aaron Patterson
f34d46ab82 reuse the same preloader object for each association 2013-09-23 16:51:51 -07:00
Aaron Patterson
6e5a2cb951 remove state from the preloader 2013-09-23 16:46:48 -07:00
Aaron Patterson
5b432811d7 pass the scope all the way down to the constructors 2013-09-23 16:34:03 -07:00
Aaron Patterson
761722287b only do the should_reset test once 2013-09-23 16:17:15 -07:00
Aaron Patterson
b4aae5a8e6 fix variable names and speed up relation ordering 2013-09-23 16:10:12 -07:00
Aaron Patterson
e5299c1ef6 hm:t preloading will respect order set on the RHS association 2013-09-23 15:58:34 -07:00
Rafael Mendonça França
9f1b43b924 Merge pull request #12315 from gaurish/super
TypeError: superclass mismatch for class PostgreSQLAdapter
2013-09-23 11:08:10 -07:00
Gaurish Sharma
2a6cb8ab2e We shouldn't override PostgreSQLAdapter's superclass inheritance while monkeypatching
Changing Inheritance section leads to following error on JRuby

    TypeError: superclass mismatch for class PostgreSQLAdapter

After this change,
Jruby: The above error no longer appear. Tests are still failing but they do run. Progress!
MRI: No change, all green(tested by running take test_test_postgresql)

Thanks to Aditya Sanghi(@asanghi) for help
2013-09-23 21:33:20 +05:30
Rafael Mendonça França
eec00b8c03 Merge pull request #11987 from wangjohn/schema_dumper_options
Creating options for schema dumper.
2013-09-23 08:11:26 -07:00
Rafael Mendonça França
9aa1a3d853 Merge pull request #10816 from bogdan/less-dirty-dirty
Make AM::Dirty less dirty to plugin into AR or other library
2013-09-23 10:59:05 -03:00
Rafael Mendonça França
afcca464db Merge pull request #11382 from kennyj/fix_10751-2
Dump UUID default functions to schema.rb [2nd version]. Fixes #10751.

Conflicts:
	activerecord/CHANGELOG.md
2013-09-22 16:01:01 -03:00
Rafael Mendonça França
70ff256850 Give the credits [ci skip] 2013-09-22 14:41:54 -03:00
Rafael Mendonça França
7f2e64520f Merge pull request #10500 from kennyj/fix_10450
Fixed a bug in  when using has_many association with :inverse_of option and UUID primary key.

Conflicts:
	activerecord/CHANGELOG.md
2013-09-22 14:38:39 -03:00
Rafael Mendonça França
8000835267 Merge pull request #12311 from kennyj/fix_typo_about_uuid
Fix typo. This test isn't executed even in the postgresql.
2013-09-21 12:24:05 -07:00
Rafael Mendonça França
f7b294fcea Add back options argument in the ActiveRecord::Base.initialize method
This will make easier to hook protected_attributes gem in our code
without making that gem fragile to change in Rails code base.

Closes #12243
2013-09-21 16:10:29 -03:00
kennyj
5adb4a4dc2 Fix typo. This test isn't executed in even postgresql. 2013-09-22 03:48:50 +09:00
Aaron Patterson
6f9ea581da cache associated target records hash 2013-09-20 20:17:49 -07:00
Aaron Patterson
99568a7a2d combine methods so we can reuse preloaders 2013-09-20 20:14:52 -07:00
Aaron Patterson
a901433ee3 return a list rather than hash 2013-09-20 20:11:45 -07:00
Aaron Patterson
8988f0b8be preserve order on the RHS query 2013-09-20 17:12:44 -07:00
Aaron Patterson
bc77ccacbd split up construction and mutation 2013-09-20 17:09:48 -07:00
Aaron Patterson
7f55ef8c4d fix method name 2013-09-20 16:22:31 -07:00
Aaron Patterson
ec7cc6aa17 access preloaders independently of model mutations 2013-09-20 15:49:56 -07:00
Aaron Patterson
31744e41f2 push running the preloaders up 2013-09-20 15:43:46 -07:00
Aaron Patterson
c6fbbbc174 push run up to preload 2013-09-20 15:39:10 -07:00
Aaron Patterson
18dccdccf7 the hash should only ever be length one, so decompose it 2013-09-20 14:23:56 -07:00
Aaron Patterson
7a8904353c stop depending on preloader interals so we can create fewer preloader
objects
2013-09-20 13:35:37 -07:00
Aaron Patterson
931a6aba36 lhs preload is always a single preload, so just preload one 2013-09-20 13:17:36 -07:00
Aaron Patterson
a04965b40e just read the attribute rather than sending 2013-09-20 11:56:59 -07:00
Aaron Patterson
8f9bba7058 extract exception raising, clean up group_by statement 2013-09-20 11:52:10 -07:00
Aaron Patterson
7ad26e8a45 generate fewer objects when grouping 2013-09-20 11:50:14 -07:00
Aaron Patterson
5170325698 do not access internal data structures 2013-09-20 11:46:24 -07:00
Aaron Patterson
5751689a68 exposing target records on the preloader 2013-09-20 11:31:00 -07:00
Aaron Patterson
1ea4a892a8 remove unused variable 2013-09-18 16:31:40 -07:00
Aaron Patterson
460eb83de0 support objects with blank string primary keys 2013-09-18 16:14:41 -07:00