Commit Graph

10703 Commits

Author SHA1 Message Date
Aaron Patterson
796c0fc1b0 pass the outer joins to join_constraints 2013-10-20 13:48:44 -07:00
Aaron Patterson
d059fa6f0c disconnect join_constraints from the instance 2013-10-20 13:42:42 -07:00
Aaron Patterson
fe67bc2a86 pass in scope chain so reflection is not needed 2013-10-20 13:18:50 -07:00
Aaron Patterson
e7bb4bb072 pass the foreign table and class to the join_constraints method 2013-10-20 13:14:48 -07:00
Aaron Patterson
bae5e02cf3 pass the join type to the join_constraints method 2013-10-20 13:11:38 -07:00
Paul Nikitochkin
a2ed5d2381 Process sub-query relation's binding values
Generated sub-query for Relation as array condition for `where` method
did not take in account its bind values, in result generates invalid SQL query.

Fixed by adding sub-query relation's binding values to base relation

Closes: #12586
2013-10-20 21:07:07 +03:00
Szymon Nowak
4ba9c508ec In Relation#empty? use #exists? instead of #count. 2013-10-19 21:53:45 +02:00
Yves Senn
db82e1d0bb Merge pull request #12560 from sue445/modify_find_lock_sample_code
avoid deprecation warning in sample code [ci skip]
2013-10-18 07:16:15 -07:00
sue445
a913af96e0 [ci skip] avoid deprecation warning in sample code
Account.find(1, lock: true)
-> DEPRECATION WARNING: Passing options to #find is deprecated. Please build a scope and then call #find on it.
2013-10-18 22:01:50 +09:00
Kenta Okamoto
bc5148da3d Convert Fixnum into String the port number in MySQL 2013-10-18 21:56:59 +09:00
Arthur Neves
fbf5085875 Fix some indentation on autosave association 2013-10-17 09:55:38 -04:00
Arthur Neves
827d42e1d1 Make define_non_cyclic_method simpler 2013-10-17 09:53:43 -04:00
Aaron Patterson
2549f6d8ee Merge branch 'master' into joindep
* master:
  Rephrase ActiveRecord transaction rollback warning
  Fix code blocks identation on AR and AS CHANGELOGs
  Removing unused fake models from actionpack tests
2013-10-16 11:43:13 -07:00
Lucas Mazza
2f1c9c8d60 Fix code blocks identation on AR and AS CHANGELOGs 2013-10-16 10:53:43 -03:00
Aaron Patterson
23f35b2fd8 use the node as cache so we can avoid accessing the table 2013-10-15 16:03:52 -07:00
Aaron Patterson
c5fe508df1 apply tables to the whole tree from the outside 2013-10-15 15:39:11 -07:00
Aaron Patterson
c746b53390 apply table aliases after the AST has been built 2013-10-15 15:34:59 -07:00
Aaron Patterson
db2e21aa0e stop reversing tables until we absolutely must 2013-10-15 15:14:25 -07:00
Aaron Patterson
66556631f5 pass the chain the join_constraints 2013-10-15 15:11:52 -07:00
Aaron Patterson
5c7633cd30 Merge branch 'master' into joindep
* master:
  use the cached arel table
  Fix typo in the changelog entry
  Don't remove the select values to add they back again
  Pluck on NullRelation accepts a list of columns

Conflicts:
	activerecord/lib/active_record/relation/finder_methods.rb
2013-10-15 14:54:31 -07:00
Aaron Patterson
f6e7e11ad2 use the cached arel table 2013-10-15 14:54:07 -07:00
Aaron Patterson
ee46f1d5d2 Merge branch 'master' into joindep
* master: (44 commits)
  grammar fix (reverted in e9a1ecd)
  Revert "fixed a doc bug in the CHANGELOG.md s/does no longer depend on/no longer depends on/"
  Add missed require making `enable_warnings` available
  Prepare generated Gemfile for Capistrano 3
  Added --model-name option scaffold_controller_generator.
  read the association instead of sending
  we should have unique sponsorable ids in the fixtures at least
  simplify populating the ordering hash
  the preloader for the RHS has all the preloaded records, so ask it
  only calculate offset index once. #12537
  Remove size alias for length validation
  Fix `singleton_class?`
  Minor Refactoring to `NumberHelper#number_to_human`
  `$SAFE = 4;` has been removed with Ruby 2.1
  scope_chain should not be mutated for other reflections
  Remove `default_primary_key_type`  and extract contains of `native_database_types` to a constant since they aren't conditional now in SQLite3Adapter. Makes it more like other adapters.
  cleanup changelog entry format. [ci skip]
  Extract a function to determine if the default value is a function
  Push default_function to superclass to avoid method check
  Dump the default function when the primary key is uuid
  ...

