sequel_pg 1.2.2-x86-mingw32 → 1.3.0-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,11 @@
1
+ === 1.3.0 (2012-04-02)
2
+
3
+ * Build Windows version against PostgreSQL 9.1.1, ruby 1.8.7, and ruby 1.9.2 (previously 9.0.1, 1.8.6, and 1.9.1) (jeremyevans)
4
+
5
+ * Add major speedup for new Sequel 3.34.0 methods Dataset#to_hash_groups and #select_hash_groups (jeremyevans)
6
+
7
+ * Handle infinite timestamp values using Database#convert_infinite_timestamps in Sequel 3.34.0 (jeremyevans)
8
+
1
9
  === 1.2.2 (2012-03-09)
2
10
 
3
11
  * Get microsecond accuracy when using datetime_class = DateTime with 1.8-1.9.2 stdlib date library via Rational (jeremyevans)
@@ -36,6 +36,10 @@
36
36
  #define SPG_YIELD_KMV_HASH 7
37
37
  #define SPG_YIELD_MKMV_HASH 8
38
38
  #define SPG_YIELD_MODEL 9
39
+ #define SPG_YIELD_KV_HASH_GROUPS 10
40
+ #define SPG_YIELD_MKV_HASH_GROUPS 11
41
+ #define SPG_YIELD_KMV_HASH_GROUPS 12
42
+ #define SPG_YIELD_MKMV_HASH_GROUPS 13
39
43
 
40
44
  static VALUE spg_Sequel;
41
45
  static VALUE spg_Blob;
@@ -49,6 +53,7 @@ static VALUE spg_sym_map;
49
53
  static VALUE spg_sym_first;
50
54
  static VALUE spg_sym_array;
51
55
  static VALUE spg_sym_hash;
56
+ static VALUE spg_sym_hash_groups;
52
57
  static VALUE spg_sym_model;
53
58
  static VALUE spg_sym__sequel_pg_type;
54
59
  static VALUE spg_sym__sequel_pg_value;
@@ -72,6 +77,8 @@ static ID spg_id_utc;
72
77
  static ID spg_id_utc_offset;
73
78
  static ID spg_id_localtime;
74
79
  static ID spg_id_new_offset;
80
+ static ID spg_id_convert_infinite_timestamps;
81
+ static ID spg_id_infinite_timestamp_value;
75
82
 
76
83
  static ID spg_id_call;
77
84
  static ID spg_id_get;
@@ -123,6 +130,17 @@ static VALUE spg_date(const char *s) {
123
130
  return rb_funcall(spg_Date, spg_id_new, 3, INT2NUM(year), INT2NUM(month), INT2NUM(day));
124
131
  }
125
132
 
133
+ static VALUE spg_timestamp_error(const char *s, VALUE self) {
134
+ VALUE db;
135
+ db = rb_funcall(self, spg_id_db, 0);
136
+ if(RTEST(rb_funcall(db, spg_id_convert_infinite_timestamps, 0))) {
137
+ if((strcmp(s, "infinity") == 0) || (strcmp(s, "-infinity") == 0)) {
138
+ return rb_funcall(db, spg_id_infinite_timestamp_value, 1, rb_tainted_str_new2(s));
139
+ }
140
+ }
141
+ rb_raise(rb_eArgError, "unexpected datetime format");
142
+ }
143
+
126
144
  static VALUE spg_timestamp(const char *s, VALUE self) {
127
145
  VALUE dtc, dt, rtz;
128
146
  int tz = SPG_NO_TZ;
@@ -140,7 +158,7 @@ static VALUE spg_timestamp(const char *s, VALUE self) {
140
158
  &usec_start, &usec, &usec_stop,
141
159
  &offset_sign, &offset_hour, &offset_minute);
142
160
  if(tokens < 7) {
143
- rb_raise(rb_eArgError, "unexpected datetime format");
161
+ return spg_timestamp_error(s, self);
144
162
  }
145
163
  usec *= (int) pow(10, (6 - (usec_stop - usec_start)));
146
164
  } else {
@@ -152,7 +170,7 @@ static VALUE spg_timestamp(const char *s, VALUE self) {
152
170
  min = 0;
153
171
  sec = 0;
154
172
  } else if (tokens < 6) {
155
- rb_raise(rb_eArgError, "unexpected datetime format");
173
+ return spg_timestamp_error(s, self);
156
174
  }
157
175
  usec = 0;
158
176
  }
