sequel_pg 1.6.10 → 1.6.11

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +4 -0
  3. data/ext/sequel_pg/sequel_pg.c +21 -7
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 25ed02f0ee78100daa444ad371dce7a81fb6302c
4
- data.tar.gz: 070c5284bfcddd9b1901be3b78c7b3166129b68e
3
+ metadata.gz: 7b51b8daa124c0b93c8210122caa04300bf38ede
4
+ data.tar.gz: 04aaec8db5cbf4ae2ac00fa345ef3ced573674cf
5
5
  SHA512:
6
- metadata.gz: d5d073fee789e59e7e83594f3f6190611a6a57eef47c55eebe1d734b588cf2a2410d3dc5ae303438d8e7038b27c1dd014c818c90175c7992fdcc89c8ac6e17a0
7
- data.tar.gz: dfd7e4b7eb0604b3cb7e90cd1629a1283e533ba8b123b4c22b9f0e62e71632e11ce9615745023a2cbad02d6bf5db536c741c2add1f81a99a5fa464cb66629900
6
+ metadata.gz: 8c19df266a6b88ea412e68c0ce8d08eadaab22d7532ddc20d7c0794afd6a3f02cf35f418443425f5f3fdda734697a8d044c396a4b7afc97e9ad256a361742ea7
7
+ data.tar.gz: 12b88db37b2b1366098893dc87fe53b76dc081d5aa82671adfaac3002ef98c77c0ac2e3b4dd20f85a47ea9ca2cec19a6621afc200788fac48ae652c0e57b13bf
data/CHANGELOG CHANGED
@@ -1,3 +1,7 @@
1
+ === 1.6.11 (2014-11-04)
2
+
3
+ * Work with ruby pg 0.18+ (currently a prerelease) (jeremyevans)
4
+
1
5
  === 1.6.10 (2014-07-11)
2
6
 
3
7
  * Work correctly when the database timezone is not a named timezone but the application timezone is (jeremyevans)
@@ -43,6 +43,17 @@
43
43
  #define SPG_YIELD_KMV_HASH_GROUPS 12
44
44
  #define SPG_YIELD_MKMV_HASH_GROUPS 13
45
45
 
46
+ /* Whether the data objects are structs instead of just pointers */
47
+ static int unwrap_structs;
48
+
49
+ /* External functions defined by ruby-pg when data objects are structs */
50
+ PGconn* pg_get_pgconn(VALUE);
51
+ PGresult* pgresult_get(VALUE);
52
+
53
+ /* Normalize access to data objects for both old and new versions of pg gem */
54
+ #define GetPGconn(_val, _var) if (unwrap_structs) {_var = pg_get_pgconn(_val);} else {Data_Get_Struct(_val, PGconn, _var);}
55
+ #define GetPGresult(_val, _var) if (unwrap_structs) {_var = pgresult_get(_val);} else {Data_Get_Struct(_val, PGresult, _var);}
56
+
46
57
  static VALUE spg_Sequel;
47
58
  static VALUE spg_Blob;
48
59
  static VALUE spg_BigDecimal;
@@ -614,11 +625,11 @@ static VALUE spg_yield_hash_rows(VALUE self, VALUE rres, VALUE ignore) {
614
625
  enc_index = enc_get_index(rres);
615
626
  #endif
616
627
 
617
- Data_Get_Struct(rres, PGresult, res);
628
+ GetPGresult(rres, res);
618
629
  ntuples = PQntuples(res);
619
630
  nfields = PQnfields(res);
620
631
  if (nfields > SPG_MAX_FIELDS) {
621
- rb_raise(rb_eRangeError, "more than %d columns in query", SPG_MAX_FIELDS);
632
+ rb_raise(rb_eRangeError, "more than %d columns in query (%ld columns detected)", SPG_MAX_FIELDS, nfields);
622
633
  }
623
634
 
624
635
  spg_set_column_info(self, res, colsyms, colconvert);
@@ -851,7 +862,7 @@ static VALUE spg_supports_streaming_p(VALUE self) {
851
862
  #if HAVE_PQSETSINGLEROWMODE
852
863
  static VALUE spg_set_single_row_mode(VALUE self) {
853
864
  PGconn *conn;
854
- Data_Get_Struct(self, PGconn, conn);
865
+ GetPGconn(self, conn);
855
866
  if (PQsetSingleRowMode(conn) != 1) {
856
867
  rb_raise(spg_PGError, "cannot set single row mode");
857
868
  }
@@ -875,11 +886,11 @@ static VALUE spg__yield_each_row(VALUE self) {
875
886
 
876
887
  rconn = rb_ary_entry(self, 1);
877
888
  self = rb_ary_entry(self, 0);
878
- Data_Get_Struct(rconn, PGconn, conn);
889
+ GetPGconn(rconn, conn);
879
890
 
880
891
  rres = rb_funcall(rconn, spg_id_get_result, 0);
881
892
  rb_funcall(rres, spg_id_check, 0);
882
- Data_Get_Struct(rres, PGresult, res);
893
+ GetPGresult(rres, res);
883
894
 
884
895
  #ifdef SPG_ENCODING
885
896
  int enc_index;
@@ -927,7 +938,7 @@ static VALUE spg__yield_each_row(VALUE self) {
927
938
 
928
939
  rres = rb_funcall(rconn, spg_id_get_result, 0);
929
940
  rb_funcall(rres, spg_id_check, 0);
930
- Data_Get_Struct(rres, PGresult, res);
941
+ GetPGresult(rres, res);
931
942
  }
932
943
  rb_funcall(rres, spg_id_clear, 0);
933
944
 
@@ -938,7 +949,7 @@ static VALUE spg__flush_results(VALUE rconn) {
938
949
  PGconn *conn;
939
950
  PGresult *res;
940
951
  VALUE error = 0;
941
- Data_Get_Struct(rconn, PGconn, conn);
952
+ GetPGconn(rconn, conn);
942
953
 
943
954
  while ((res = PQgetResult(conn)) != NULL) {
944
955
  if (!error) {
@@ -1043,6 +1054,9 @@ void Init_sequel_pg(void) {
1043
1054
  if (rb_eval_string("Date.today.instance_variable_get(:@ajd)") != Qnil) {
1044
1055
  spg_id_Rational = rb_intern("Rational");
1045
1056
  }
1057
+ if (rb_eval_string("defined?(PG::TypeMapAllStrings)") != Qnil) {
1058
+ unwrap_structs = 1;
1059
+ }
1046
1060
 
1047
1061
  c = rb_funcall(spg_Postgres, cg, 1, rb_str_new2("Dataset"));
1048
1062
  rb_define_private_method(c, "yield_hash_rows", spg_yield_hash_rows, 2);
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sequel_pg
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.10
4
+ version: 1.6.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy Evans
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-11 00:00:00.000000000 Z
11
+ date: 2014-11-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pg