Conflicts:
	activerecord/lib/active_record/relation/finder_methods.rb
2013-10-15 14:45:00 -07:00
Rafael Mendonça França
ab9475bccf Don't remove the select values to add they back again
Conflicts:
	activerecord/lib/active_record/relation/finder_methods.rb
2013-10-15 18:02:25 -03:00
Rafael Mendonça França
9f80937e82 Merge pull request #12547 from derekprior/dp-fix-null-relation-pluck
Pluck on NullRelation should accept a list of columns
2013-10-15 12:09:46 -07:00
Vijay Dev
e3e3851ed6 grammar fix (reverted in e9a1ecd) 2013-10-15 23:34:59 +05:30
Derek Prior
23dfc39ed9 Pluck on NullRelation accepts a list of columns
`pluck` was updated to accept a list of columns, but the `NullRelation`
was never updated to match that signature. As a result, calling `pluck`
on a `NullRelation` results in an `ArgumentError`.
2013-10-15 13:11:43 -04:00
Aaron Patterson
704bf0ecc5 move column_names_with_alias on to the alias cache object 2013-10-14 18:59:29 -07:00
Aaron Patterson
3d7efb1627 this method does not exist anymore 2013-10-14 18:45:47 -07:00
Aaron Patterson
621c24323e keep a cache on the alias object 2013-10-14 18:37:18 -07:00
Aaron Patterson
a53c2beac4 move alias building to the table node 2013-10-14 18:26:34 -07:00
Aaron Patterson
a3a6313c1b let the Table class build the ARel alias nodes 2013-10-14 18:18:56 -07:00
Aaron Patterson
fc61df5a62 store aliases in a better structure 2013-10-14 18:10:43 -07:00
Aaron Patterson
4bf10fcdee remove delegation to chain 2013-10-14 17:47:43 -07:00
Aaron Patterson
6a2b43dccd rm JoinHelper from JoinAssociation 2013-10-14 17:43:15 -07:00
Aaron Patterson
396b1951fc read the association instead of sending 2013-10-14 17:30:29 -07:00
Aaron Patterson
e95bc57208 we should have unique sponsorable ids in the fixtures at least 2013-10-14 15:27:49 -07:00
Aaron Patterson
03c98bddfd simplify populating the ordering hash 2013-10-14 13:27:52 -07:00
Aaron Patterson
43a63f6d5e the preloader for the RHS has all the preloaded records, so ask it 2013-10-14 13:23:03 -07:00
Aaron Patterson
19b871a090 only calculate offset index once. #12537 2013-10-14 13:04:57 -07:00
Rafael Mendonça França
828134b756 Merge pull request #10538 from neerajdotname/3882
scope_chain should not be mutated for other reflections
2013-10-14 12:26:10 -07:00
Neeraj Singh
cd9592959f scope_chain should not be mutated for other reflections
Currently `scope_chain` uses same array for building different
`scope_chain` for different associations. During processing
these arrays are sometimes mutated and because of in-place
mutation the changed `scope_chain` impacts other reflections.

Fix is to dup the value before adding to the `scope_chain`.

Fixes #3882.
2013-10-14 11:59:59 -04:00
Rafael Mendonça França
ad590413b4 Merge pull request #12527 from vipulnsward/sqlite_database_types
SQLite3 Adapter datatypes cleanup
2013-10-14 08:58:44 -07:00
Vipul A M
4f381734e2 Remove default_primary_key_type and extract contains of native_database_types to a constant since they aren't conditional now in SQLite3Adapter. Makes it more like other adapters. 2013-10-14 21:09:06 +05:30
Rafael Mendonça França
25649c7fd7 Merge pull request #9499 from dmitry/inverse_instance_should_not_be_reloaded_after_stale_state_change
Inversed instance should not be reloaded after stale state was changed

Conflicts:
	activerecord/CHANGELOG.md
2013-10-14 12:17:40 -03:00
Rafael Mendonça França
c05f9558ee Merge pull request #11833 from vipulnsward/remove_autoincrement
Remove sqlite specific`supports_autoincrement?` which defaults to true
2013-10-14 07:48:45 -07:00
Yves Senn
a11ddbe55f cleanup changelog entry format. [ci skip] 2013-10-14 09:47:21 +02:00
Rafael Mendonça França
5b144233e9 Extract a function to determine if the default value is a function 2013-10-14 01:46:45 -03:00
Rafael Mendonça França
c921db9484 Push default_function to superclass to avoid method check 2013-10-14 01:46:41 -03:00
Rafael Mendonça França
9541a72858 Dump the default function when the primary key is uuid
Fixes #12489
2013-10-14 01:46:35 -03:00
Aaron Patterson
71250a5ae5 unhook join_constraints from the @tables ivar 2013-10-13 18:01:18 -07:00
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