sequel_pg 1.19.0 → 1.20.0
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.
- checksums.yaml +4 -4
- data/CHANGELOG +8 -0
- data/MIT-LICENSE +1 -1
- data/ext/sequel_pg/sequel_pg.c +11 -5
- data/lib/sequel/extensions/pg_streaming.rb +6 -6
- data/lib/sequel_pg/model.rb +21 -7
- data/lib/sequel_pg/sequel_pg.rb +14 -14
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 14718a7aa7ca80b5952b679a8bbcd29bc3b381c80ac8df005d864f34a6c0da45
|
|
4
|
+
data.tar.gz: 816ea1b4bed0b6292c4d30e02954c1bc436af0126eda4b70bc177cf634cc7702
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f79306d514d96bcfefea76f9afcebc3efcb67f0a8ff6ff0ceaba9b00c767277be24190357d344c3301f7d5aded60991b11ecbd72d2e1684eec4b4f278695f37e
|
|
7
|
+
data.tar.gz: 2214385a1e511c1c408aa1800ef5a0abdbc6fccaa963ac064a343dec6a99b176ed134aa007922803c7c492b687215a2a7fb545ab52bfea0030af53a46d20d1eb
|
data/CHANGELOG
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
=== 1.20.0 (2026-09-06)
|
|
2
|
+
|
|
3
|
+
* Skip query canceling on Ruby < 2.4 (jeremyevans)
|
|
4
|
+
|
|
5
|
+
* Only allow parsing arrays of up to 6 dimensions (jeremyevans)
|
|
6
|
+
|
|
7
|
+
* Disable model optimization if the model_class.shape_friendly is true (jeremyevans)
|
|
8
|
+
|
|
1
9
|
=== 1.19.0 (2026-03-06)
|
|
2
10
|
|
|
3
11
|
* Cancel the query if an exception is raised while streaming query results (jtmkrueger, jeremyevans) (#66)
|
data/MIT-LICENSE
CHANGED
data/ext/sequel_pg/sequel_pg.c
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#define SEQUEL_PG_VERSION_INTEGER
|
|
1
|
+
#define SEQUEL_PG_VERSION_INTEGER 12000
|
|
2
2
|
|
|
3
3
|
#include <string.h>
|
|
4
4
|
#include <stdio.h>
|
|
@@ -279,7 +279,7 @@ pg_text_dec_integer(char *val, size_t len)
|
|
|
279
279
|
|
|
280
280
|
static VALUE spg__array_col_value(char *v, size_t length, VALUE converter, int enc_index, int oid, VALUE db);
|
|
281
281
|
|
|
282
|
-
static VALUE read_array(int *index, char *c_pg_array_string, long array_string_length, VALUE buf, VALUE converter, int enc_index, int oid, VALUE db) {
|
|
282
|
+
static VALUE read_array(int *index, char *c_pg_array_string, long array_string_length, VALUE buf, VALUE converter, int enc_index, int oid, VALUE db, int level) {
|
|
283
283
|
int word_index = 0;
|
|
284
284
|
char *word = RSTRING_PTR(buf);
|
|
285
285
|
|
|
@@ -341,7 +341,10 @@ static VALUE read_array(int *index, char *c_pg_array_string, long array_string_l
|
|
|
341
341
|
else if(c == '{')
|
|
342
342
|
{
|
|
343
343
|
(*index)++;
|
|
344
|
-
|
|
344
|
+
if (level >= 6) {
|
|
345
|
+
rb_raise(rb_eArgError, "cannot parse array with more than 6 dimensions");
|
|
346
|
+
}
|
|
347
|
+
rb_ary_push(array, read_array(index, c_pg_array_string, array_string_length, buf, converter, enc_index, oid, db, level + 1));
|
|
345
348
|
escapeNext = 1;
|
|
346
349
|
}
|
|
347
350
|
else
|
|
@@ -425,7 +428,8 @@ static VALUE parse_pg_array(VALUE self, VALUE pg_array_string, VALUE converter)
|
|
|
425
428
|
converter,
|
|
426
429
|
enc_get_index(pg_array_string),
|
|
427
430
|
0,
|
|
428
|
-
Qnil
|
|
431
|
+
Qnil,
|
|
432
|
+
1);
|
|
429
433
|
}
|
|
430
434
|
|
|
431
435
|
static VALUE spg_timestamp_error(const char *s, VALUE self, const char *error_msg) {
|
|
@@ -980,7 +984,7 @@ static VALUE spg_array_value(char *c_pg_array_string, int array_string_length, V
|
|
|
980
984
|
buf = rb_str_buf_new(array_string_length);
|
|
981
985
|
rb_str_set_len(buf, array_string_length);
|
|
982
986
|
rb_obj_freeze(buf);
|
|
983
|
-
args[0] = read_array(&index, c_pg_array_string, array_string_length, buf, converter, enc_index, oid, self);
|
|
987
|
+
args[0] = read_array(&index, c_pg_array_string, array_string_length, buf, converter, enc_index, oid, self, 1);
|
|
984
988
|
return rb_class_new_instance(2, args, spg_PGArray);
|
|
985
989
|
}
|
|
986
990
|
|
|
@@ -2004,6 +2008,7 @@ static VALUE spg__flush_results(VALUE rconn) {
|
|
|
2004
2008
|
VALUE error = 0;
|
|
2005
2009
|
conn = pg_get_pgconn(rconn);
|
|
2006
2010
|
|
|
2011
|
+
#if (RUBY_API_VERSION_MAJOR > 2 || (RUBY_API_VERSION_MAJOR == 2 && RUBY_API_VERSION_MINOR >= 4))
|
|
2007
2012
|
/* Only cancel if an exception is being unwound. During normal
|
|
2008
2013
|
* completion, the query has already finished and there are no
|
|
2009
2014
|
* results to drain, so canceling is unnecessary. */
|
|
@@ -2035,6 +2040,7 @@ static VALUE spg__flush_results(VALUE rconn) {
|
|
|
2035
2040
|
* will check for and report any real errors. */
|
|
2036
2041
|
}
|
|
2037
2042
|
}
|
|
2043
|
+
#endif
|
|
2038
2044
|
|
|
2039
2045
|
while ((res = PQgetResult(conn)) != NULL) {
|
|
2040
2046
|
if (!error) {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
# :
|
|
1
|
+
# simplecov:disable
|
|
2
2
|
unless Sequel::Postgres.respond_to?(:supports_streaming?)
|
|
3
3
|
raise LoadError, "either sequel_pg not loaded, or an old version of sequel_pg loaded"
|
|
4
4
|
end
|
|
5
5
|
unless Sequel::Postgres.supports_streaming?
|
|
6
6
|
raise LoadError, "streaming is not supported by the version of libpq in use"
|
|
7
7
|
end
|
|
8
|
-
# :
|
|
8
|
+
# simplecov:enable
|
|
9
9
|
|
|
10
10
|
# Database methods necessary to support streaming. You should load this extension
|
|
11
11
|
# into your database object:
|
|
@@ -75,13 +75,13 @@ module Sequel::Postgres::Streaming
|
|
|
75
75
|
|
|
76
76
|
private
|
|
77
77
|
|
|
78
|
-
# :
|
|
78
|
+
# simplecov:disable
|
|
79
79
|
unless Sequel::Postgres::Adapter.method_defined?(:send_query_params)
|
|
80
80
|
def send_query_params(*args)
|
|
81
81
|
send_query(*args)
|
|
82
82
|
end
|
|
83
83
|
end
|
|
84
|
-
# :
|
|
84
|
+
# simplecov:enable
|
|
85
85
|
|
|
86
86
|
if Sequel::Database.instance_methods.map(&:to_s).include?('log_connection_yield')
|
|
87
87
|
# If using single row mode, send the query instead of executing it.
|
|
@@ -97,7 +97,7 @@ module Sequel::Postgres::Streaming
|
|
|
97
97
|
end
|
|
98
98
|
end
|
|
99
99
|
else
|
|
100
|
-
# :
|
|
100
|
+
# simplecov:disable
|
|
101
101
|
def execute_query(sql, args)
|
|
102
102
|
if @single_row_mode
|
|
103
103
|
@single_row_mode = false
|
|
@@ -109,7 +109,7 @@ module Sequel::Postgres::Streaming
|
|
|
109
109
|
super
|
|
110
110
|
end
|
|
111
111
|
end
|
|
112
|
-
# :
|
|
112
|
+
# simplecov:enable
|
|
113
113
|
end
|
|
114
114
|
end
|
|
115
115
|
|
data/lib/sequel_pg/model.rb
CHANGED
|
@@ -37,12 +37,26 @@ class Sequel::Postgres::Dataset
|
|
|
37
37
|
|
|
38
38
|
private
|
|
39
39
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
rp
|
|
45
|
-
|
|
46
|
-
|
|
40
|
+
if Sequel::Model.respond_to?(:shape_friendly)
|
|
41
|
+
# The model load can only be optimized if it's for a model and it's not a graphed dataset
|
|
42
|
+
# or using a cursor.
|
|
43
|
+
def optimize_model_load?(rp)
|
|
44
|
+
rp.is_a?(Class) &&
|
|
45
|
+
rp < Sequel::Model &&
|
|
46
|
+
!rp.shape_friendly &&
|
|
47
|
+
rp.method(:call).owner == Sequel::Model::ClassMethods &&
|
|
48
|
+
opts[:optimize_model_load] != false
|
|
49
|
+
end
|
|
50
|
+
# simplecov:disable
|
|
51
|
+
else
|
|
52
|
+
# The model load can only be optimized if it's for a model and it's not a graphed dataset
|
|
53
|
+
# or using a cursor.
|
|
54
|
+
def optimize_model_load?(rp)
|
|
55
|
+
rp.is_a?(Class) &&
|
|
56
|
+
rp < Sequel::Model &&
|
|
57
|
+
rp.method(:call).owner == Sequel::Model::ClassMethods &&
|
|
58
|
+
opts[:optimize_model_load] != false
|
|
59
|
+
end
|
|
60
|
+
# simplecov:enable
|
|
47
61
|
end
|
|
48
62
|
end
|
data/lib/sequel_pg/sequel_pg.rb
CHANGED
|
@@ -21,16 +21,16 @@ class Sequel::Postgres::Dataset
|
|
|
21
21
|
opts.has_key?(:optimize_model_load) ? opts[:optimize_model_load] : true
|
|
22
22
|
end
|
|
23
23
|
|
|
24
|
-
# :
|
|
24
|
+
# simplecov:disable
|
|
25
25
|
if method_defined?(:as_set)
|
|
26
|
-
# :
|
|
26
|
+
# simplecov:enable
|
|
27
27
|
if RUBY_VERSION > '4'
|
|
28
28
|
def as_set(column)
|
|
29
29
|
return super unless allow_sequel_pg_optimization?
|
|
30
30
|
clone(:_sequel_pg_type=>:map_set, :_sequel_pg_value=>column).fetch_rows(sql){|s| return s}
|
|
31
31
|
Set.new
|
|
32
32
|
end
|
|
33
|
-
# :
|
|
33
|
+
# simplecov:disable
|
|
34
34
|
else
|
|
35
35
|
def as_set(column)
|
|
36
36
|
return super unless allow_sequel_pg_optimization?
|
|
@@ -39,7 +39,7 @@ class Sequel::Postgres::Dataset
|
|
|
39
39
|
rows
|
|
40
40
|
end
|
|
41
41
|
end
|
|
42
|
-
# :
|
|
42
|
+
# simplecov:enable
|
|
43
43
|
end
|
|
44
44
|
|
|
45
45
|
# In the case where an argument is given, use an optimized version.
|
|
@@ -75,13 +75,13 @@ class Sequel::Postgres::Dataset
|
|
|
75
75
|
end
|
|
76
76
|
end
|
|
77
77
|
|
|
78
|
-
# :
|
|
78
|
+
# simplecov:disable
|
|
79
79
|
unless Sequel::Dataset.method_defined?(:as_hash)
|
|
80
80
|
# Handle previous versions of Sequel that use to_hash instead of as_hash
|
|
81
81
|
alias to_hash as_hash
|
|
82
82
|
remove_method :as_hash
|
|
83
83
|
end
|
|
84
|
-
# :
|
|
84
|
+
# simplecov:enable
|
|
85
85
|
|
|
86
86
|
# In the case where both arguments given, use an optimized version.
|
|
87
87
|
def to_hash_groups(key_column, value_column = nil, opts = Sequel::OPTS)
|
|
@@ -101,7 +101,7 @@ class Sequel::Postgres::Dataset
|
|
|
101
101
|
with_sql_all(sql, &block)
|
|
102
102
|
end
|
|
103
103
|
|
|
104
|
-
# :
|
|
104
|
+
# simplecov:disable
|
|
105
105
|
# Generally overridden by the model support, only used if the model
|
|
106
106
|
# support is not used.
|
|
107
107
|
def with_sql_all(sql, &block)
|
|
@@ -117,7 +117,7 @@ class Sequel::Postgres::Dataset
|
|
|
117
117
|
end
|
|
118
118
|
[]
|
|
119
119
|
end
|
|
120
|
-
# :
|
|
120
|
+
# simplecov:enable
|
|
121
121
|
|
|
122
122
|
protected
|
|
123
123
|
|
|
@@ -135,9 +135,9 @@ class Sequel::Postgres::Dataset
|
|
|
135
135
|
[]
|
|
136
136
|
end
|
|
137
137
|
|
|
138
|
-
# :
|
|
138
|
+
# simplecov:disable
|
|
139
139
|
if method_defined?(:_select_set_multiple)
|
|
140
|
-
# :
|
|
140
|
+
# simplecov:enable
|
|
141
141
|
if RUBY_VERSION > '4'
|
|
142
142
|
# Always use optimized version
|
|
143
143
|
def _select_set_multiple(ret_cols)
|
|
@@ -152,7 +152,7 @@ class Sequel::Postgres::Dataset
|
|
|
152
152
|
clone(:_sequel_pg_type=>:first_set).fetch_rows(sql){|s| return s}
|
|
153
153
|
Set.new
|
|
154
154
|
end
|
|
155
|
-
# :
|
|
155
|
+
# simplecov:disable
|
|
156
156
|
else
|
|
157
157
|
# Always use optimized version
|
|
158
158
|
def _select_set_multiple(ret_cols)
|
|
@@ -170,7 +170,7 @@ class Sequel::Postgres::Dataset
|
|
|
170
170
|
set
|
|
171
171
|
end
|
|
172
172
|
end
|
|
173
|
-
# :
|
|
173
|
+
# simplecov:enable
|
|
174
174
|
end
|
|
175
175
|
|
|
176
176
|
if defined?(Sequel::Model::ClassMethods)
|
|
@@ -189,10 +189,10 @@ if defined?(Sequel::Postgres::PGArray)
|
|
|
189
189
|
# pg_array extension previously loaded
|
|
190
190
|
|
|
191
191
|
class Sequel::Postgres::PGArray::Creator
|
|
192
|
-
# :
|
|
192
|
+
# simplecov:disable
|
|
193
193
|
# Avoid method redefined verbose warning
|
|
194
194
|
alias call call if method_defined?(:call)
|
|
195
|
-
# :
|
|
195
|
+
# simplecov:enable
|
|
196
196
|
|
|
197
197
|
# Override Creator to use sequel_pg's C-based parser instead of the pure ruby parser.
|
|
198
198
|
def call(string)
|
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.
|
|
4
|
+
version: 1.20.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Jeremy Evans
|
|
@@ -100,7 +100,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
100
100
|
- !ruby/object:Gem::Version
|
|
101
101
|
version: '0'
|
|
102
102
|
requirements: []
|
|
103
|
-
rubygems_version: 4.0.
|
|
103
|
+
rubygems_version: 4.0.16
|
|
104
104
|
specification_version: 4
|
|
105
105
|
summary: Faster SELECTs when using Sequel with pg
|
|
106
106
|
test_files: []
|