query_helper 0.2.29 → 0.3.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6393029fea1bbf5dcc2e0c724689a7a9eada99b0bcba65896ddfcb4704442130
4
- data.tar.gz: a988a611a54efa8ea34080294b92c278bb5dbc3cf59e3598b1e7a3668f87343c
3
+ metadata.gz: b9626c22503b7f257a4276b969a498a017753e879e30b04b6643c618ae8f03d4
4
+ data.tar.gz: 825fdbf988d8a41abd89d250aa6d56f0add379fced68e630099ea688cde9b586
5
5
  SHA512:
6
- metadata.gz: 8c9a16cf6b3706de8eede885b7301d433b2317ea8bb1136d4386d7248c11dd06851d51d9ba6bd3536382b37103ed22554ce757ddb63ea85f6af43e62dcbc6650
7
- data.tar.gz: b6f5bf13fee17da7f195a6ff4e38afe68020379782ada889514654c769014ec41dc31ca7eafc743299dac5cf729cc27c842c7b72cb5ce55984dc3bb9548666f2
6
+ metadata.gz: 1ce4589b5783e435ec47b22b2e04b094d8f5da5703b439510b7a9570d8dc0d87d505d2e2fca6125b1c180707bcae9001af9d3f40003c2747966f09a420978237
7
+ data.tar.gz: 9c8188da6470cd4469a4825e21725cbc1d19b5fcd1f246eb0d86d2dddd589ddcb7be30c8a500a3650b1a61fb2d2a622f6ff41388a8193bacda3544ca3974d81c
@@ -0,0 +1,26 @@
1
+ name: Brakeman
2
+
3
+ on: [push]
4
+
5
+ jobs:
6
+ brakeman:
7
+ runs-on: ubuntu-latest
8
+ steps:
9
+ - uses: actions/checkout@v2
10
+
11
+ - name: Set up Ruby 2.7.2
12
+ uses: ruby/setup-ruby@v1
13
+ with:
14
+ # Not needed with a .ruby-version file
15
+ ruby-version: 2.7.2
16
+ # runs 'bundle install' and caches installed gems automatically
17
+ bundler-cache: true
18
+
19
+ - name: Brakeman install
20
+ run: gem install brakeman
21
+
22
+ - name: brakeman
23
+ id: brakeman
24
+ run: |
25
+ brakeman --color --force -q
26
+ if [ $? -ne 0 ]; then return 1; fi
@@ -0,0 +1,20 @@
1
+ name: Publish Gem
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - v*
7
+ jobs:
8
+ build:
9
+ runs-on: ubuntu-latest
10
+
11
+ steps:
12
+ - uses: actions/checkout@v1
13
+
14
+ - name: Release Gem
15
+ if: contains(github.ref, 'refs/tags/v')
16
+ uses: cadwallion/publish-rubygems-action@master
17
+ env:
18
+ GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
19
+ RUBYGEMS_API_KEY: ${{secrets.RUBYGEMS_API_KEY}}
20
+ RELEASE_COMMAND: rake release
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- query_helper (0.2.29)
4
+ query_helper (0.3.4)
5
5
  activerecord (> 5)
6
6
  activesupport (> 5)
7
7
  sqlite3
@@ -43,13 +43,13 @@ GEM
43
43
  i18n (>= 0.7)
44
44
  i18n (1.8.10)
45
45
  concurrent-ruby (~> 1.0)
46
- loofah (2.12.0)
46
+ loofah (2.18.0)
47
47
  crass (~> 1.0.2)
48
48
  nokogiri (>= 1.5.9)
49
49
  method_source (1.0.0)
50
50
  mini_portile2 (2.8.0)
51
51
  minitest (5.14.4)
52
- nokogiri (1.13.3)
52
+ nokogiri (1.13.8)
53
53
  mini_portile2 (~> 2.8.0)
54
54
  racc (~> 1.4)
55
55
  racc (1.6.0)
@@ -59,7 +59,7 @@ GEM
59
59
  rails-dom-testing (2.0.3)
60
60
  activesupport (>= 4.2.0)
61
61
  nokogiri (>= 1.6)
62
- rails-html-sanitizer (1.4.2)
62
+ rails-html-sanitizer (1.4.3)
63
63
  loofah (~> 2.3)
64
64
  railties (6.1.4.1)
65
65
  actionpack (= 6.1.4.1)
@@ -89,7 +89,8 @@ GEM
89
89
  rspec-mocks (~> 3.10)
90
90
  rspec-support (~> 3.10)
91
91
  rspec-support (3.10.2)
92
- sqlite3 (1.4.2)
92
+ sqlite3 (1.6.2)
93
+ mini_portile2 (~> 2.8.0)
93
94
  thor (1.1.0)
94
95
  tzinfo (2.0.4)
95
96
  concurrent-ruby (~> 1.0)
@@ -8,12 +8,24 @@ class QueryHelper
8
8
  def self.load_associations(payload:, associations: [], as_json_options: {})
9
9
  as_json_options ||= {}