@@ -458,21 +476,21 @@ static VALUE spg_yield_hash_rows(VALUE self, VALUE rres, VALUE ignore) {
458
476
  type = SPG_YIELD_FIRST;
459
477
  } else if (pg_type == spg_sym_array) {
460
478
  type = SPG_YIELD_ARRAY;
461
- } else if (pg_type == spg_sym_hash && rb_type(pg_value) == T_ARRAY) {
479
+ } else if ((pg_type == spg_sym_hash || pg_type == spg_sym_hash_groups) && rb_type(pg_value) == T_ARRAY) {
462
480
  VALUE pg_value_key, pg_value_value;
463
481
  pg_value_key = rb_ary_entry(pg_value, 0);
464
482
  pg_value_value = rb_ary_entry(pg_value, 1);
465
483
  if (SYMBOL_P(pg_value_key)) {
466
484
  if (SYMBOL_P(pg_value_value)) {
467
- type = SPG_YIELD_KV_HASH;
485
+ type = pg_type == spg_sym_hash_groups ? SPG_YIELD_KV_HASH_GROUPS : SPG_YIELD_KV_HASH;
468
486
  } else if (rb_type(pg_value_value) == T_ARRAY) {
469
- type = SPG_YIELD_KMV_HASH;
487
+ type = pg_type == spg_sym_hash_groups ? SPG_YIELD_KMV_HASH_GROUPS : SPG_YIELD_KMV_HASH;
470
488
  }
471
489
  } else if (rb_type(pg_value_key) == T_ARRAY) {
472
490
  if (SYMBOL_P(pg_value_value)) {
473
- type = SPG_YIELD_MKV_HASH;
491
+ type = pg_type == spg_sym_hash_groups ? SPG_YIELD_MKV_HASH_GROUPS : SPG_YIELD_MKV_HASH;
474
492
  } else if (rb_type(pg_value_value) == T_ARRAY) {
475
- type = SPG_YIELD_MKMV_HASH;
493
+ type = pg_type == spg_sym_hash_groups ? SPG_YIELD_MKMV_HASH_GROUPS : SPG_YIELD_MKMV_HASH;
476
494
  }
477
495
  }
478
496
  } else if (pg_type == spg_sym_model && rb_type(pg_value) == T_CLASS) {
@@ -529,54 +547,114 @@ static VALUE spg_yield_hash_rows(VALUE self, VALUE rres, VALUE ignore) {
529
547
  }
530
548
  break;
531
549
  case SPG_YIELD_KV_HASH:
550
+ case SPG_YIELD_KV_HASH_GROUPS:
532
551
  /* Hash with single key and single value */
533
552
  {
534
553
  VALUE k, v;
535
554
  h = rb_hash_new();
536
555
  k = spg__field_id(rb_ary_entry(pg_value, 0), colsyms, nfields);
537
556
  v = spg__field_id(rb_ary_entry(pg_value, 1), colsyms, nfields);
538
- for(i=0; i<ntuples; i++) {
539
- rb_hash_aset(h, spg__col_value(self, res, i, k, colconvert ENC_INDEX), spg__col_value(self, res, i, v, colconvert ENC_INDEX));
540
- }
557
+ if(type == SPG_YIELD_KV_HASH) {
558
+ for(i=0; i<ntuples; i++) {
559
+ rb_hash_aset(h, spg__col_value(self, res, i, k, colconvert ENC_INDEX), spg__col_value(self, res, i, v, colconvert ENC_INDEX));
560
+ }
561
+ } else {
562
+ VALUE kv, vv, a;
563
+ for(i=0; i<ntuples; i++) {
564
+ kv = spg__col_value(self, res, i, k, colconvert ENC_INDEX);
565
+ vv = spg__col_value(self, res, i, v, colconvert ENC_INDEX);
566
+ a = rb_hash_lookup(h, kv);
567
+ if(!RTEST(a)) {
568
+ rb_hash_aset(h, kv, rb_ary_new3(1, vv));
569
+ } else {
570
+ rb_ary_push(a, vv);
571
+ }
572
+ }
573
+ }
541
574
  rb_yield(h);
542
575
  }
543
576
  break;
544
577
  case SPG_YIELD_MKV_HASH:
578
+ case SPG_YIELD_MKV_HASH_GROUPS:
545
579
  /* Hash with array of keys and single value */
546
580
  {
547
581
  VALUE k, v;
548
582
  h = rb_hash_new();
549
583
  k = spg__field_ids(rb_ary_entry(pg_value, 0), colsyms, nfields);
550
584
  v = spg__field_id(rb_ary_entry(pg_value, 1), colsyms, nfields);
551
- for(i=0; i<ntuples; i++) {
552
- rb_hash_aset(h, spg__col_values(self, k, colsyms, nfields, res, i, colconvert ENC_INDEX), spg__col_value(self, res, i, v, colconvert ENC_INDEX));
553
- }
585
+ if(type == SPG_YIELD_MKV_HASH) {
586
+ for(i=0; i<ntuples; i++) {
587
+ rb_hash_aset(h, spg__col_values(self, k, colsyms, nfields, res, i, colconvert ENC_INDEX), spg__col_value(self, res, i, v, colconvert ENC_INDEX));
588
+ }
589
+ } else {
590
+ VALUE kv, vv, a;
591
+ for(i=0; i<ntuples; i++) {
592
+ kv = spg__col_values(self, k, colsyms, nfields, res, i, colconvert ENC_INDEX);
593
+ vv = spg__col_value(self, res, i, v, colconvert ENC_INDEX);
594
+ a = rb_hash_lookup(h, kv);
595
+ if(!RTEST(a)) {
596
+ rb_hash_aset(h, kv, rb_ary_new3(1, vv));
597
+ } else {
598
+ rb_ary_push(a, vv);
599
+ }
600
+ }
601
+ }
554
602
  rb_yield(h);
555
603
  }
556
604
  break;
557
605
  case SPG_YIELD_KMV_HASH:
606
+ case SPG_YIELD_KMV_HASH_GROUPS:
558
607
  /* Hash with single keys and array of values */
559
608
  {
560
609
  VALUE k, v;
561
610
  h = rb_hash_new();
562
611
  k = spg__field_id(rb_ary_entry(pg_value, 0), colsyms, nfields);
563
612
  v = spg__field_ids(rb_ary_entry(pg_value, 1), colsyms, nfields);
564
- for(i=0; i<ntuples; i++) {
565
- rb_hash_aset(h, spg__col_value(self, res, i, k, colconvert ENC_INDEX), spg__col_values(self, v, colsyms, nfields, res, i, colconvert ENC_INDEX));
566
- }
613
+ if(type == SPG_YIELD_KMV_HASH) {
614
+ for(i=0; i<ntuples; i++) {
615
+ rb_hash_aset(h, spg__col_value(self, res, i, k, colconvert ENC_INDEX), spg__col_values(self, v, colsyms, nfields, res, i, colconvert ENC_INDEX));
616
+ }
617
+ } else {
618
+ VALUE kv, vv, a;
619
+ for(i=0; i<ntuples; i++) {
620
+ kv = spg__col_value(self, res, i, k, colconvert ENC_INDEX);
621
+ vv = spg__col_values(self, v, colsyms, nfields, res, i, colconvert ENC_INDEX);
622
+ a = rb_hash_lookup(h, kv);
623
+ if(!RTEST(a)) {
624
+ rb_hash_aset(h, kv, rb_ary_new3(1, vv));
625
+ } else {
626
+ rb_ary_push(a, vv);
627
+ }
628
+ }
629
+ }
567
630
  rb_yield(h);
568
631
  }
569
632
  break;
570
633
  case SPG_YIELD_MKMV_HASH:
634
+ case SPG_YIELD_MKMV_HASH_GROUPS:
571
635
  /* Hash with array of keys and array of values */
572
636
  {
573
637
  VALUE k, v;
574
638
  h = rb_hash_new();
575
639
  k = spg__field_ids(rb_ary_entry(pg_value, 0), colsyms, nfields);
576
640
  v = spg__field_ids(rb_ary_entry(pg_value, 1), colsyms, nfields);
577
- for(i=0; i<ntuples; i++) {
578
- rb_hash_aset(h, spg__col_values(self, k, colsyms, nfields, res, i, colconvert ENC_INDEX), spg__col_values(self, v, colsyms, nfields, res, i, colconvert ENC_INDEX));
579
- }
641
+ if(type == SPG_YIELD_MKMV_HASH) {
642
+ for(i=0; i<ntuples; i++) {
643
+ rb_hash_aset(h, spg__col_values(self, k, colsyms, nfields, res, i, colconvert ENC_INDEX), spg__col_values(self, v, colsyms, nfields, res, i, colconvert ENC_INDEX));
644
+ }
645
+ } else {
646
+ VALUE kv, vv, a;
647
+ for(i=0; i<ntuples; i++) {
648
+ kv = spg__col_values(self, k, colsyms, nfields, res, i, colconvert ENC_INDEX);
649
+ vv = spg__col_values(self, v, colsyms, nfields, res, i, colconvert ENC_INDEX);
650
+ a = rb_hash_lookup(h, kv);
651
+ if(!RTEST(a)) {
652
+ rb_hash_aset(h, kv, rb_ary_new3(1, vv));
653
+ } else {
654
+ rb_ary_push(a, vv);
655
+ }
656
+ }
657
+ }
580
658
  rb_yield(h);
581
659
  }
582
660
  break;
@@ -615,6 +693,8 @@ void Init_sequel_pg(void) {
615
693
  spg_id_utc_offset = rb_intern("utc_offset");
616
694
  spg_id_localtime = rb_intern("localtime");
617
695
  spg_id_new_offset = rb_intern("new_offset");
696
+ spg_id_convert_infinite_timestamps = rb_intern("convert_infinite_timestamps");
697
+ spg_id_infinite_timestamp_value = rb_intern("infinite_timestamp_value");
618
698
 
619
699
  spg_id_call = rb_intern("call");
620
700
  spg_id_get = rb_intern("[]");
@@ -634,6 +714,7 @@ void Init_sequel_pg(void) {
634
714
  spg_sym_first = ID2SYM(rb_intern("first"));
635
715
  spg_sym_array = ID2SYM(rb_intern("array"));
636
716
  spg_sym_hash = ID2SYM(rb_intern("hash"));
717
+ spg_sym_hash_groups = ID2SYM(rb_intern("hash_groups"));
637
718
  spg_sym_model = ID2SYM(rb_intern("model"));
638
719
  spg_sym__sequel_pg_type = ID2SYM(rb_intern("_sequel_pg_type"));
639
720
  spg_sym__sequel_pg_value = ID2SYM(rb_intern("_sequel_pg_value"));
data/lib/1.8/sequel_pg.so CHANGED
Binary file
data/lib/1.9/sequel_pg.so CHANGED
Binary file
@@ -40,6 +40,15 @@ class Sequel::Postgres::Dataset
40
40
  end
41
41
  end
42
42
 
43
+ # In the case where both arguments given, use an optimized version.
44
+ def to_hash_groups(key_column, value_column = nil)
45
+ if value_column
46
+ clone(:_sequel_pg_type=>:hash_groups, :_sequel_pg_value=>[key_column, value_column]).fetch_rows(sql){|s| return s}
47
+ else
48
+ super
49
+ end
50
+ end
51
+
43
52
  # If model loads are being optimized and this is a model load, use the optimized
44
53
  # version.
45
54
  def each
metadata CHANGED
@@ -2,12 +2,12 @@
2
2
  name: sequel_pg
3
3
  version: !ruby/object:Gem::Version
4
4
  hash: 27
5
- prerelease: false
5
+ prerelease:
6
6
  segments:
7
7
  - 1
8
- - 2
9
- - 2
10
- version: 1.2.2
8
+ - 3
9
+ - 0
10
+ version: 1.3.0
11
11
  platform: x86-mingw32
12
12
  authors:
13
13
  - Jeremy Evans
@@ -15,8 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-11-01 00:00:00 -07:00
19
- default_executable:
18
+ date: 2012-03-24 00:00:00 Z
20
19
  dependencies:
21
20
  - !ruby/object:Gem::Dependency
22
21
  name: pg
@@ -42,12 +41,12 @@ dependencies:
42
41
  requirements:
43
42
  - - ">="
44
43
  - !ruby/object:Gem::Version
45
- hash: 115
44
+ hash: 143
46
45
  segments:
47
46
  - 3
48
- - 29
47
+ - 34
49
48
  - 0
50
- version: 3.29.0
49
+ version: 3.34.0
51
50
  type: :runtime
52
51
  version_requirements: *id002
53
52
  description: |
@@ -75,7 +74,6 @@ files:
75
74
  - lib/sequel_pg/sequel_pg.rb
76
75
  - lib/1.8/sequel_pg.so
77
76
  - lib/1.9/sequel_pg.so
78
- has_rdoc: true
79
77
  homepage: http://github.com/jeremyevans/sequel_pg
80
78
  licenses: []
81
79
 
@@ -95,12 +93,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
95
93
  requirements:
96
94
  - - ">="
97
95
  - !ruby/object:Gem::Version
98
- hash: 59
96
+ hash: 57
99
97
  segments:
100
98
  - 1
101
99
  - 8
102
- - 6
103
- version: 1.8.6
100
+ - 7
101
+ version: 1.8.7
104
102
  required_rubygems_version: !ruby/object:Gem::Requirement
105
103
  none: false
106
104
  requirements:
@@ -113,7 +111,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
113
111
  requirements: []
114
112
 
115
113
  rubyforge_project:
116
- rubygems_version: 1.3.7
114
+ rubygems_version: 1.8.21
117
115
  signing_key:
118
116
  specification_version: 3
119
117
  summary: Faster SELECTs when using Sequel with pg