pg 0.14.1 → 0.15.0.pre.432

Sign up to get free protection for your applications and to get access to all the features.
@@ -44,6 +44,13 @@ describe PG::Result do
44
44
  res[0]['b'].should== '2'
45
45
  end
46
46
 
47
+ it "should yield a row as an array" do
48
+ res = @conn.exec("SELECT 1 AS a, 2 AS b")
49
+ list = []
50
+ res.each_row { |r| list << r }
51
+ list.should eq [['1', '2']]
52
+ end
53
+
47
54
  it "should insert nil AS NULL and return NULL as nil" do
48
55
  res = @conn.exec("SELECT $1::int AS n", [nil])
49
56
  res[0]['n'].should be_nil()
@@ -66,13 +73,14 @@ describe PG::Result do
66
73
  should == 'relation "nonexistant_table" does not exist'
67
74
  result.error_field( PG::PG_DIAG_MESSAGE_DETAIL ).should be_nil()
68
75
  result.error_field( PG::PG_DIAG_MESSAGE_HINT ).should be_nil()
69
- result.error_field( PG::PG_DIAG_STATEMENT_POSITION ).should == '15'
76
+ statement_pos = RSpec.configuration.exclusion_filter[:postgresql_90] ? nil : '15'
77
+ result.error_field( PG::PG_DIAG_STATEMENT_POSITION ).should == statement_pos
70
78
  result.error_field( PG::PG_DIAG_INTERNAL_POSITION ).should be_nil()
71
79
  result.error_field( PG::PG_DIAG_INTERNAL_QUERY ).should be_nil()
72
80
  result.error_field( PG::PG_DIAG_CONTEXT ).should be_nil()
73
- result.error_field( PG::PG_DIAG_SOURCE_FILE ).should =~ /parse_relation\.c$/
74
- result.error_field( PG::PG_DIAG_SOURCE_LINE ).should == '857'
75
- result.error_field( PG::PG_DIAG_SOURCE_FUNCTION ).should == 'parserOpenTable'
81
+ result.error_field( PG::PG_DIAG_SOURCE_FILE ).should =~ /parse_relation\.c$|namespace\.c$/
82
+ result.error_field( PG::PG_DIAG_SOURCE_LINE ).should =~ /^\d+$/
83
+ result.error_field( PG::PG_DIAG_SOURCE_FUNCTION ).should =~ /^parserOpenTable$|^RangeVarGetRelid$/
76
84
 
77
85
  end
78
86
 
@@ -89,7 +97,7 @@ describe PG::Result do
89
97
  it "should return the same bytes in binary format that are sent in binary format" do
90
98
  binary_file = File.join(Dir.pwd, 'spec/data', 'random_binary_data')
91
99
  bytes = File.open(binary_file, 'rb').read
