qreport 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -24,19 +24,19 @@ module Qreport
24
24
 
25
25
  Connection.current = connection
26
26
 
27
- conn.transaction do
28
- # Create a report row sequence:
29
- run "CREATE TEMPORARY SEQUENCE qr_row_seq"
30
- end
31
-
32
27
  # Rewrite query to create result table rows:
33
28
  self.arguments = arguments.merge(:qr_run_id => conn.safe_sql("nextval('qr_row_seq')"))
34
29
  report_run.report_sql = report_sql(sql)
35
30
 
31
+ conn.transaction do
32
+ # Create a report row sequence:
33
+ run "DROP SEQUENCE IF EXISTS qr_row_seq"
34
+ run "CREATE TEMPORARY SEQUENCE qr_row_seq"
36
35
  # Infer base columns, if not specified.
37
36
  if report_run.base_columns.empty?
38
37
  infer_base_columns!
39
38
  end
39
+ end
40
40
 
41
41
  # Construct report_table name from column names and types:
42
42
  report_table = report_run.report_table
@@ -53,6 +53,10 @@ module Qreport
53
53
  # Run query into report table:
54
54
  begin
55
55
  conn.transaction do
56
+ # Create a report row sequence:
57
+ run "DROP SEQUENCE IF EXISTS qr_row_seq"
58
+ run "CREATE TEMPORARY SEQUENCE qr_row_seq"
59
+
56
60
  unless conn.table_exists? report_table
57
61
  result =
58
62
  run "CREATE TABLE #{report_table} AS #{report_run.report_sql}", :arguments => arguments, :verbose => @verbose
@@ -77,6 +81,8 @@ module Qreport
77
81
  result = report_run._select :COLUMNS => 'COUNT(*) AS "nrows"' #, :verbose => true
78
82
  nrows = result.rows[0]["nrows"] || (raise Error, "cannot determine nrows")
79
83
  end
84
+
85
+ run "DROP SEQUENCE IF EXISTS qr_row_seq"
80
86
  # pp result
81
87
  result = nil
82
88
  end # transaction
@@ -86,7 +92,7 @@ module Qreport
86
92
  end
87
93
 
88
94
  conn.transaction do
89
- run "DROP SEQUENCE qr_row_seq" unless error_1
95
+ run "DROP SEQUENCE IF EXISTS qr_row_seq"
90
96
 
91
97
  # Update stats:
92
98
  report_run.finished_at = Time.now.utc
@@ -1,3 +1,3 @@
1
1
  module Qreport
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.7"
3
3
  end
data/qreport.gemspec CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |gem|
18
18
  gem.require_paths = ["lib"]
19
19
 
20
20
  gem.add_development_dependency 'rake', '>= 0.9.0'
21
- gem.add_development_dependency 'rspec', '~> 2.12'
21
+ gem.add_development_dependency 'rspec', '~> 2.13'
22
22
  gem.add_development_dependency 'simplecov', '~> 0.7.1'
23
23
  gem.add_development_dependency "guard", "~> 1.8.0"
24
24
  gem.add_development_dependency "guard-rspec", "~> 3.0.2"
@@ -98,11 +98,14 @@ describe Qreport::Connection do
98
98
  [ :a_symbol!, "'a_symbol!'", :a_symbol!.to_s ],
99
99
  [ Time.parse('2011-04-27T13:23:00.000000Z'), "'2011-04-27T13:23:00.000000Z'::timestamp", Time.parse('2011-04-27T13:23:00.000000') ],
100
100
  [ Time.parse('2011-04-27 13:23:00 -0500'), "'2011-04-27T13:23:00.000000-05:00'::timestamp", Time.parse('2011-04-27 13:23:00 -0500') ],
101
+ [ [ 1, "2", :three ], "'[1,\"2\",\"three\"]'", :IGNORE ],
102
+ [ { :a => 1, "b" => 2 }, "'{\"a\":1,\"b\":2}'", :IGNORE ],
101
103
  ].each do | value, sql, return_value |
102
104
  it "can handle encoding #{value.class.name} value #{value.inspect} as #{sql.inspect}." do
103
105
  conn.escape_value(value).should == sql
104
106
  end
105
107
  it "can handle decoding #{value.class.name} value #{value.inspect}." do
108
+ pending :if => return_value == :IGNORE
106
109
  sql_x = conn.escape_value(value)
107
110
  r = conn.run "SELECT #{sql_x}"
108
111
  r = r.rows.first.values.first
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: qreport
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-07-09 00:00:00.000000000 Z
12
+ date: 2013-07-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -34,7 +34,7 @@ dependencies:
34
34
  requirements:
35
35
  - - ~>
36
36
  - !ruby/object:Gem::Version
37
- version: '2.12'
37
+ version: '2.13'
38
38
  type: :development
39
39
  prerelease: false
40
40
  version_requirements: !ruby/object:Gem::Requirement
@@ -42,7 +42,7 @@ dependencies:
42
42
  requirements:
43
43
  - - ~>
44
44
  - !ruby/object:Gem::Version
45
- version: '2.12'
45
+ version: '2.13'
46
46
  - !ruby/object:Gem::Dependency
47
47
  name: simplecov
48
48
  requirement: !ruby/object:Gem::Requirement
@@ -162,12 +162,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
162
162
  - - ! '>='
163
163
  - !ruby/object:Gem::Version
164
164
  version: '0'
165
+ segments:
166
+ - 0
167
+ hash: 2296611255217817535
165
168
  required_rubygems_version: !ruby/object:Gem::Requirement
166
169
  none: false
167
170
  requirements:
168
171
  - - ! '>='
169
172
  - !ruby/object:Gem::Version
170
173
  version: '0'
174
+ segments:
175
+ - 0
176
+ hash: 2296611255217817535
171
177
  requirements: []
172
178
  rubyforge_project:
173
179
  rubygems_version: 1.8.25