1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

removed bind for insertion and updation

This commit is contained in:
Nick Kallen 2008-04-11 13:55:17 -07:00
parent e6f6fbc5c7
commit 8887dcce12
6 changed files with 14 additions and 14 deletions

View file

@ -3,7 +3,7 @@ module ActiveRelation
attr_reader :record attr_reader :record
def initialize(relation, record) def initialize(relation, record)
@relation, @record = relation, record @relation, @record = relation, record.bind(relation)
end end
def to_sql(formatter = nil) def to_sql(formatter = nil)

View file

@ -63,11 +63,11 @@ module ActiveRelation
module Writes module Writes
def insert(record) def insert(record)
session.create Insertion.new(self, record.bind(self)); self session.create Insertion.new(self, record); self
end end
def update(assignments) def update(assignments)
session.update Update.new(self, assignments.bind(self)); self session.update Update.new(self, assignments); self
end end
def delete def delete

View file

@ -3,7 +3,7 @@ module ActiveRelation
attr_reader :assignments attr_reader :assignments
def initialize(relation, assignments) def initialize(relation, assignments)
@relation, @assignments = relation, assignments @relation, @assignments = relation, assignments.bind(relation)
end end
def to_sql(formatter = nil) def to_sql(formatter = nil)

View file

@ -9,7 +9,7 @@ module ActiveRelation
describe '#to_sql' do describe '#to_sql' do
describe 'when given values whose types correspond to the types of the attributes' do describe 'when given values whose types correspond to the types of the attributes' do
before do before do
@insertion = Insertion.new(@relation, @relation[:name] => "nick".bind(@relation)) @insertion = Insertion.new(@relation, @relation[:name] => "nick")
end end
it 'manufactures sql inserting data' do it 'manufactures sql inserting data' do
@ -23,7 +23,7 @@ module ActiveRelation
describe 'when given values whose types differ from from the types of the attributes' do describe 'when given values whose types differ from from the types of the attributes' do
before do before do
@insertion = Insertion.new(@relation, @relation[:id] => '1-asdf'.bind(@relation)) @insertion = Insertion.new(@relation, @relation[:id] => '1-asdf')
end end
it 'manufactures sql inserting data' do it 'manufactures sql inserting data' do
@ -37,7 +37,7 @@ module ActiveRelation
describe 'when given values whose types correspond to the type of the attribtues' do describe 'when given values whose types correspond to the type of the attribtues' do
before do before do
@insertion = Insertion.new(@relation, @relation[:name] => "nick".bind(@relation)) @insertion = Insertion.new(@relation, @relation[:name] => "nick")
end end
it 'manufactures sql inserting data' do it 'manufactures sql inserting data' do
@ -52,7 +52,7 @@ module ActiveRelation
describe '#call' do describe '#call' do
before do before do
@insertion = Insertion.new(@relation, @relation[:name] => "nick".bind(@relation)) @insertion = Insertion.new(@relation, @relation[:name] => "nick")
end end
it 'executes an insert on the connection' do it 'executes an insert on the connection' do

View file

@ -138,7 +138,7 @@ module ActiveRelation
it 'manufactures an insertion relation' do it 'manufactures an insertion relation' do
Session.start do Session.start do
record = {@relation[:name] => 'carl'} record = {@relation[:name] => 'carl'}
mock(Session.new).create(Insertion.new(@relation, record.bind(@relation))) mock(Session.new).create(Insertion.new(@relation, record))
@relation.insert(record).should == @relation @relation.insert(record).should == @relation
end end
end end
@ -148,7 +148,7 @@ module ActiveRelation
it 'manufactures an update relation' do it 'manufactures an update relation' do
Session.start do Session.start do
assignments = {@relation[:name] => Value.new('bob', @relation)} assignments = {@relation[:name] => Value.new('bob', @relation)}
mock(Session.new).update(Update.new(@relation, assignments.bind(@relation))) mock(Session.new).update(Update.new(@relation, assignments))
@relation.update(assignments).should == @relation @relation.update(assignments).should == @relation
end end
end end

View file

@ -9,7 +9,7 @@ module ActiveRelation
describe '#to_sql' do describe '#to_sql' do
describe 'when given values whose types correspond to the types of the attributes' do describe 'when given values whose types correspond to the types of the attributes' do
before do before do
@update = Update.new(@relation, @relation[:name] => "nick".bind(@relation)) @update = Update.new(@relation, @relation[:name] => "nick")
end end
it 'manufactures sql updating attributes' do it 'manufactures sql updating attributes' do
@ -22,7 +22,7 @@ module ActiveRelation
describe 'when given values whose types differ from from the types of the attributes' do describe 'when given values whose types differ from from the types of the attributes' do
before do before do
@update = Update.new(@relation, @relation[:id] => '1-asdf'.bind(@relation)) @update = Update.new(@relation, @relation[:id] => '1-asdf')
end end
it 'manufactures sql updating attributes' do it 'manufactures sql updating attributes' do
@ -37,7 +37,7 @@ module ActiveRelation
before do before do
@update = Update.new( @update = Update.new(
@relation.select(@relation[:id].eq(1)), @relation.select(@relation[:id].eq(1)),
@relation[:name] => "nick".bind(@relation) @relation[:name] => "nick"
) )
end end
@ -53,7 +53,7 @@ module ActiveRelation
describe '#call' do describe '#call' do
before do before do
@update = Update.new(@relation, @relation[:name] => "nick".bind(@relation)) @update = Update.new(@relation, @relation[:name] => "nick")
end end
it 'executes an update on the connection' do it 'executes an update on the connection' do