sqldsl 1.4.1 → 1.4.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README +5 -5
- data/lib/inner_join_builder.rb +2 -2
- data/lib/select.rb +11 -8
- data/rakefile.rb +1 -1
- data/test/inner_join_builder_test.rb +1 -1
- data/test/select_acceptance_test.rb +2 -3
- metadata +2 -2
data/README
CHANGED
@@ -154,10 +154,9 @@ See the tests for more examples
|
|
154
154
|
end
|
155
155
|
|
156
156
|
def test_select_with_inner_join
|
157
|
-
expected = "select * from t1 a inner join t2 b on a.id = b.id
|
158
|
-
statement = Select.all.from[:t1.as(:a)].inner_join[:t2.as(:b)].on do
|
157
|
+
expected = "select * from t1 a inner join t2 b, t3 c on a.id = b.id and b.id2 = c.id where c.attr1 = 'foo' and b.attr1 = 'foo2'"
|
158
|
+
statement = Select.all.from[:t1.as(:a)].inner_join[:t2.as(:b), :t3.as(:c)].on do
|
159
159
|
a.id == b.id
|
160
|
-
end.inner_join[:t3.as(:c)].on do
|
161
160
|
b.id2 == c.id
|
162
161
|
end.where do
|
163
162
|
c.attr1 == 'foo'
|
@@ -195,5 +194,6 @@ See the tests for more examples
|
|
195
194
|
end
|
196
195
|
|
197
196
|
=== Contributors
|
198
|
-
Matt Deiters[http://www.theagiledeveloper.com]
|
199
|
-
|
197
|
+
Matt[http://www.theagiledeveloper.com] Deiters[http://www.theagiledeveloper.com]
|
198
|
+
|
199
|
+
Sergio[http://spejman-on-rails.blogspot.com/] Espeja[http://spejman-on-rails.blogspot.com/]
|
data/lib/inner_join_builder.rb
CHANGED
data/lib/select.rb
CHANGED
@@ -78,15 +78,18 @@ class Select < SqlStatement
|
|
78
78
|
InnerJoinBuilder.new(self)
|
79
79
|
end
|
80
80
|
|
81
|
-
def inner_join_table(
|
81
|
+
def inner_join_table(*table_names) #:nodoc:
|
82
82
|
@to_sql << " inner join "
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
83
|
+
table_names.flatten!
|
84
|
+
@to_sql += table_names.inject([]) do |result, element|
|
85
|
+
if element.to_s =~ / as /
|
86
|
+
@tables << element.to_s.split(/ as /).last.to_sym
|
87
|
+
result << element.to_s.gsub(/ as /, " ").to_sym
|
88
|
+
else
|
89
|
+
@tables << element
|
90
|
+
result << element
|
91
|
+
end
|
92
|
+
end.to_sql
|
90
93
|
self
|
91
94
|
end
|
92
95
|
|
data/rakefile.rb
CHANGED
@@ -27,7 +27,7 @@ Gem::manage_gems
|
|
27
27
|
specification = Gem::Specification.new do |s|
|
28
28
|
s.name = "sqldsl"
|
29
29
|
s.summary = "A DSL for creating SQL Statements"
|
30
|
-
s.version = "1.4.
|
30
|
+
s.version = "1.4.2"
|
31
31
|
s.author = 'Jay Fields'
|
32
32
|
s.description = "A DSL for creating SQL Statements"
|
33
33
|
s.email = 'sqldsl-developer@rubyforge.org'
|
@@ -3,7 +3,7 @@ require File.dirname(__FILE__) + '/test_helper'
|
|
3
3
|
class InnerJoinBuilderTest < Test::Unit::TestCase
|
4
4
|
def test_add_tables
|
5
5
|
ij = InnerJoinBuilder.new(s_builder = mock)
|
6
|
-
s_builder.expects(:inner_join_table).with(:"table1 as foo")
|
6
|
+
s_builder.expects(:inner_join_table).with([:"table1 as foo"])
|
7
7
|
ij[:table1.as(:foo)]
|
8
8
|
end
|
9
9
|
end
|
@@ -77,10 +77,9 @@ class SelectAcceptanceTest < Test::Unit::TestCase
|
|
77
77
|
end
|
78
78
|
|
79
79
|
def test_select_with_inner_join
|
80
|
-
expected = "select * from t1 a inner join t2 b on a.id = b.id
|
81
|
-
statement = Select.all.from[:t1.as(:a)].inner_join[:t2.as(:b)].on do
|
80
|
+
expected = "select * from t1 a inner join t2 b, t3 c on a.id = b.id and b.id2 = c.id where c.attr1 = 'foo' and b.attr1 = 'foo2'"
|
81
|
+
statement = Select.all.from[:t1.as(:a)].inner_join[:t2.as(:b), :t3.as(:c)].on do
|
82
82
|
a.id == b.id
|
83
|
-
end.inner_join[:t3.as(:c)].on do
|
84
83
|
b.id2 == c.id
|
85
84
|
end.where do
|
86
85
|
c.attr1 == 'foo'
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.8.11
|
|
3
3
|
specification_version: 1
|
4
4
|
name: sqldsl
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 1.4.
|
7
|
-
date: 2007-03-
|
6
|
+
version: 1.4.2
|
7
|
+
date: 2007-03-26 00:00:00 -04:00
|
8
8
|
summary: A DSL for creating SQL Statements
|
9
9
|
require_paths:
|
10
10
|
- lib
|