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

renamed ion classes

This commit is contained in:
Nick Kallen 2008-05-19 13:57:21 -07:00
parent 3eae3b08ee
commit 518db17ca3
13 changed files with 37 additions and 36 deletions

View file

@ -1,5 +1,4 @@
todo:
- rename select to where
- and/or w/ predicates
- blocks for all operations
- result sets to attr correlation too
@ -18,7 +17,7 @@ done:
. Attribute == Attribute -> EqualityPredicate
. Attribute >= Attribute -> GreaterThanOrEqualToPredicate
. Relation.include?(Column) -> Predicate
. Relation.project(*Column) -> ProjectionRelation
. Relation.project(*Column) -> ProjectRelation
. Relation.select(*Predicate) -> SelectionRelation
. Relation.order(*Column) -> OrderRelation
. #to_sql
@ -67,6 +66,8 @@ done:
- All Sql Strategies should be accumulations with the top-level relation?
- instance methodify externalize
- test: find_attribute_given_attribute and all @attribute ||= everywhere and memoization of table class.
- rename select to where
- rename all ion classes
icebox:
- #bind in Attribute and Expression should be doing a descend?

View file

@ -6,14 +6,14 @@ require 'arel/relations/writing'
require 'arel/relations/table'
require 'arel/relations/aggregation'
require 'arel/relations/join'
require 'arel/relations/grouping'
require 'arel/relations/projection'
require 'arel/relations/group'
require 'arel/relations/project'
require 'arel/relations/where'
require 'arel/relations/order'
require 'arel/relations/take'
require 'arel/relations/skip'
require 'arel/relations/deletion'
require 'arel/relations/insertion'
require 'arel/relations/delete'
require 'arel/relations/insert'
require 'arel/relations/update'
require 'arel/relations/alias'
require 'arel/sessions/session'

View file

@ -1,5 +1,5 @@
module Arel
class Grouping < Compound
class Group < Compound
attr_reader :groupings
def initialize(relation, *groupings)
@ -7,7 +7,7 @@ module Arel
end
def ==(other)
Grouping === other and
Group === other and
relation == other.relation and
groupings == other.groupings
end

View file

@ -1,5 +1,5 @@
module Arel
class Insertion < Writing
class Insert < Writing
attr_reader :record
def initialize(relation, record)
@ -20,7 +20,7 @@ module Arel
end
def ==(other)
Insertion === other and
Insert === other and
relation == other.relation and
record == other.record
end

View file

@ -1,5 +1,5 @@
module Arel
class Projection < Compound
class Project < Compound
attr_reader :projections
def initialize(relation, *projections)
@ -15,7 +15,7 @@ module Arel
end
def ==(other)
Projection === other and
Project === other and
relation == other.relation and
projections == other.projections
end

View file

@ -77,7 +77,7 @@ module Arel
end
def project(*attributes)
attributes.all?(&:blank?) ? self : Projection.new(self, *attributes)
attributes.all?(&:blank?) ? self : Project.new(self, *attributes)
end
def alias
@ -97,12 +97,12 @@ module Arel
end
def group(*groupings)
groupings.all?(&:blank?) ? self : Grouping.new(self, *groupings)
groupings.all?(&:blank?) ? self : Group.new(self, *groupings)
end
module Writable
def insert(record)
session.create Insertion.new(self, record); self
session.create Insert.new(self, record); self
end
def update(assignments)

View file