10
10
  as_json_options[:include] = as_json_options[:include] || json_associations(associations)
11
- ActiveRecord::Associations::Preloader.new.preload(payload, associations)
11
+ begin
12
+ # Preloader have been changed in Rails 7, which is giving error on upgrade.
13
+ # This should be updated to latest API once all repos have been upgraded to Rails 7
14
+ ActiveRecord::Associations::Preloader.new.preload(payload, associations)
15
+ rescue
16
+ ActiveRecord::Associations::Preloader.new(records: payload, associations: associations).call
17
+ end
12
18
  payload.as_json(as_json_options)
13
19
  end
14
20
 
15
21
  def self.preload_associations(payload:, preload: [])
16
- ActiveRecord::Associations::Preloader.new.preload(payload, preload)
22
+ begin
23
+ # Preloader have been changed in Rails 7, which is giving error on upgrade.
24
+ # This should be updated to latest API once all repos have been upgraded to Rails 7
25
+ ActiveRecord::Associations::Preloader.new.preload(payload, preload)
26
+ rescue
27
+ ActiveRecord::Associations::Preloader.new(records: payload, associations: preload).call
28
+ end
17
29
  end
18
30
 
19
31
  def self.json_associations(associations)
@@ -26,7 +26,8 @@ class QueryHelper
26
26
  end
27
27
 
28
28
  def create_query_helper_filter
29
- filter_values = params[:filter].permit!.to_h
29
+ # Here we get dynamic filter variable and hence we can't define permit.
30
+ filter_values = params[:filter].to_unsafe_h
30
31
  QueryHelper::SqlFilter.new(filter_values: filter_values)
31
32
  end
32
33
 
@@ -26,8 +26,8 @@ class QueryHelper
26
26
  end
27
27
 
28
28
  def build
29
- insert_having_clauses()
30
29
  insert_qualify_clauses()
30
+ insert_having_clauses()
31
31
  insert_where_clauses()
32
32
  insert_select_clauses()
33
33
  insert_order_by_and_limit_clause()
@@ -49,7 +49,7 @@ class QueryHelper
49
49
 
50
50
  def qualify_clauses(index)
51
51
  if index == 0
52
- "qualified_results AS ( "
52
+ "WITH qualified_results AS ( "
53
53
  else
54
54
  ", qualified_results AS ( "
55
55
  end
@@ -114,7 +114,7 @@ class QueryHelper
114
114
  end
115
115
 
116
116
  def insert_where_index
117
- group_by_index() || order_by_index() || limit_index() || @sql.length
117
+ qualify_index() || group_by_index() || order_by_index() || limit_index() || @sql.length
118
118
  end
119
119
 
120
120
  def insert_qualify_index
@@ -1,3 +1,3 @@
1
1
  class QueryHelper
2
- VERSION = "0.2.29"
2
+ VERSION = "0.3.4"
3
3
  end
data/query_helper.gemspec CHANGED
@@ -6,12 +6,12 @@ require "query_helper/version"
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = "query_helper"
8
8
  spec.version = QueryHelper::VERSION
9
- spec.authors = ["Evan McDaniel"]
10
- spec.email = ["eamigo13@gmail.com"]
9
+ spec.authors = ["Patterninc"]
10
+ spec.email = ["jason@pattern.com"]
11
11
 
12
12
  spec.summary = %q{Ruby Gem to help with pagination and data formatting at Pattern, Inc.}
13
13
  spec.description = %q{Ruby gem developed to help with pagination, filtering, sorting, and including associations on both active record queries and custom sql queries}
14
- spec.homepage = "https://github.com/iserve-products/query_helper"
14
+ spec.homepage = "https://github.com/patterninc/query_helper"
15
15
  spec.license = "MIT"
16
16
 
17
17
  # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: query_helper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.29
4
+ version: 0.3.4
5
5
  platform: ruby
6
6
  authors:
7
- - Evan McDaniel
7
+ - Patterninc
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-05-24 00:00:00.000000000 Z
11
+ date: 2023-04-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -167,12 +167,14 @@ dependencies:
167
167
  description: Ruby gem developed to help with pagination, filtering, sorting, and including
168
168
  associations on both active record queries and custom sql queries
169
169
  email:
170
- - eamigo13@gmail.com
170
+ - jason@pattern.com
171
171
  executables: []
172
172
  extensions: []
173
173
  extra_rdoc_files: []
174
174
  files:
175
+ - ".github/workflows/brakeman.yml"
175
176
  - ".github/workflows/ci.yml"
177
+ - ".github/workflows/publish_rubygems.yml"
176
178
  - ".gitignore"
177
179
  - ".rspec"
178
180
  - CODE_OF_CONDUCT.md
@@ -195,7 +197,7 @@ files:
195
197
  - lib/query_helper/sql_sort.rb
196
198
  - lib/query_helper/version.rb
197
199
  - query_helper.gemspec
198
- homepage: https://github.com/iserve-products/query_helper
200
+ homepage: https://github.com/patterninc/query_helper
199
201
  licenses:
200
202
  - MIT
201
203
  metadata: {}