92
- res = @conn.exec('VALUES ($1::bytea)',
100
+ res = @conn.exec('VALUES ($1::bytea)',
93
101
  [ { :value => bytes, :format => 1 } ], 1)
94
102
  res[0]['column1'].should== bytes
95
103
  res.getvalue(0,0).should == bytes
@@ -111,7 +119,7 @@ describe PG::Result do
111
119
  it "should return the same bytes in text format that are sent in binary format" do
112
120
  binary_file = File.join(Dir.pwd, 'spec/data', 'random_binary_data')
113
121
  bytes = File.open(binary_file, 'rb').read
114
- res = @conn.exec('VALUES ($1::bytea)',
122
+ res = @conn.exec('VALUES ($1::bytea)',
115
123
  [ { :value => bytes, :format => 1 } ])
116
124
  PG::Connection.unescape_bytea(res[0]['column1']).should== bytes
117
125
  end
@@ -127,8 +135,8 @@ describe PG::Result do
127
135
  out_bytes.should == in_bytes
128
136
  end
129
137
 
130
- it "should return the parameter type of the specified prepared statement parameter" do
131
- query = 'SELECT * FROM pg_stat_activity WHERE user = $1::name AND current_query = $2::text'
138
+ it "should return the parameter type of the specified prepared statement parameter", :postgresql_92 do
139
+ query = 'SELECT * FROM pg_stat_activity WHERE user = $1::name AND query = $2::text'
132
140
  @conn.prepare( 'queryfinder', query )
133
141
  res = @conn.describe_prepared( 'queryfinder' )
134
142
 
@@ -260,4 +268,11 @@ describe PG::Result do
260
268
  }.to raise_error( PG::Error, /relation "nonexistant_table" does not exist/ )
261
269
  end
262
270
 
271
+ it "can return the values of a single field" do
272
+ res = @conn.exec( "SELECT 1 AS x, 'a' AS y UNION ALL SELECT 2, 'b'" )
273
+ res.field_values( 'x' ).should == ['1', '2']
274
+ res.field_values( 'y' ).should == ['a', 'b']
275
+ expect{ res.field_values( '' ) }.to raise_error(IndexError)
276
+ expect{ res.field_values( :x ) }.to raise_error(TypeError)
277
+ end
263
278
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pg
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.14.1
4
+ version: 0.15.0.pre.432
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -36,7 +36,7 @@ cert_chain:
36
36
  YUhDS0xaZFNLai9SSHVUT3QrZ2JsUmV4OEZBaDhOZUEKY21saFhlNDZwWk5K
37
37
  Z1dLYnhaYWg4NWpJang5NWhSOHZPSStOQU01aUg5a09xSzEzRHJ4YWNUS1Bo
38
38
  cWo1UGp3RgotLS0tLUVORCBDRVJUSUZJQ0FURS0tLS0tCg==
39
- date: 2012-09-02 00:00:00.000000000 Z
39
+ date: 2013-02-03 00:00:00.000000000 Z
40
40
  dependencies:
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: hoe-mercurial
@@ -125,7 +125,7 @@ dependencies:
125
125
  requirements:
126
126
  - - ~>
127
127
  - !ruby/object:Gem::Version
128
- version: '3.0'
128
+ version: '3.4'
129
129
  type: :development
130
130
  prerelease: false
131
131
  version_requirements: !ruby/object:Gem::Requirement
@@ -133,13 +133,13 @@ dependencies:
133
133
  requirements:
134
134
  - - ~>
135
135
  - !ruby/object:Gem::Version
136
- version: '3.0'
136
+ version: '3.4'
137
137
  description: ! "Pg is the Ruby interface to the {PostgreSQL RDBMS}[http://www.postgresql.org/].\n\nIt
138
138
  works with {PostgreSQL 8.3 and later}[http://bit.ly/6AfPhm].\n\nA small example
139
- usage:\n\n #!/usr/bin/env ruby\n \n require 'pg'\n \n # Output a table of current
139
+ usage:\n\n #!/usr/bin/env ruby\n\n require 'pg'\n\n # Output a table of current
140
140
  connections to the DB\n conn = PG.connect( dbname: 'sales' )\n conn.exec( \"SELECT
141
141
  * FROM pg_stat_activity\" ) do |result|\n puts \" PID | User |
142
- Query\"\n\tresult.each do |row|\n puts \" %7d | %-16s | %s \" %\n row.values_at('procpid',
142
+ Query\"\n result.each do |row|\n puts \" %7d | %-16s | %s \" %\n row.values_at('procpid',
143
143
  'usename', 'current_query')\n end\n end"
144
144
  email:
145
145
  - ged@FaerieMUD.org
@@ -156,6 +156,7 @@ extra_rdoc_files:
156
156
  - README.rdoc
157
157
  - POSTGRES
158
158
  - LICENSE
159
+ - ext/gvl_wrappers.c
159
160
  - ext/pg.c
160
161
  - ext/pg_connection.c
161
162
  - ext/pg_result.c
@@ -175,6 +176,8 @@ files:
175
176
  - Rakefile
176
177
  - Rakefile.cross
177
178
  - ext/extconf.rb
179
+ - ext/gvl_wrappers.c
180
+ - ext/gvl_wrappers.h
178
181
  - ext/pg.c
179
182
  - ext/pg.h
180
183
  - ext/pg_connection.c
@@ -187,6 +190,7 @@ files:
187
190
  - lib/pg/constants.rb
188
191
  - lib/pg/exceptions.rb
189
192
  - lib/pg/result.rb
193
+ - sample/array_insert.rb
190
194
  - sample/async_api.rb
191
195
  - sample/async_copyto.rb
192
196
  - sample/async_mixed.rb
@@ -239,7 +243,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
239
243
  version: '0'
240
244
  requirements: []
241
245
  rubyforge_project: pg
242
- rubygems_version: 1.8.24
246
+ rubygems_version: 1.8.25
243
247
  signing_key:
244
248
  specification_version: 3
245
249
  summary: Pg is the Ruby interface to the {PostgreSQL RDBMS}[http://www.postgresql.org/]
metadata.gz.sig CHANGED
Binary file