aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/sql_algebra/relations/relation.rb1
-rw-r--r--spec/integration/scratch_spec.rb5
-rw-r--r--spec/relations/join_relation_spec.rb2
-rw-r--r--spec/relations/order_relation_spec.rb2
-rw-r--r--spec/relations/projection_relation_spec.rb2
-rw-r--r--spec/relations/range_relation_spec.rb2
-rw-r--r--spec/relations/rename_relation_spec.rb2
-rw-r--r--spec/relations/selection_relation_spec.rb2
8 files changed, 10 insertions, 8 deletions
diff --git a/lib/sql_algebra/relations/relation.rb b/lib/sql_algebra/relations/relation.rb
index 82266fd7e8..13742cb570 100644
--- a/lib/sql_algebra/relations/relation.rb
+++ b/lib/sql_algebra/relations/relation.rb
@@ -59,6 +59,7 @@ class Relation
end
end
end
+ delegate :to_s, :to => :to_sql
protected
def attributes; [] end
diff --git a/spec/integration/scratch_spec.rb b/spec/integration/scratch_spec.rb
index b19f1a5234..725ac755c0 100644
--- a/spec/integration/scratch_spec.rb
+++ b/spec/integration/scratch_spec.rb
@@ -11,7 +11,7 @@ describe 'Relational Algebra' do
end
it 'simulates User.has_many :photos' do
- @user_photos.project(*@photos.attributes).to_sql.to_s.should be_like("""
+ @user_photos.project(*@photos.attributes).to_s.should be_like("""
SELECT photos.id, photos.user_id, photos.camera_id
FROM users
LEFT OUTER JOIN photos
@@ -22,7 +22,7 @@ describe 'Relational Algebra' do
end
it 'simulates a User.has_many :cameras :through => :photos' do
- @user_cameras.project(*@cameras.attributes).to_sql.to_s.should be_like("""
+ @user_cameras.project(*@cameras.attributes).to_s.should be_like("""
SELECT cameras.id
FROM users
LEFT OUTER JOIN photos
@@ -35,6 +35,7 @@ describe 'Relational Algebra' do
end
it '' do
+ # @user_cameras.qualify.to_s
#
# @users.rename()
end
diff --git a/spec/relations/join_relation_spec.rb b/spec/relations/join_relation_spec.rb
index b7357b02e8..b70bf553b1 100644
--- a/spec/relations/join_relation_spec.rb
+++ b/spec/relations/join_relation_spec.rb
@@ -36,7 +36,7 @@ describe JoinRelation do
end
it 'manufactures sql joining the two tables on the predicate, merging the selects' do
- ConcreteJoinRelation.new(@relation1, @relation2, @predicate).to_sql.to_s.should == SelectBuilder.new do
+ ConcreteJoinRelation.new(@relation1, @relation2, @predicate).to_s.should == SelectBuilder.new do
select do
column :foo, :name
column :foo, :id
diff --git a/spec/relations/order_relation_spec.rb b/spec/relations/order_relation_spec.rb
index 8792683eec..a78ac148e2 100644
--- a/spec/relations/order_relation_spec.rb
+++ b/spec/relations/order_relation_spec.rb
@@ -25,7 +25,7 @@ describe OrderRelation do
describe '#to_sql' do
it "manufactures sql with an order clause" do
- OrderRelation.new(@relation1, @attribute1).to_sql.to_s.should == SelectBuilder.new do
+ OrderRelation.new(@relation1, @attribute1).to_s.should == SelectBuilder.new do
select do
column :foo, :name
column :foo, :id
diff --git a/spec/relations/projection_relation_spec.rb b/spec/relations/projection_relation_spec.rb
index 149669c5b2..5a33b16bd5 100644
--- a/spec/relations/projection_relation_spec.rb
+++ b/spec/relations/projection_relation_spec.rb
@@ -25,7 +25,7 @@ describe ProjectionRelation do
describe '#to_sql' do
it "manufactures sql with a limited select clause" do
- ProjectionRelation.new(@relation1, @attribute1).to_sql.to_s.should == SelectBuilder.new do
+ ProjectionRelation.new(@relation1, @attribute1).to_s.should == SelectBuilder.new do
select do
column :foo, :id
end
diff --git a/spec/relations/range_relation_spec.rb b/spec/relations/range_relation_spec.rb
index 947bf35120..926cc0929f 100644
--- a/spec/relations/range_relation_spec.rb
+++ b/spec/relations/range_relation_spec.rb
@@ -26,7 +26,7 @@ describe RangeRelation do
it "manufactures sql with limit and offset" do
range_size = @range2.last - @range2.first + 1
range_start = @range2.first
- RangeRelation.new(@relation1, @range2).to_sql.to_s.should == SelectBuilder.new do
+ RangeRelation.new(@relation1, @range2).to_s.should == SelectBuilder.new do
select do
column :foo, :name
column :foo, :id
diff --git a/spec/relations/rename_relation_spec.rb b/spec/relations/rename_relation_spec.rb
index 7db329ad7a..301ee6db9e 100644
--- a/spec/relations/rename_relation_spec.rb
+++ b/spec/relations/rename_relation_spec.rb
@@ -52,7 +52,7 @@ describe RenameRelation do
describe '#to_sql' do
it 'manufactures sql aliasing the attribute' do
- @renamed_relation.to_sql.to_s.should == SelectBuilder.new do
+ @renamed_relation.to_s.should == SelectBuilder.new do
select do
column :foo, :name
column :foo, :id, :schmid
diff --git a/spec/relations/selection_relation_spec.rb b/spec/relations/selection_relation_spec.rb
index 7ffb3b3676..656a386fd6 100644
--- a/spec/relations/selection_relation_spec.rb
+++ b/spec/relations/selection_relation_spec.rb
@@ -35,7 +35,7 @@ describe SelectionRelation do
describe '#to_sql' do
it "manufactures sql with where clause conditions" do
- SelectionRelation.new(@relation1, @predicate1).to_sql.to_s.should == SelectBuilder.new do
+ SelectionRelation.new(@relation1, @predicate1).to_s.should == SelectBuilder.new do
select do
column :foo, :name
column :foo, :id