diff options
author | Bryan Helmkamp <bryan@brynary.com> | 2009-05-17 15:47:10 -0400 |
---|---|---|
committer | Bryan Helmkamp <bryan@brynary.com> | 2009-05-17 15:47:10 -0400 |
commit | 07833d39c2885a5cddf38eeb860d79353c0f447b (patch) | |
tree | 5312d3ab6eefba0c936bb3b9a7bf2e879899af2e /lib | |
parent | 20b28b441b651d0404d64049253898c061a039be (diff) | |
download | rails-07833d39c2885a5cddf38eeb860d79353c0f447b.tar.gz rails-07833d39c2885a5cddf38eeb860d79353c0f447b.tar.bz2 rails-07833d39c2885a5cddf38eeb860d79353c0f447b.zip |
basic implementation of in memory insertions
Conflicts:
lib/arel/engines/memory/relations.rb
Diffstat (limited to 'lib')
-rw-r--r-- | lib/arel/algebra/relations/relation.rb | 2 | ||||
-rw-r--r-- | lib/arel/engines/memory/engine.rb | 4 | ||||
-rw-r--r-- | lib/arel/engines/memory/relations.rb | 1 | ||||
-rw-r--r-- | lib/arel/engines/memory/relations/writes.rb | 7 | ||||
-rw-r--r-- | lib/arel/session.rb | 3 |
5 files changed, 16 insertions, 1 deletions
diff --git a/lib/arel/algebra/relations/relation.rb b/lib/arel/algebra/relations/relation.rb index c38ab0e9c5..9fdac26528 100644 --- a/lib/arel/algebra/relations/relation.rb +++ b/lib/arel/algebra/relations/relation.rb @@ -57,7 +57,7 @@ module Arel module Writable def insert(record) - session.create Insert.new(self, record); self + session.create Insert.new(self, record) end def update(assignments) diff --git a/lib/arel/engines/memory/engine.rb b/lib/arel/engines/memory/engine.rb index 67a084f2cd..c8f79c9d57 100644 --- a/lib/arel/engines/memory/engine.rb +++ b/lib/arel/engines/memory/engine.rb @@ -5,6 +5,10 @@ module Arel def read(relation) relation.eval end + + def create(relation) + relation.eval + end end include CRUD end diff --git a/lib/arel/engines/memory/relations.rb b/lib/arel/engines/memory/relations.rb index 1b009537b9..c67af2d63b 100644 --- a/lib/arel/engines/memory/relations.rb +++ b/lib/arel/engines/memory/relations.rb @@ -1,4 +1,5 @@ require 'arel/engines/memory/relations/array' require 'arel/engines/memory/relations/operations' +require 'arel/engines/memory/relations/writes' require 'arel/engines/memory/relations/compound' diff --git a/lib/arel/engines/memory/relations/writes.rb b/lib/arel/engines/memory/relations/writes.rb new file mode 100644 index 0000000000..fa8b84a32c --- /dev/null +++ b/lib/arel/engines/memory/relations/writes.rb @@ -0,0 +1,7 @@ +module Arel + class Insert < Compound + def eval + unoperated_rows + [Row.new(self, record.values.collect(&:value))] + end + end +end
\ No newline at end of file diff --git a/lib/arel/session.rb b/lib/arel/session.rb index cf04e8a93a..921ad0a7ac 100644 --- a/lib/arel/session.rb +++ b/lib/arel/session.rb @@ -24,6 +24,7 @@ module Arel module CRUD def create(insert) insert.call + insert end def read(select) @@ -34,10 +35,12 @@ module Arel def update(update) update.call + update end def delete(delete) delete.call + delete end end include CRUD |