sqldsl 1.1.0 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
1
  class DistinctSelect < Select #:nodoc:
2
2
  class << self
3
3
  def [](*columns)
4
- self.new("select distinct #{create_columns_list(columns)}")
4
+ self.new("select distinct #{columns.to_sql}")
5
5
  end
6
6
  end
7
7
  end
data/lib/select.rb CHANGED
@@ -6,11 +6,7 @@ class Select < SqlStatement
6
6
  #
7
7
  # Select[1, :column1, 'book'].to_sql #=> "select 1, column1, 'book'"
8
8
  def [](*columns)
9
- self.new("select #{create_columns_list(columns)}")
10
- end
11
-
12
- def create_columns_list(columns) #:nodoc:
13
- columns.collect{ |column| column.to_sql }.join(', ')
9
+ self.new("select #{columns.to_sql}")
14
10
  end
15
11
 
16
12
  # call-seq: Select.distinct -> a_select
@@ -21,6 +17,15 @@ class Select < SqlStatement
21
17
  def distinct
22
18
  DistinctSelect
23
19
  end
20
+
21
+ # call-seq: Select[arg,...] -> a_select
22
+ #
23
+ # Returns a Select instance with the SQL initialized to 'select *'
24
+ #
25
+ # Select.all.to_sql #=> "select *"
26
+ def all
27
+ self.new("select *")
28
+ end
24
29
 
25
30
  end
26
31
 
@@ -40,7 +45,7 @@ class Select < SqlStatement
40
45
  #
41
46
  # Select[1, :column1, 'book'].from[:table1, :table2].to_sql #=> "select 1, column1, 'book' from table1, table2"
42
47
  def [](*table_names)
43
- @to_sql += table_names.sort{ |x,y| x.to_s <=> y.to_s }.collect{ |table| table.to_s }.sort.join(', ')
48
+ @to_sql += table_names.sort{ |x,y| x.to_s <=> y.to_s }.to_sql
44
49
  self
45
50
  end
46
51
 
data/rakefile.rb CHANGED
@@ -27,7 +27,7 @@ Gem::manage_gems
27
27
  specification = Gem::Specification.new do |s|
28
28
  s.name = "sqldsl"
29
29
  s.summary = "A DSL for creating SQL Statements"
30
- s.version = "1.1.0"
30
+ s.version = "1.1.1"
31
31
  s.author = 'Jay Fields'
32
32
  s.description = "A DSL for creating SQL Statements"
33
33
  s.email = 'sqldsl-developer@rubyforge.org'
data/test/select_test.rb CHANGED
@@ -43,4 +43,12 @@ class SelectTest < Test::Unit::TestCase
43
43
  assert_equal 'select column1 as foo, column2 as bar', Select[:column1 => :foo, :column2 => :bar].to_sql
44
44
  end
45
45
 
46
+ def test_table_aliasing
47
+ assert_equal 'select * from table1 as foo, table2 as bar', Select.all.from[:table1 => :foo, :table2 => :bar].to_sql
48
+ end
49
+
50
+ def test_select_all
51
+ assert_equal 'select *', Select.all.to_sql
52
+ end
53
+
46
54
  end
metadata CHANGED
@@ -3,7 +3,7 @@ rubygems_version: 0.9.0
3
3
  specification_version: 1
4
4
  name: sqldsl
5
5
  version: !ruby/object:Gem::Version
6
- version: 1.1.0
6
+ version: 1.1.1
7
7
  date: 2007-03-01 00:00:00 -05:00
8
8
  summary: A DSL for creating SQL Statements
9
9
  require_paths: