activegraph-extensions 0.0.1-java → 0.0.3-java

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9c33fee6eede1db2664a17ae82a9f7dcb0d3611b2665605a024fd184a2695fa9
4
- data.tar.gz: ea57d1a76c541d3b5c8c655f1b4cea22142917c83500a2275f4f2fc177f120af
3
+ metadata.gz: fbb2be9a5d8f1afc55b3888e1afc33940a2eb709de5afae7144f25992d2d0873
4
+ data.tar.gz: 23a259b8d2dffd7e6f73e552275fe0d9b9849bfcb80bc437be21c6e32944d5fe
5
5
  SHA512:
6
- metadata.gz: dc88d9b5d715d803ede073cfd97f60bdbb4b1efe93231416a95ba3963d5831af872bf7e55e53906061693009f9e052e725dea8e80bd8a1a5e44864221659b4ad
7
- data.tar.gz: d0b79494bac58f25b9c972951c7bce4d27beb33c5bdcbf865905a81401375b344ab9b9cb101360e93aa1db9bfcc14015ecc1b7a853623e90f9a6a7ca59ff67a0
6
+ metadata.gz: 55a7e0e10065e825acef207348a9277162af5d6ec81b158b957b266e37ba0fa98c6aa620cca84a31b253a58574880742a13d7f7f7cda576fd1f7dab3e60eda15
7
+ data.tar.gz: 679aa1b9d1ad94633506b1938cb3d50ea3bd2af2bd9392f352370f5d4410476cabf1a327bae1d6cafdbd18f5b62650b94584c826ea65cb4bb61be1a035eaa57a
data/CHANGELOG.md CHANGED
@@ -1 +1,7 @@
1
- # Change Log
1
+ # Change Log
2
+
3
+ ## [0.0.3] 2023-02-23
4
+
5
+ ## Fixed
6
+
7
+ - Fixed issue where there was 500 error when we are eagerloding relations with multiple optional matches and some privious match was haveing authorization and next one was skipping authorization for those same nodes. This would result in a collection of related nodes where some nodes were null and corresponding next optional match nodes on path had values.
data/README.md CHANGED
@@ -1 +1 @@
1
- # Extensions to activegraph gem.
1
+ # Extensions to activegraph gem.
@@ -33,7 +33,6 @@ DESCRIPTION
33
33
  s.add_development_dependency('guard-rspec')
34
34
  s.add_development_dependency('guard-rubocop')
35
35
  s.add_development_dependency('neo4j-rake_tasks', '>= 0.3.0')
36
- # s.add_development_dependency("neo4j-#{ENV['driver'] == 'java' ? 'java' : 'ruby'}-driver", '~> 4.1.0.beta.1')
37
36
  s.add_development_dependency('os')
38
37
  s.add_development_dependency('pry')
39
38
  s.add_development_dependency('railties', '>= 4.0')
@@ -45,8 +45,9 @@ module ActiveGraphExtensions
45
45
  end
46
46
 
47
47
  def limit_node_in_where_clause(query, path)
48
- root_path = path[0..0]
49
- query.where("`#{path_name(root_path)}` in [i IN #{node_from_collection(root_path)} | i[1]]")
48
+ (path.length - 1).times.inject(query) do |query_with_where, index|
49
+ query_with_where.where("`#{path_name(path[0..index])}` in [i IN #{node_from_collection(path[0..index])} | i[1]]")
50
+ end
50
51
  end
51
52
 
52
53
  def node_from_collection(path_step)
@@ -35,20 +35,10 @@ module ActiveGraphExtensions
35
35
  end
36
36
 
37
37
  def process_string(str)
38
- # head, rest = str.split('.', 2)
39
- # head, association_limit = extract_assoc_limit(head)
40
- # k, length = head.split('*', -2)
41
- # length = { max: length } if length
42
- #add_nested(k.to_sym, rest, length, association_limit)
43
38
  map = StringParsers::RelationParser.new.parse(str)
44
39
  add_nested(map[:rel_name].to_sym, map[:rest_str].to_s.presence, map[:length_part], map[:limit_digit])
45
40
  end
46
41
 
47
- # def extract_assoc_limit(str)
48
- # transformer = StringParsers::RelationParamTransformer.new(str)
49
- # [transformer.rel_name_n_length, transformer.rel_limit_number]
50
- # end
51
-
52
42
  def process_hash(spec)
53
43
  spec = spec.dup
54
44
  @options = spec.delete(:_options)
@@ -10,10 +10,8 @@ module ActiveGraphExtensions
10
10
  rel_model = relationship_model(path)
11
11
  return {} if @opts.blank? || !(auth_scope = authorized_scope(rel_model, path))
12
12
  conf = { rels: [], chain: {} }
13
- proxy = auth_scope.call(var, "#{var}_rel", user: @opts[:user],
14
- properties: properties_for(rel_model),
15
- privileges: @opts[:privileges],
16
- rel_length: path.last.rel_length)
13
+ proxy = auth_scope.call(var, "#{var}_rel", @opts.merge(properties: properties_for(rel_model),
14
+ rel_length: path.last.rel_length))
17
15
  proxy_rel_parts(proxy.instance_variable_get(:@break_proxy) || proxy, conf)
18
16
  conf
19
17
  end
@@ -57,7 +57,7 @@ module ActiveGraphExtensions
57
57
 
58
58
  def optional_match_with_where(query, path, vars)
59
59
  computed_query = super
60
- computed_query = limit_node_in_where_clause(computed_query, path) if multipath_with_sideload_limit?(path)
60
+ computed_query = limit_node_in_where_clause(computed_query, path) if multipath?(path)
61
61
  skip_order? && !path.last.rel_length ? computed_query : optional_order(computed_query, path, vars)
62
62
  end
63
63
 
