arel_toolkit 0.4.5 → 0.4.6

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.
@@ -42,7 +42,7 @@ module Arel
42
42
  # RANGE only unbounded
43
43
  # ROWS all
44
44
  # https://github.com/postgres/postgres/blob/REL_10_1/src/include/nodes/parsenodes.h
45
- FRAMEOPTIONS = {
45
+ FRAMEOPTIONS_V10 = {
46
46
  'FRAMEOPTION_NONDEFAULT' => 0x00001,
47
47
  'FRAMEOPTION_RANGE' => 0x00002,
48
48
  'FRAMEOPTION_ROWS' => 0x00004,
@@ -59,6 +59,38 @@ module Arel
59
59
  'FRAMEOPTION_END_VALUE_FOLLOWING' => 0x02000,
60
60
  }.freeze
61
61
 
62
+ FRAMEOPTIONS_V11_AND_UP = {
63
+ 'FRAMEOPTION_NONDEFAULT' => 0x00001, # any specified? */
64
+ 'FRAMEOPTION_RANGE' => 0x00002, # RANGE behavior */
65
+ 'FRAMEOPTION_ROWS' => 0x00004, # ROWS behavior */
66
+ 'FRAMEOPTION_GROUPS' => 0x00008, # GROUPS behavior */
67
+ 'FRAMEOPTION_BETWEEN' => 0x00010, # BETWEEN given? */
68
+ 'FRAMEOPTION_START_UNBOUNDED_PRECEDING' => 0x00020, # start is U. P. */
69
+ 'FRAMEOPTION_END_UNBOUNDED_PRECEDING' => 0x00040, # (disallowed) */
70
+ 'FRAMEOPTION_START_UNBOUNDED_FOLLOWING' => 0x00080, # (disallowed) */
71
+ 'FRAMEOPTION_END_UNBOUNDED_FOLLOWING' => 0x00100, # end is U. F. */
72
+ 'FRAMEOPTION_START_CURRENT_ROW' => 0x00200, # start is C. R. */
73
+ 'FRAMEOPTION_END_CURRENT_ROW' => 0x00400, # end is C. R. */
74
+ 'FRAMEOPTION_START_OFFSET_PRECEDING' => 0x00800, # start is O. P. */
75
+ 'FRAMEOPTION_END_OFFSET_PRECEDING' => 0x01000, # end is O. P. */
76
+ 'FRAMEOPTION_START_OFFSET_FOLLOWING' => 0x02000, # start is O. F. */
77
+ 'FRAMEOPTION_END_OFFSET_FOLLOWING' => 0x04000, # end is O. F. */
78
+ 'FRAMEOPTION_EXCLUDE_CURRENT_ROW' => 0x08000, # omit C.R. */
79
+ 'FRAMEOPTION_EXCLUDE_GROUP' => 0x10000, # omit C.R. & peers */
80
+ 'FRAMEOPTION_EXCLUDE_TIES' => 0x20000, # omit C.R.'s peers */
81
+ }.freeze
82
+
83
+ def frameoptions
84
+ case PG.library_version.to_s[0, 2]
85
+ when '09', '10'
86
+ FRAMEOPTIONS_V10
87
+ when '11', '12', '13', '14'
88
+ FRAMEOPTIONS_V11_AND_UP
89
+ else
90
+ boom "Version #{PG.library_version.to_s[0, 2]} not supported"
91
+ end
92
+ end
93
+
62
94
  def biggest_detractable_number(number, candidates)
63
95
  high_to_low_candidates = candidates.sort { |a, b| b <=> a }
64
96
  high_to_low_candidates.find do |candidate|
@@ -69,8 +101,8 @@ module Arel
69
101
  def calculate_frame_option_names(frame_options, names = [])
70
102
  return names if frame_options.zero?
71
103
 
72
- number = biggest_detractable_number(frame_options, FRAMEOPTIONS.values)
73
- name = FRAMEOPTIONS.key(number)
104
+ number = biggest_detractable_number(frame_options, frameoptions.values)
105
+ name = frameoptions.key(number)
74
106
  calculate_frame_option_names(
75
107
  frame_options - number, names + [name]
76
108
  )
@@ -95,10 +127,10 @@ module Arel
95
127
  when 'CURRENT_ROW'
96
128
  Arel::Nodes::CurrentRow.new
97
129
 
98
- when 'VALUE_PRECEDING'
130
+ when 'VALUE_PRECEDING', 'OFFSET_PRECEDING'
99
131
  Arel::Nodes::Preceding.new offset
100
132
 
101
- when 'VALUE_FOLLOWING'
133
+ when 'VALUE_FOLLOWING', 'OFFSET_FOLLOWING'
102
134
  Arel::Nodes::Following.new offset
103
135
 
104
136
  else
@@ -119,17 +119,19 @@ module Arel
119
119
 
120
120
  # https://www.rubydoc.info/github/rubyworks/facets/String:unquote
121
121
  def unquote_string(string)
122
+ s = string.dup
123
+
122
124
  case string[0, 1]
123
125
  when "'", '"', '`'
124
- string[0] = ''
126
+ s[0] = ''
125
127
  end
126
128
 
127
129
  case string[-1, 1]
128
130
  when "'", '"', '`'
129
- string[-1] = ''
131
+ s[-1] = ''
130
132
  end
131
133
 
132
- string
134
+ s
133
135
  end
134
136
 
135
137
  def database_object_mapping
@@ -1,3 +1,3 @@
1
1
  module ArelToolkit
2
- VERSION = '0.4.5'.freeze
2
+ VERSION = '0.4.6'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: arel_toolkit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.5
4
+ version: 0.4.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - maarten
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-07-08 00:00:00.000000000 Z
11
+ date: 2021-07-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -16,14 +16,20 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: 5.0.0
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: 6.0.4
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
27
  - - ">="
25
28
  - !ruby/object:Gem::Version
26
- version: '0'
29
+ version: 5.0.0
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: 6.0.4
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: pg
29
35
  requirement: !ruby/object:Gem::Requirement
@@ -44,14 +50,14 @@ dependencies:
44
50
  requirements:
45
51
  - - "~>"
46
52
  - !ruby/object:Gem::Version
47
- version: '1.3'
53
+ version: '2.1'
48
54
  type: :runtime
49
55
  prerelease: false
50
56
  version_requirements: !ruby/object:Gem::Requirement
51
57
  requirements:
52
58
  - - "~>"
53
59
  - !ruby/object:Gem::Version
54
- version: '1.3'
60
+ version: '2.1'
55
61
  - !ruby/object:Gem::Dependency
56
62
  name: bundler
57
63
  requirement: !ruby/object:Gem::Requirement
@@ -156,14 +162,14 @@ dependencies:
156
162
  requirements:
157
163
  - - "~>"
158
164
  - !ruby/object:Gem::Version
159
- version: 2.2.0
165
+ version: 2.4.1
160
166
  type: :development
161
167
  prerelease: false
162
168
  version_requirements: !ruby/object:Gem::Requirement
163
169
  requirements:
164
170
  - - "~>"
165
171
  - !ruby/object:Gem::Version
166
- version: 2.2.0
172
+ version: 2.4.1
167
173
  - !ruby/object:Gem::Dependency
168
174
  name: database_cleaner
169
175
  requirement: !ruby/object:Gem::Requirement
@@ -406,6 +412,7 @@ files:
406
412
  - ".rspec"
407
413
  - ".rubocop.yml"
408
414
  - ".ruby-version"
415
+ - ".tool-versions"
409
416
  - Appraisals
410
417
  - CHANGELOG.md
411
418
  - CODE_OF_CONDUCT.md
@@ -419,6 +426,7 @@ files:
419
426
  - benchmark.rb
420
427
  - bin/console
421
428
  - bin/setup
429
+ - docker-compose.yml
422
430
  - ext/pg_result_init/extconf.rb
423
431
  - ext/pg_result_init/pg_result_init.c
424
432
  - ext/pg_result_init/pg_result_init.h
@@ -593,7 +601,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
593
601
  - !ruby/object:Gem::Version
594
602
  version: '0'
595
603
  requirements: []
596
- rubygems_version: 3.0.3
604
+ rubygems_version: 3.1.6
597
605
  signing_key:
598
606
  specification_version: 4
599
607
  summary: Collection of tools for Arel