@ -1,7 +1,7 @@
require File.join(File.dirname(__FILE__), '..', '..', '..', 'spec_helper')
module Arel
describe Grouping do
describe Group do
before do
@relation = Table.new(:users)
@attribute = @relation[:id]
@ -10,7 +10,7 @@ module Arel
describe '#to_sql' do
describe 'when given a predicate' do
it "manufactures sql with where clause conditions" do
Grouping.new(@relation, @attribute).to_sql.should be_like("
Group.new(@relation, @attribute).to_sql.should be_like("
SELECT `users`.`id`, `users`.`name`
FROM `users`
GROUP BY `users`.`id`
@ -20,7 +20,7 @@ module Arel
describe 'when given a string' do
it "passes the string through to the where clause" do
Grouping.new(@relation, 'asdf').to_sql.should be_like("
Group.new(@relation, 'asdf').to_sql.should be_like("
SELECT `users`.`id`, `users`.`name`
FROM `users`
GROUP BY asdf

View file

@ -1,7 +1,7 @@
require File.join(File.dirname(__FILE__), '..', '..', '..', 'spec_helper')
module Arel
describe Insertion do
describe Insert do
before do
@relation = Table.new(:users)
end
@ -9,7 +9,7 @@ module Arel
describe '#to_sql' do
it 'manufactures sql inserting data when given multiple rows' do
pending 'it should insert multiple rows'
@insertion = Insertion.new(@relation, [@relation[:name] => "nick", @relation[:name] => "bryan"])
@insertion = Insert.new(@relation, [@relation[:name] => "nick", @relation[:name] => "bryan"])
@insertion.to_sql.should be_like("
INSERT
@ -19,7 +19,7 @@ module Arel
end
it 'manufactures sql inserting data when given multiple values' do
@insertion = Insertion.new(@relation, @relation[:id] => "1", @relation[:name] => "nick")
@insertion = Insert.new(@relation, @relation[:id] => "1", @relation[:name] => "nick")
@insertion.to_sql.should be_like("
INSERT
@ -30,7 +30,7 @@ module Arel
describe 'when given values whose types correspond to the types of the attributes' do
before do
@insertion = Insertion.new(@relation, @relation[:name] => "nick")
@insertion = Insert.new(@relation, @relation[:name] => "nick")
end
it 'manufactures sql inserting data' do
@ -44,7 +44,7 @@ module Arel
describe 'when given values whose types differ from from the types of the attributes' do
before do
@insertion = Insertion.new(@relation, @relation[:id] => '1-asdf')
@insertion = Insert.new(@relation, @relation[:id] => '1-asdf')
end
it 'manufactures sql inserting data' do
@ -59,7 +59,7 @@ module Arel
describe '#call' do
before do
@insertion = Insertion.new(@relation, @relation[:name] => "nick")
@insertion = Insert.new(@relation, @relation[:name] => "nick")
end
it 'executes an insert on the connection' do

View file

@ -1,7 +1,7 @@
require File.join(File.dirname(__FILE__), '..', '..', '..', 'spec_helper')
module Arel
describe Projection do
describe Project do
before do
@relation = Table.new(:users)
@attribute = @relation[:id]
@ -9,7 +9,7 @@ module Arel
describe '#attributes' do
before do
@projection = Projection.new(@relation, @attribute)
@projection = Project.new(@relation, @attribute)
end
it "manufactures attributes associated with the projection relation" do
@ -20,7 +20,7 @@ module Arel
describe '#to_sql' do
describe 'when given an attribute' do
it "manufactures sql with a limited select clause" do
Projection.new(@relation, @attribute).to_sql.should be_like("
Project.new(@relation, @attribute).to_sql.should be_like("
SELECT `users`.`id`
FROM `users`
")
@ -29,11 +29,11 @@ module Arel
describe 'when given a relation' do
before do
@scalar_relation = Projection.new(@relation, @relation[:name])
@scalar_relation = Project.new(@relation, @relation[:name])
end
it "manufactures sql with scalar selects" do
Projection.new(@relation, @scalar_relation).to_sql.should be_like("
Project.new(@relation, @scalar_relation).to_sql.should be_like("
SELECT (SELECT `users`.`name` FROM `users`) AS `users` FROM `users`
")
end
@ -41,7 +41,7 @@ module Arel
describe 'when given a string' do
it "passes the string through to the select clause" do
Projection.new(@relation, 'asdf').to_sql.should be_like("
Project.new(@relation, 'asdf').to_sql.should be_like("
SELECT asdf FROM `users`
")
end
@ -60,13 +60,13 @@ module Arel
describe '#aggregation?' do
describe 'when the projections are attributes' do
it 'returns false' do
Projection.new(@relation, @attribute).should_not be_aggregation
Project.new(@relation, @attribute).should_not be_aggregation
end
end
describe 'when the projections include an aggregation' do
it "obtains" do
Projection.new(@relation, @attribute.sum).should be_aggregation
Project.new(@relation, @attribute.sum).should be_aggregation
end
end
end

View file

@ -62,7 +62,7 @@ module Arel
describe '#project' do
it "manufactures a projection relation" do
@relation.project(@attribute1, @attribute2). \
should == Projection.new(@relation, @attribute1, @attribute2)
should == Project.new(@relation, @attribute1, @attribute2)
end
describe "when given blank attributes" do
@ -136,7 +136,7 @@ module Arel
describe '#group' do
it 'manufactures a group relation' do
@relation.group(@attribute1, @attribute2).should == Grouping.new(@relation, @attribute1, @attribute2)
@relation.group(@attribute1, @attribute2).should == Group.new(@relation, @attribute1, @attribute2)
end
describe 'when given blank groupings' do
@ -160,7 +160,7 @@ module Arel
it 'manufactures an insertion relation' do
Session.start do
record = {@relation[:name] => 'carl'}
mock(Session.new).create(Insertion.new(@relation, record))
mock(Session.new).create(Insert.new(@relation, record))
@relation.insert(record).should == @relation
end
end

View file

@ -32,7 +32,7 @@ module Arel
describe Session::CRUD do
before do
@insert = Insertion.new(@relation, @relation[:name] => 'nick')
@insert = Insert.new(@relation, @relation[:name] => 'nick')
@update = Update.new(@relation, @relation[:name] => 'nick')
@delete = Deletion.new(@relation)
@read = @relation