aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorNick Kallen <nkallen@nick-kallens-computer-2.local>2007-12-30 17:35:23 -0800
committerNick Kallen <nkallen@nick-kallens-computer-2.local>2007-12-30 17:35:23 -0800
commit1a59c8cbc90d37fa571c12049d0e43aa44d46388 (patch)
tree021bcf5e92274cfcbbd43541b1ab4e57a6a8275e /lib
parent63b9c6a41f7ab92a16362a50b60bcea7e20cb427 (diff)
downloadrails-1a59c8cbc90d37fa571c12049d0e43aa44d46388.tar.gz
rails-1a59c8cbc90d37fa571c12049d0e43aa44d46388.tar.bz2
rails-1a59c8cbc90d37fa571c12049d0e43aa44d46388.zip
sql builder
Diffstat (limited to 'lib')
-rw-r--r--lib/sql_algebra.rb3
-rw-r--r--lib/sql_algebra/relations/table_relation.rb5
-rw-r--r--lib/sql_algebra/sql/select.rb23
3 files changed, 6 insertions, 25 deletions
diff --git a/lib/sql_algebra.rb b/lib/sql_algebra.rb
index 8adbed150d..79bdc8a449 100644
--- a/lib/sql_algebra.rb
+++ b/lib/sql_algebra.rb
@@ -29,4 +29,5 @@ require 'sql_algebra/predicates/match_predicate'
require 'sql_algebra/extensions/range'
-require 'sql_algebra/sql/select' \ No newline at end of file
+require 'sql_algebra/sql_builder/sql_builder'
+require 'sql_algebra/sql_builder/select_builder' \ No newline at end of file
diff --git a/lib/sql_algebra/relations/table_relation.rb b/lib/sql_algebra/relations/table_relation.rb
index dd4987c3e1..17cdbab61a 100644
--- a/lib/sql_algebra/relations/table_relation.rb
+++ b/lib/sql_algebra/relations/table_relation.rb
@@ -6,6 +6,9 @@ class TableRelation < Relation
end
def to_sql
- Select.new(:*).from(table)
+ SelectBuilder.new do
+ select :*
+ from table
+ end
end
end \ No newline at end of file
diff --git a/lib/sql_algebra/sql/select.rb b/lib/sql_algebra/sql/select.rb
deleted file mode 100644
index da92ad3a52..0000000000
--- a/lib/sql_algebra/sql/select.rb
+++ /dev/null
@@ -1,23 +0,0 @@
-class Select
- attr_reader :attributes, :tables, :predicates
-
- def initialize(*attributes)
- @attributes = attributes
- end
-
- def from(*tables)
- returning self do |select|
- @tables = tables
- end
- end
-
- def where(*predicates)
- returning self do |select|
- @predicates = predicates
- end
- end
-
- def ==(other)
- attributes == other.attributes and tables == other.tables and predicates == other.predicates
- end
-end \ No newline at end of file