do_postgres 0.10.7-x86-mingw32 → 0.10.8-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
data/ChangeLog.markdown CHANGED
@@ -1,3 +1,8 @@
1
+ ## 0.10.8 2012-02-10
2
+
3
+ * Ruby 1.9.3 compatibility on Windows
4
+ * Fix crash issue when reading a reader twice
5
+
1
6
  ## 0.10.7 2011-10-13
2
7
 
3
8
  * Ruby 1.9.3 compatibility
@@ -53,9 +53,10 @@ VALUE data_objects_const_get(VALUE scope, const char *constant) {
53
53
  void data_objects_debug(VALUE connection, VALUE string, struct timeval *start) {
54
54
  struct timeval stop;
55
55
  VALUE message;
56
+ do_int64 duration;
56
57
 
57
58
  gettimeofday(&stop, NULL);
58
- do_int64 duration = (stop.tv_sec - start->tv_sec) * 1000000 + stop.tv_usec - start->tv_usec;
59
+ duration = (stop.tv_sec - start->tv_sec) * 1000000 + stop.tv_usec - start->tv_usec;
59
60
 
60
61
  message = rb_funcall(cDO_Logger_Message, ID_NEW, 3, string, rb_time_new(start->tv_sec, start->tv_usec), INT2NUM(duration));
61
62
 
@@ -65,6 +66,7 @@ void data_objects_debug(VALUE connection, VALUE string, struct timeval *start) {
65
66
  void data_objects_raise_error(VALUE self, const struct errcodes *errors, int errnum, const char *message, VALUE query, VALUE state) {
66
67
  const char *exception_type = "SQLError";
67
68
  const struct errcodes *e;
69
+ VALUE uri, exception;
68
70
 
69
71
  for (e = errors; e->error_name; e++) {
70
72
  if (e->error_no == errnum) {
@@ -74,9 +76,9 @@ void data_objects_raise_error(VALUE self, const struct errcodes *errors, int err
74
76
  }
75
77
  }
76
78
 
77
- VALUE uri = rb_funcall(rb_iv_get(self, "@connection"), rb_intern("to_s"), 0);
79
+ uri = rb_funcall(rb_iv_get(self, "@connection"), rb_intern("to_s"), 0);
78
80
 
79
- VALUE exception = rb_funcall(
81
+ exception = rb_funcall(
80
82
  data_objects_const_get(mDO, exception_type),
81
83
  ID_NEW,
82
84
  5,
@@ -116,8 +118,8 @@ void data_objects_assert_file_exists(char *file, const char *message) {
116
118
  }
117
119
 
118
120
  VALUE data_objects_build_query_from_args(VALUE klass, int count, VALUE *args) {
119
- VALUE array = rb_ary_new();
120
121
  int i;
122
+ VALUE array = rb_ary_new();
121
123
 
122
124
  for (i = 0; i < count; i++) {
123
125
  rb_ary_push(array, args[i]);
@@ -176,8 +178,6 @@ VALUE data_objects_timezone_to_offset(int hour_offset, int minute_offset) {
176
178
  VALUE data_objects_parse_date(const char *date) {
177
179
  static char const *const _fmt_date = "%4d-%2d-%2d";
178
180
  int year = 0, month = 0, day = 0;
179
- int jd, ajd;
180
- VALUE rational;
181
181
 
182
182
  switch (sscanf(date, _fmt_date, &year, &month, &day)) {
183
183
  case 0:
@@ -185,16 +185,7 @@ VALUE data_objects_parse_date(const char *date) {
185
185
  return Qnil;
186
186
  }
187
187
 
188
- #ifdef HAVE_NO_DATETIME_NEWBANG
189
188
  return rb_funcall(rb_cDate, ID_NEW, 3, INT2NUM(year), INT2NUM(month), INT2NUM(day));
190
- #else
191
-
192
- jd = data_objects_jd_from_date(year, month, day);
193
- ajd = (jd * 2) - 1; // Math from Date.jd_to_ajd
194
- rational = rb_funcall(rb_mKernel, ID_RATIONAL, 2, INT2NUM(ajd), INT2NUM(2));
195
-
196
- return rb_funcall(rb_cDate, ID_NEW_DATE, 3, rational, INT2NUM(0), INT2NUM(2299161));
197
- #endif
198
189
  }
199
190
 
200
191
  VALUE data_objects_parse_time(const char *date) {
@@ -224,10 +215,9 @@ VALUE data_objects_parse_date_time(const char *date) {
224
215
  int tokens_read;
225
216
  const char *fmt_datetime;
226
217
 
227
- VALUE ajd, offset;
218
+ VALUE offset;
228
219
 
229
- int year, month, day, hour, min, sec, hour_offset, minute_offset, jd;
230
- do_int64 num, den;
220
+ int year, month, day, hour, min, sec, hour_offset, minute_offset;
231
221
 
232
222
  struct tm timeinfo;
233
223
  time_t target_time;
@@ -304,40 +294,9 @@ VALUE data_objects_parse_date_time(const char *date) {
304
294
  rb_raise(eDataError, "Couldn't parse date: %s", date);
305
295
  }
306
296
 
307
- #ifdef HAVE_NO_DATETIME_NEWBANG
308
297
  offset = data_objects_timezone_to_offset(hour_offset, minute_offset);
309
298
  return rb_funcall(rb_cDateTime, ID_NEW, 7, INT2NUM(year), INT2NUM(month), INT2NUM(day),
310
299
  INT2NUM(hour), INT2NUM(min), INT2NUM(sec), offset);
311
- #else
312
- jd = data_objects_jd_from_date(year, month, day);
313
-
314
- /*
315
- * Generate ajd with fractional days for the time.
316
- * Extracted from Date#jd_to_ajd, Date#day_fraction_to_time, and Rational#+ and #-.
317
- *
318
- * TODO: These are 64bit numbers; is reduce() really necessary?
319
- */
320
-
321
- num = (hour * 1440) + (min * 24);
322
- num -= (hour_offset * 1440) + (minute_offset * 24);
323
- den = (24 * 1440);
324
- data_objects_reduce(&num, &den);
325
-
326
- num = (num * 86400) + (sec * den);
327
- den = den * 86400;
328
- data_objects_reduce(&num, &den);
329
-
330
- num += jd * den;
331
-
332
- num = (num * 2) - den;
333
- den *= 2;
334
- data_objects_reduce(&num, &den);
335
-
336
- ajd = rb_funcall(rb_mKernel, ID_RATIONAL, 2, rb_ull2inum(num), rb_ull2inum(den));
337
- offset = data_objects_timezone_to_offset(hour_offset, minute_offset);
338
-
339
- return rb_funcall(rb_cDateTime, ID_NEW_DATE, 3, ajd, offset, INT2NUM(2299161));
340
- #endif
341
300
  }
342
301
 
343
302
  VALUE data_objects_cConnection_character_set(VALUE self) {
@@ -371,17 +330,15 @@ VALUE data_objects_cConnection_quote_date(VALUE self, VALUE value) {
371
330
  * into Ruby-strings so we can easily typecast later
372
331
  */
373
332
  VALUE data_objects_cCommand_set_types(int argc, VALUE *argv, VALUE self) {
333
+ VALUE entry, sub_entry;
334
+ int i, j;
374
335
  VALUE type_strings = rb_ary_new();
375
336
  VALUE array = rb_ary_new();
376
337
 
377
- int i, j;
378
-
379
338
  for (i = 0; i < argc; i++) {
380
339
  rb_ary_push(array, argv[i]);
381
340
  }
382
341
 
383
- VALUE entry, sub_entry;
384
-
385
342
  for (i = 0; i < RARRAY_LEN(array); i++) {
386
343
  entry = rb_ary_entry(array, i);
387
344
 
@@ -610,7 +610,15 @@ VALUE do_postgres_cReader_close(VALUE self) {
610
610
  }
611
611
 
612
612
  VALUE do_postgres_cReader_next(VALUE self) {
613
- PGresult *reader = DATA_PTR(rb_iv_get(self, "@reader"));
613
+
614
+ VALUE reader = rb_iv_get(self, "@reader");
615
+
616
+ if(reader == Qnil) {
617
+ rb_raise(eConnectionError, "This result set has already been closed.");
618
+ return Qfalse;
619
+ }
620
+
621
+ PGresult *pg_reader = DATA_PTR(reader);
614
622
 
615
623
  int row_count = NUM2INT(rb_iv_get(self, "@row_count"));
616
624
  int field_count = NUM2INT(rb_iv_get(self, "@field_count"));
@@ -642,8 +650,8 @@ VALUE do_postgres_cReader_next(VALUE self) {
642
650
  field_type = rb_ary_entry(field_types, i);
643
651
 
644
652
  // Always return nil if the value returned from Postgres is null
645
- if (!PQgetisnull(reader, position, i)) {
646
- value = do_postgres_typecast(PQgetvalue(reader, position, i), PQgetlength(reader, position, i), field_type, enc);
653
+ if (!PQgetisnull(pg_reader, position, i)) {
654
+ value = do_postgres_typecast(PQgetvalue(pg_reader, position, i), PQgetlength(pg_reader, position, i), field_type, enc);
647
655
  }
648
656
  else {
649
657
  value = Qnil;
Binary file
Binary file
@@ -1,5 +1,5 @@
1
1
  module DataObjects
2
2
  module Postgres
3
- VERSION = '0.10.7'
3
+ VERSION = '0.10.8'
4
4
  end
5
5
  end
@@ -6,4 +6,28 @@ require 'data_objects/spec/shared/typecast/date_spec'
6
6
  describe 'DataObjects::Postgres with Date' do
7
7
  it_should_behave_like 'supporting Date'
8
8
  it_should_behave_like 'supporting Date autocasting'
9
+
10
+ describe 'exotic dates' do
11
+
12
+ before do
13
+ @connection = DataObjects::Connection.new(CONFIG.uri)
14
+ @connection.create_command("INSERT INTO widgets (release_date) VALUES ('0001-01-01')").execute_non_query
15
+
16
+ @command = @connection.create_command("SELECT release_date FROM widgets WHERE release_date = '0001-01-01'")
17
+ @reader = @command.execute_reader
18
+ @reader.next!
19
+ @values = @reader.values
20
+ end
21
+
22
+ after do
23
+ @reader.close
24
+ @connection.close
25
+ end
26
+
27
+ it 'should return the number of created rows' do
28
+ @values.first.should == Date.civil(1, 1, 1)
29
+ end
30
+
31
+ end
32
+
9
33
  end
data/tasks/compile.rake CHANGED
@@ -70,7 +70,7 @@ begin
70
70
  ext.classpath = '../do_jdbc/lib/do_jdbc_internal.jar'
71
71
  ext.java_compiling do |gem|
72
72
  gem.add_dependency 'jdbc-postgres', '>=8.2'
73
- gem.add_dependency 'do_jdbc', '0.10.7'
73
+ gem.add_dependency 'do_jdbc', '0.10.8'
74
74
  end
75
75
  end
76
76
  rescue LoadError
data/tasks/spec.rake CHANGED
@@ -2,7 +2,6 @@ require 'rspec/core/rake_task'
2
2
 
3
3
  RSpec::Core::RakeTask.new(:spec => [:clean, :compile]) do |spec|
4
4
  spec.pattern = './spec/**/*_spec.rb'
5
- spec.skip_bundler = true
6
5
  end
7
6
 
8
7
  RSpec::Core::RakeTask.new(:rcov => [:clean, :compile]) do |rcov|
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: do_postgres
3
3
  version: !ruby/object:Gem::Version
4
- hash: 57
4
+ hash: 39
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 10
9
- - 7
10
- version: 0.10.7
9
+ - 8
10
+ version: 0.10.8
11
11
  platform: x86-mingw32
12
12
  authors:
13
13
  - Dirkjan Bussink
@@ -18,23 +18,23 @@ cert_chain: []
18
18
  date: 2011-03-29 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
- requirement: &id001 !ruby/object:Gem::Requirement
21
+ version_requirements: &id001 !ruby/object:Gem::Requirement
22
22
  none: false
23
23
  requirements:
24
24
  - - "="
25
25
  - !ruby/object:Gem::Version
26
- hash: 57
26
+ hash: 39
27
27
  segments:
28
28
  - 0
29
29
  - 10
30
- - 7
31
- version: 0.10.7
32
- version_requirements: *id001
30
+ - 8
31
+ version: 0.10.8
33
32
  name: data_objects
34
33
  prerelease: false
35
34
  type: :runtime
35
+ requirement: *id001
36
36
  - !ruby/object:Gem::Dependency
37
- requirement: &id002 !ruby/object:Gem::Requirement
37
+ version_requirements: &id002 !ruby/object:Gem::Requirement
38
38
  none: false
39
39
  requirements:
40
40
  - - ~>
@@ -44,12 +44,12 @@ dependencies:
44
44
  - 2
45
45
  - 5
46
46
  version: "2.5"
47
- version_requirements: *id002
48
47
  name: rspec
49
48
  prerelease: false
50
49
  type: :development
50
+ requirement: *id002
51
51
  - !ruby/object:Gem::Dependency
52
- requirement: &id003 !ruby/object:Gem::Requirement
52
+ version_requirements: &id003 !ruby/object:Gem::Requirement
53
53
  none: false
54
54
  requirements:
55
55
  - - ~>
@@ -59,10 +59,10 @@ dependencies:
59
59
  - 0
60
60
  - 7
61
61
  version: "0.7"
62
- version_requirements: *id003
63
62
  name: rake-compiler
64
63
  prerelease: false
65
64
  type: :development
65
+ requirement: *id003
66
66
  description: Implements the DataObjects API for PostgreSQL
67
67
  email: d.bussink@gmail.com
68
68
  executables: []
@@ -172,7 +172,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
172
172
  requirements: []
173
173
 
174
174
  rubyforge_project: dorb
175
- rubygems_version: 1.8.6
175
+ rubygems_version: 1.8.14
176
176
  signing_key:
177
177
  specification_version: 3
178
178
  summary: DataObjects PostgreSQL Driver