diff --git a/CHANGELOG b/CHANGELOG index f15788b..735b636 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,7 @@ +=== 1.12.4 (2020-01-02) + +* Work with pg 1.2.1+ (jeremyevans) + === 1.12.3 (2020-01-02) * Warn and do not load sequel_pg if pg >1.2 is used (jeremyevans) diff --git a/ext/sequel_pg/sequel_pg.c b/ext/sequel_pg/sequel_pg.c index 549fd33..1ae31a3 100644 --- a/ext/sequel_pg/sequel_pg.c +++ b/ext/sequel_pg/sequel_pg.c @@ -1,4 +1,4 @@ -#define SEQUEL_PG_VERSION_INTEGER 11203 +#define SEQUEL_PG_VERSION_INTEGER 11204 #include #include @@ -72,8 +72,10 @@ /* External functions defined by ruby-pg */ PGconn* pg_get_pgconn(VALUE); PGresult* pgresult_get(VALUE); +int pg_get_result_enc_idx(VALUE); static int spg_use_ipaddr_alloc; +static int spg_use_pg_get_result_enc_idx; static VALUE spg_Sequel; static VALUE spg_PGArray; @@ -1387,7 +1389,7 @@ static VALUE spg_yield_hash_rows(VALUE self, VALUE rres, VALUE ignore) { } res = pgresult_get(rres); - enc_index = enc_get_index(rres); + enc_index = spg_use_pg_get_result_enc_idx ? pg_get_result_enc_idx(rres) : enc_get_index(rres); ntuples = PQntuples(res); nfields = PQnfields(res); @@ -1655,7 +1657,7 @@ static VALUE spg__yield_each_row(VALUE self) { rb_funcall(rres, spg_id_check, 0); res = pgresult_get(rres); - enc_index = enc_get_index(rres); + enc_index = spg_use_pg_get_result_enc_idx ? pg_get_result_enc_idx(rres) : enc_get_index(rres); /* Only handle regular and model types. All other types require compiling all * of the results at once, which is not a use case for streaming. The streaming @@ -1760,8 +1762,7 @@ void Init_sequel_pg(void) { } if (RTEST(rb_eval_string("defined?(PG::VERSION) && PG::VERSION.to_f >= 1.2"))) { - rb_warn("sequel_pg not loaded as it is not compatible with the ruby-pg version in use; uninstall sequel_pg or downgrade pg to 1.1.4"); - return; + spg_use_pg_get_result_enc_idx = 1; } rb_const_set(spg_Postgres, rb_intern("SEQUEL_PG_VERSION_INTEGER"), INT2FIX(SEQUEL_PG_VERSION_INTEGER)); diff --git a/sequel_pg.gemspec b/sequel_pg.gemspec index 2bfe0d2..dd3fe46 100644 --- a/sequel_pg.gemspec +++ b/sequel_pg.gemspec @@ -15,7 +15,7 @@ SEQUEL_PG_GEMSPEC = Gem::Specification.new do |s| s.files = %w(MIT-LICENSE CHANGELOG README.rdoc Rakefile ext/sequel_pg/extconf.rb ext/sequel_pg/sequel_pg.c lib/sequel_pg/sequel_pg.rb lib/sequel/extensions/pg_streaming.rb) s.license = 'MIT' s.extensions << 'ext/sequel_pg/extconf.rb' - s.add_dependency("pg", [">= 0.18.0"]) + s.add_dependency("pg", [">= 0.18.0", "!= 1.2.0"]) s.add_dependency("sequel", [">= 4.38.0"]) s.metadata = { 'bug_tracker_uri' => 'https://github.com/jeremyevans/sequel_pg/issues',