sequel_pg 1.6.0 → 1.6.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.
Files changed (4) hide show
  1. data/CHANGELOG +4 -0
  2. data/README.rdoc +7 -4
  3. data/ext/sequel_pg/sequel_pg.c +27 -10
  4. metadata +2 -2
data/CHANGELOG CHANGED
@@ -1,3 +1,7 @@
1
+ === 1.6.1 (2012-10-25)
2
+
3
+ * Make PostgreSQL array parser handle string encodings correctly on ruby 1.9 (jeremyevans)
4
+
1
5
  === 1.6.0 (2012-09-04)
2
6
 
3
7
  * Replace PQsetRowProcessor streaming with PQsetSingleRowMode streaming introduced in PostgreSQL 9.2beta3 (jeremyevans)
data/README.rdoc CHANGED
@@ -65,7 +65,7 @@ enable the model optimization via:
65
65
 
66
66
  == Streaming
67
67
 
68
- If you are using PostgreSQL 9.2 or higher on the client, then sequel_pg
68
+ If you are using PostgreSQL 9.2beta3 or higher on the client, then sequel_pg
69
69
  should enable streaming support. This allows you to stream returned
70
70
  rows one at a time, instead of collecting the entire result set in
71
71
  memory (which is how PostgreSQL works by default). You can check
@@ -76,8 +76,7 @@ if streaming is supported by:
76
76
  If streaming is supported, you can load the streaming support into the
77
77
  database:
78
78
 
79
- require 'sequel_pg/streaming'
80
- DB.extend Sequel::Postgres::Streaming
79
+ DB.extension(:pg_streaming)
81
80
 
82
81
  Then you can call the Dataset#stream method to have the dataset use
83
82
  the streaming support:
@@ -87,7 +86,11 @@ the streaming support:
87
86
  If you want to enable streaming for all of a database's datasets, you
88
87
  can do the following:
89
88
 
90
- DB.extend_datasets Sequel::Postgres::Streaming::AllQueries
89
+ DB.stream_all_queries = true
90
+
91
+ Note that pg 0.14.1+ is required for streaming to work. This is not
92
+ required by the gem, as it is only a requirement for streaming, not
93
+ for general use.
91
94
 
92
95
  == Installing the gem
93
96
 
@@ -120,7 +120,11 @@ static int enc_get_index(VALUE val)
120
120
  }
121
121
  #endif
122
122
 
123
- static VALUE read_array(int *index, char *c_pg_array_string, int array_string_length, char *word, VALUE converter)
123
+ static VALUE read_array(int *index, char *c_pg_array_string, int array_string_length, char *word, VALUE converter
124
+ #ifdef SPG_ENCODING
125
+ , int enc_index
126
+ #endif
127
+ )
124
128
  {
125
129
  int word_index = 0;
126
130
 
@@ -161,15 +165,20 @@ static VALUE read_array(int *index, char *c_pg_array_string, int array_string_le
161
165
  {
162
166
  rb_ary_push(array, Qnil);
163
167
  }
164
- else if (RTEST(converter))
168
+ else
165
169
  {
166
- VALUE rword = rb_str_new(word, word_index);
170
+ VALUE rword = rb_tainted_str_new(word, word_index);
167
171
  RB_GC_GUARD(rword);
168
- rb_ary_push(array, rb_funcall(converter, spg_id_call, 1, rword));
169
- }
170
- else
171
- {
172
- rb_ary_push(array, rb_str_new(word, word_index));
172
+
173
+ #ifdef SPG_ENCODING
174
+ rb_enc_associate_index(rword, enc_index);
175
+ #endif
176
+
177
+ if (RTEST(converter)) {
178
+ rword = rb_funcall(converter, spg_id_call, 1, rword);
179
+ }
180
+
181
+ rb_ary_push(array, rword);
173
182
  }
174
183
  }
175
184
  if(c == '}')
@@ -187,7 +196,11 @@ static VALUE read_array(int *index, char *c_pg_array_string, int array_string_le
187
196
  else if(c == '{')
188
197
  {
189
198
  (*index)++;
190
- rb_ary_push(array, read_array(index, c_pg_array_string, array_string_length, word, converter));
199
+ rb_ary_push(array, read_array(index, c_pg_array_string, array_string_length, word, converter
200
+ #ifdef SPG_ENCODING
201
+ , enc_index
202
+ #endif
203
+ ));
191
204
  escapeNext = 1;
192
205
  }
193
206
  else
@@ -230,7 +243,11 @@ static VALUE parse_pg_array(VALUE self, VALUE pg_array_string, VALUE converter)
230
243
  char *word = RSTRING_PTR(buf);
231
244
  int index = 1;
232
245
 
233
- return read_array(&index, c_pg_array_string, array_string_length, word, converter);
246
+ return read_array(&index, c_pg_array_string, array_string_length, word, converter
247
+ #ifdef SPG_ENCODING
248
+ , enc_get_index(pg_array_string)
249
+ #endif
250
+ );
234
251
  }
235
252
 
236
253
  static VALUE spg_time(const char *s) {
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sequel_pg
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.0
4
+ version: 1.6.1
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: 2012-09-04 00:00:00.000000000 Z
12
+ date: 2012-10-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: pg