@@ -4,20 +4,19 @@ module ActiveGraphExtensions
4
4
  module StringParsers
5
5
  # Parsing relationships with length
6
6
  class RelationParser < ::Parslet::Parser
7
- rule(:asterix) { str('*') }
8
- rule(:digit) { match('[\d]').repeat }
9
- rule(:range) { str('..') }
10
- rule(:dot) { str('.') }
11
- rule(:zero) { str('0') }
12
- rule(:length_1) { zero.as(:min) >> range >> digit.maybe.as(:max) }
13
- rule(:length_2) { digit.maybe.as(:max) }
14
- rule(:length) { asterix >> (length_1 | length_2) }
15
- rule(:rel) { match('[a-z,_]').repeat.as(:rel_name) }
16
- rule(:limit) { digit.as(:limit_digit) >> asterix }
17
- rule(:key) { limit.maybe >> rel >> length.as(:length_part).maybe }
18
- rule(:anything) { match('.').repeat }
19
- rule(:root) { key >> dot.maybe >> anything.maybe.as(:rest_str) }
7
+ include SharedRules
20
8
 
9
+ # TODO: It is very bad to build a grammar with none terminals. Please note that none here are necessary to
10
+ # mimic the previous behavior of `repeat` which is `repeat(0)` which effectively allows empty strings as
11
+ # identifiers
12
+ rule(:zero) { str('0') }
13
+ rule(:length_1) { zero.as(:min) >> range >> number?.maybe.as(:max) }
14
+ rule(:length_2) { number?.maybe.as(:max) }
15
+ rule(:length) { asterisk >> (length_1 | length_2) }
16
+ rule(:limit) { number?.as(:limit_digit) >> asterisk }
17
+ rule(:key) { limit.maybe >> rel >> length.as(:length_part).maybe }
18
+ rule(:anything) { match('.').repeat }
19
+ rule(:root) { key >> dot.maybe >> anything.maybe.as(:rest_str) }
21
20
  rule(:rel_sequence) { infix_expression(key, [dot, 1, :left]) }
22
21
  end
23
22
  end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActiveGraphExtensions
4
+ module StringParsers
5
+ module SharedRules
6
+ extend ActiveSupport::Concern
7
+ VAR_CHAR = 'a-z_'
8
+ included do
9
+ rule(:asterisk) { str('*') }
10
+ rule(:number) { match('[\d]').repeat(1) }
11
+ rule(:none) { str('') }
12
+ rule(:number?) { number | none }
13
+ rule(:range) { str('..') }
14
+ rule(:dot) { str('.') }
15
+ rule(:identifier) { match("[#{VAR_CHAR}]") >> match("[#{VAR_CHAR}0-9]").repeat(0) }
16
+ rule(:identifier?) { identifier | none }
17
+ rule(:rel) { identifier?.as(:rel_name) }
18
+ end
19
+ end
20
+ end
21
+ end
@@ -1,3 +1,3 @@
1
1
  module ActiveGraphExtensions
2
- VERSION = '0.0.1'
2
+ VERSION = '0.0.3'
3
3
  end
@@ -4,10 +4,7 @@ require 'parslet'
4
4
  module ActiveGraphExtensions
5
5
  end
6
6
 
7
- loader = Zeitwerk::Loader.for_gem
8
- loader.inflector.inflect 'version' => 'VERSION'
9
- loader.ignore(File.expand_path('activegraph-extensions.rb', __dir__))
10
- loader.setup
7
+ Zeitwerk::Loader.for_gem.setup
11
8
 
12
9
  ActiveGraph::Node::Query::QueryProxy.include ActiveGraphExtensions::Node::Query::QueryProxyEagerLoading
13
10
  ActiveGraph::Node::Query::QueryProxy.prepend ActiveGraphExtensions::Node::Query::QueryProxy
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activegraph-extensions
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.3
5
5
  platform: java
6
6
  authors:
7
7
  - Amit Suryavanshi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-01-17 00:00:00.000000000 Z
11
+ date: 2023-02-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
@@ -218,8 +218,7 @@ files:
218
218
  - Gemfile
219
219
  - README.md
220
220
  - activegraph-extensions.gemspec
221
- - lib/active_graph_extensions/node.rb
222
- - lib/active_graph_extensions/node/query.rb
221
+ - lib/active_graph_extensions.rb
223
222
  - lib/active_graph_extensions/node/query/query_proxy.rb
224
223
  - lib/active_graph_extensions/node/query/query_proxy_eager_loading.rb
225
224
  - lib/active_graph_extensions/node/query/query_proxy_eager_loading/association_eager_load.rb
@@ -227,10 +226,9 @@ files:
227
226
  - lib/active_graph_extensions/node/query/query_proxy_eager_loading/eager_loading_order.rb
228
227
  - lib/active_graph_extensions/node/query/query_proxy_eager_loading/enhanced_tree.rb
229
228
  - lib/active_graph_extensions/node/query/query_proxy_eager_loading/scope_eager_loading.rb
230
- - lib/active_graph_extensions/string_parsers.rb
231
229
  - lib/active_graph_extensions/string_parsers/relation_parser.rb
230
+ - lib/active_graph_extensions/string_parsers/shared_rules.rb
232
231
  - lib/active_graph_extensions/version.rb
233
- - lib/activegraph-extensions.rb
234
232
  homepage: https://github.com/neo4jrb/activegraph-extensions/
235
233
  licenses:
236
234
  - MIT
@@ -1,8 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module ActiveGraphExtensions
4
- module Node
5
- module Query
6
- end
7
- end
8
- end
@@ -1,6 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module ActiveGraphExtensions
4
- module Node
5
- end
6
- end
@@ -1,6 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module ActiveGraphExtensions
4
- module StringParsers
5
- end
6
- end