fake_arel 1.3.0 → 1.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/fake_arel.gemspec +1 -1
- data/lib/fake_arel/with_scope_replacement.rb +16 -2
- data/spec/fake_arel_spec.rb +8 -1
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.3.
|
1
|
+
1.3.1
|
data/fake_arel.gemspec
CHANGED
@@ -3,8 +3,22 @@ module WithScopeReplacement
|
|
3
3
|
base.class_eval do
|
4
4
|
class << self
|
5
5
|
def to_sql
|
6
|
-
|
7
|
-
|
6
|
+
options = current_scoped_methods
|
7
|
+
join_dependency = JoinDependency.new(self, merge_includes(scope(:find, :include), nil), nil)
|
8
|
+
scope = scope(:find)
|
9
|
+
sql = "SELECT #{(scope && scope[:select]) || default_select(options[:joins] || (scope && scope[:joins]))} "
|
10
|
+
sql << join_dependency.join_associations.collect{|join| join.association_join }.join
|
11
|
+
|
12
|
+
add_joins!(sql, options[:joins], scope)
|
13
|
+
add_conditions!(sql, options[:conditions], scope)
|
14
|
+
add_limited_ids_condition!(sql, options, join_dependency) if !using_limitable_reflections?(join_dependency.reflections) && ((scope && scope[:limit]) || options[:limit])
|
15
|
+
|
16
|
+
add_group!(sql, options[:group], options[:having], scope)
|
17
|
+
add_order!(sql, options[:order], scope)
|
18
|
+
add_limit!(sql, options, scope) if using_limitable_reflections?(join_dependency.reflections)
|
19
|
+
add_lock!(sql, options, scope)
|
20
|
+
|
21
|
+
return sanitize_sql(sql)
|
8
22
|
end
|
9
23
|
|
10
24
|
def with_scope(method_scoping = {}, action = :merge, &block)
|
data/spec/fake_arel_spec.rb
CHANGED
@@ -51,9 +51,16 @@ describe "Fake Arel" do
|
|
51
51
|
end
|
52
52
|
|
53
53
|
it "should includes includes when including included includes" do
|
54
|
-
sql = Topic.includes(:replies
|
54
|
+
sql = Topic.includes(:replies).includes(:author).where("replies.id = 1").to_sql
|
55
55
|
p sql
|
56
56
|
sql.should =~ /JOIN "replies"/i
|
57
|
+
sql.should =~ /JOIN "authors"/i
|
58
|
+
end
|
59
|
+
|
60
|
+
it "should only include the selects we select" do
|
61
|
+
sql = Topic.select("topics.id").includes(:replies).where("replies.id = 1").to_sql
|
62
|
+
sql.should =~ /SELECT topics.id/
|
63
|
+
|
57
64
|
end
|
58
65
|
end
|
59
66
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fake_arel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 25
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 3
|
9
|
-
-
|
10
|
-
version: 1.3.
|
9
|
+
- 1
|
10
|
+
version: 1.3.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Grant Ammons
|