sqlstmt 0.1.9 → 0.1.10

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.
Files changed (2) hide show
  1. data/lib/sqlstmt/insert_select.rb +7 -1
  2. metadata +2 -2
@@ -13,6 +13,11 @@ class InsertSelect < FromQuery
13
13
  @into_table = nil
14
14
  end
15
15
 
16
+ def distinct
17
+ @distinct = true
18
+ self
19
+ end
20
+
16
21
  def into(table)
17
22
  @into_table = table
18
23
  self
@@ -26,9 +31,10 @@ private
26
31
  end
27
32
 
28
33
  def build_stmt
34
+ distinct_str = if @distinct then 'DISTINCT ' else '' end
29
35
  into_str = @fields.join(',')
30
36
  select_str = @values.join(',')
31
- "INSERT INTO #@into_table (#{into_str}) SELECT #{select_str}#{build_from_clause}"
37
+ "INSERT INTO #@into_table (#{into_str}) SELECT #{distinct_str}#{select_str}#{build_from_clause}"
32
38
  end
33
39
  end
34
40
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sqlstmt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.9
4
+ version: 0.1.10
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-05-10 00:00:00.000000000 Z
13
+ date: 2013-05-21 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: dohutil