From ae21b4d4cea86cdea32c3950b4a4ecf18c2942f5 Mon Sep 17 00:00:00 2001 From: Heinrich Klobuczek Date: Tue, 22 Feb 2022 11:46:48 -0900 Subject: [PATCH 1/7] testing driver 1.7 on neo4j 4.4 --- .github/workflows/test.yml | 2 +- lib/active_graph/core/schema.rb | 40 ++++++++++++++++++--------------- spec/active_graph/base_spec.rb | 2 +- spec/e2e/id_property_spec.rb | 2 +- 4 files changed, 25 insertions(+), 21 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ece9538b0..b201c24f7 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -16,7 +16,7 @@ jobs: fail-fast: false matrix: ruby: [ 2.5, 3.0, 3.1, jruby-9.3.3.0 ] - neo4j: [ 3.5.30, 4.0.12 ] + neo4j: [ 3.5.30, 4.0.12, 4.1.11, 4.2.15, 4.3.10, 4.4.4 ] driver: [ ffi ] include: - ruby: jruby-9.3.3.0 diff --git a/lib/active_graph/core/schema.rb b/lib/active_graph/core/schema.rb index 535efc033..5aae0270c 100644 --- a/lib/active_graph/core/schema.rb +++ b/lib/active_graph/core/schema.rb @@ -2,28 +2,32 @@ module ActiveGraph module Core module Schema def version - result = query('CALL dbms.components()', {}, skip_instrumentation: true) - # BTW: community / enterprise could be retrieved via `result.first.edition` - result.first[:versions][0] + query('CALL dbms.components()', {}, skip_instrumentation: true).first[:versions][0] end def indexes - result = query('CALL db.indexes()', {}, skip_instrumentation: true) - - result.map do |row| - { type: row[:type].to_sym, label: label(result, row), properties: properties(row), state: row[:state].to_sym } + raw_indexes do |keys, result| + result.map do |row| + { type: row[:type].to_sym, label: label(keys, row), properties: properties(row), + state: row[:state].to_sym } + end end end def constraints - result = query('CALL db.indexes()', {}, skip_instrumentation: true) - - result.select(&method(v4?(result) ? :v4_filter : :v3_filter)).map do |row| - { type: :uniqueness, label: label(result, row), properties: properties(row) } + raw_indexes do |keys, result| + result.select(&method(v4?(keys) ? :v4_filter : :v3_filter)).map do |row| + { type: :uniqueness, label: label(keys, row), properties: properties(row) } + end end end + def raw_indexes + result = query('CALL db.indexes()', {}, skip_instrumentation: true) + yield result.keys, result.reject { |row| row[:type] == 'LOOKUP' } + end + private def v4_filter(row) @@ -34,22 +38,22 @@ def v3_filter(row) row[:type] == 'node_unique_property' end - def label(result, row) - if v34?(result) + def label(keys, row) + if v34?(keys) row[:label] else - (v4?(result) ? row[:labelsOrTypes] : row[:tokenNames]).first + (v4?(keys) ? row[:labelsOrTypes] : row[:tokenNames]).first end.to_sym end - def v4?(result) + def v4?(keys) return @v4 unless @v4.nil? - @v4 = result.keys.include?(:labelsOrTypes) + @v4 = keys.include?(:labelsOrTypes) end - def v34?(result) + def v34?(keys) return @v34 unless @v34.nil? - @v34 = result.keys.include?(:label) + @v34 = keys.include?(:label) end def properties(row) diff --git a/spec/active_graph/base_spec.rb b/spec/active_graph/base_spec.rb index 4e1042011..3fe107da3 100644 --- a/spec/active_graph/base_spec.rb +++ b/spec/active_graph/base_spec.rb @@ -363,7 +363,7 @@ def create_index(label_name, property, options = {}) describe 'Clause ordering error' do it 'raises an error' do expect do - described_class.query("RETURN a CREATE (a:Album {uuid: 'dup'})").to_a + described_class.query("RETURN 1 CREATE (a:Album {uuid: 'dup'})").to_a end.to raise_error Neo4j::Driver::Exceptions::ClientException, /RETURN can only be used at the end of the query/ end end diff --git a/spec/e2e/id_property_spec.rb b/spec/e2e/id_property_spec.rb index 1a55ba0b0..80149da8a 100644 --- a/spec/e2e/id_property_spec.rb +++ b/spec/e2e/id_property_spec.rb @@ -195,7 +195,7 @@ end - EXISTS_REGEXP = /Node.\d+\)? already exists with label/ + EXISTS_REGEXP = /Node.\d+\)? already exists with label|New data does not satisfy Constraint/ describe 'id_property :my_id, on: :foobar' do before do From b69b8fd1a852b4671478f27f2ba07f703bc3b103 Mon Sep 17 00:00:00 2001 From: Heinrich Klobuczek Date: Tue, 22 Feb 2022 11:52:52 -0900 Subject: [PATCH 2/7] tap --- .github/workflows/test.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b201c24f7..5b13c2770 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -5,10 +5,7 @@ on: branches: [ '10' ] pull_request: branches: [ '10' ] - - # Allows you to run this workflow manually from the Actions tab workflow_dispatch: - jobs: test: runs-on: ubuntu-18.04 From f0e10ce61a71e8eca6c87b7b060f38a0339776b0 Mon Sep 17 00:00:00 2001 From: Heinrich Klobuczek Date: Tue, 22 Feb 2022 12:40:14 -0900 Subject: [PATCH 3/7] fixed some specs --- spec/active_graph/base_spec.rb | 2 +- spec/unit/shared/attributes_spec.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/active_graph/base_spec.rb b/spec/active_graph/base_spec.rb index 3fe107da3..e3c9e3e36 100644 --- a/spec/active_graph/base_spec.rb +++ b/spec/active_graph/base_spec.rb @@ -356,7 +356,7 @@ def create_index(label_name, property, options = {}) it 'raises an error' do expect do described_class.query("CRATE (:Album {uuid: 'dup'})").to_a - end.to raise_error(Neo4j::Driver::Exceptions::ClientException, /Invalid input 'A'/) + end.to raise_error(Neo4j::Driver::Exceptions::ClientException, /Invalid input '.*A.*'/) end end diff --git a/spec/unit/shared/attributes_spec.rb b/spec/unit/shared/attributes_spec.rb index 3e2f2285f..aaa4d2df2 100644 --- a/spec/unit/shared/attributes_spec.rb +++ b/spec/unit/shared/attributes_spec.rb @@ -222,7 +222,7 @@ def self.name it 'raises when setting an undefined attribute' do expect do model.send(method, :initials, 'BP') - end.to raise_error ActiveGraph::UnknownAttributeError, 'unknown attribute: initials' + end.to raise_error ActiveGraph::UnknownAttributeError, /unknown attribute: initials/ end end end From 384932b92026e7a3f50fffc880882fa292eee958 Mon Sep 17 00:00:00 2001 From: Heinrich Klobuczek Date: Tue, 22 Feb 2022 13:01:29 -0900 Subject: [PATCH 4/7] fixed some specs --- lib/active_graph/migrations/base.rb | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/active_graph/migrations/base.rb b/lib/active_graph/migrations/base.rb index 97237d567..4867b8dfe 100644 --- a/lib/active_graph/migrations/base.rb +++ b/lib/active_graph/migrations/base.rb @@ -57,9 +57,13 @@ def run_migration(direction) end def handle_migration_error!(e) - fail e unless e.message =~ /Cannot perform data updates in a transaction that has performed schema updates./ - fail MigrationError, - "#{e.message}. Please add `disable_transactions!` in your migration file." + if e.is_a?(Neo4j::Driver::Exceptions::ClientException) && + e.code == 'Neo.ClientError.Transaction.ForbiddenDueToTransactionType' || + e.message =~ /Cannot perform data updates in a transaction that has performed schema updates./ + fail MigrationError, "#{e.message}. Please add `disable_transactions!` in your migration file." + else + fail e + end end def migration_transaction(&block) From 29a4988dce258f0a10401017bf44a174e9a8f324 Mon Sep 17 00:00:00 2001 From: Heinrich Klobuczek Date: Tue, 22 Feb 2022 13:27:55 -0900 Subject: [PATCH 5/7] restructured build matrix --- .github/workflows/test.yml | 19 ++++++++++++++++++- lib/active_graph/version.rb | 2 +- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 5b13c2770..7d4825446 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -13,8 +13,9 @@ jobs: fail-fast: false matrix: ruby: [ 2.5, 3.0, 3.1, jruby-9.3.3.0 ] - neo4j: [ 3.5.30, 4.0.12, 4.1.11, 4.2.15, 4.3.10, 4.4.4 ] + neo4j: [ 3.5.30, 4.0.12 ] driver: [ ffi ] + experimental: [ false ] include: - ruby: jruby-9.3.3.0 neo4j: 4.0.12 @@ -24,6 +25,22 @@ jobs: driver: ffi java-version: 8 active-model-version: 5.2.3 + - ruby: 3.1 + neo4j: 4.1.11 + driver: ffi + experimental: true + - ruby: 3.1 + neo4j: 4.2.15 + driver: ffi + experimental: true + - ruby: 3.1 + neo4j: 4.3.10 + driver: ffi + experimental: true + - ruby: 3.1 + neo4j: 4.4.4 + driver: ffi + experimental: true env: NEO4J_EDITION_FLAG: -e NEO4J_VERSION: ${{ matrix.neo4j }} diff --git a/lib/active_graph/version.rb b/lib/active_graph/version.rb index fa467335b..794709dcc 100644 --- a/lib/active_graph/version.rb +++ b/lib/active_graph/version.rb @@ -1,3 +1,3 @@ module ActiveGraph - VERSION = '10.1.1' + VERSION = '10.2.0.beta.1' end From b11e58bc15fa4fb597b73917365752036dcbd12e Mon Sep 17 00:00:00 2001 From: Heinrich Klobuczek Date: Tue, 22 Feb 2022 18:38:37 -0900 Subject: [PATCH 6/7] restructured build matrix --- .github/workflows/test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7d4825446..9cd0c37b4 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -9,6 +9,7 @@ on: jobs: test: runs-on: ubuntu-18.04 + continue-on-error: ${{ matrix.experimental }} strategy: fail-fast: false matrix: From 8d726614ffb0c7c7bd0a7339151e1b5aed6c1d79 Mon Sep 17 00:00:00 2001 From: Heinrich Klobuczek Date: Tue, 22 Feb 2022 18:57:17 -0900 Subject: [PATCH 7/7] restructured build matrix --- .github/workflows/test.yml | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9cd0c37b4..a32922995 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -9,14 +9,13 @@ on: jobs: test: runs-on: ubuntu-18.04 - continue-on-error: ${{ matrix.experimental }} + continue-on-error: ${{ matrix.neo4j > '4.0' }} strategy: fail-fast: false matrix: ruby: [ 2.5, 3.0, 3.1, jruby-9.3.3.0 ] - neo4j: [ 3.5.30, 4.0.12 ] + neo4j: [ 3.5.30, 4.0.12, 4.1.11, 4.2.15, 4.3.10, 4.4.4 ] driver: [ ffi ] - experimental: [ false ] include: - ruby: jruby-9.3.3.0 neo4j: 4.0.12 @@ -26,22 +25,6 @@ jobs: driver: ffi java-version: 8 active-model-version: 5.2.3 - - ruby: 3.1 - neo4j: 4.1.11 - driver: ffi - experimental: true - - ruby: 3.1 - neo4j: 4.2.15 - driver: ffi - experimental: true - - ruby: 3.1 - neo4j: 4.3.10 - driver: ffi - experimental: true - - ruby: 3.1 - neo4j: 4.4.4 - driver: ffi - experimental: true env: NEO4J_EDITION_FLAG: -e NEO4J_VERSION: ${{ matrix.neo4j }}