activegraph icon indicating copy to clipboard operation
activegraph copied to clipboard

NoMethodError (undefined method `to_sym' for nil:NilClass) when fetching Node

Open michalkorzawski opened this issue 2 years ago • 8 comments

Hi

I have an issue with fetching data - all operation like Model.first, Model.last, Model.find_by(name: 'some name') ends up with error NoMethodError (undefined method `to_sym' for nil:NilClass)

BUT when I copy/paste ActiveGraph::Core::Schema from activegraph source code to my app and in application.rb I'm loading this code like this:

overrides = "#{Rails.root}/app/services/active_graph"

Rails.autoloaders.main.ignore(overrides)

config.to_prepare do
  Dir.glob("#{overrides}/**/*.rb").each do |override|
    load override
  end
end

everything is working fine

label(keys, row) from below's method is causing this error (only then I'm not including this code in my rails app)

def indexes
        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
gem 'activegraph', '~> 10.1'
gem 'neo4j-ruby-driver', '~> 1.7', '>= 1.7.5'

I run neo4j db as a docker image

Do you know why could it be?

michalkorzawski avatar Sep 27 '21 18:09 michalkorzawski

Might be related, activegraph 10 doesn't seem to support neo4j above 4.0. 😢

harmjanblok avatar Dec 10 '21 13:12 harmjanblok

@michalkorzawski Is there any specific INDEX in DB which is causing this issue?

amitsuryavanshi avatar Dec 14 '21 06:12 amitsuryavanshi

We are also running into this issue on Neo4j 4.4.0 (a co-workers instance), but I don't seem to have the issue running 4.2.1. We are going to attempt to downgrade to 4.2.12 on the co-workers instance.

jeperkins4 avatar Dec 16 '21 16:12 jeperkins4

I also ran into this issue and the underlying issue is the 2 seemingly default indexes in the neo4j db. def label(result, row) if v34?(result) row[:label] else (v4?(result) ? row[:labelsOrTypes] : row[:tokenNames]).first # this code is accessing the first element of the index's empty labelsOrTypes array end.to_sym end

Screen Shot 2021-12-23 at 3 28 37 PM

I'm not sure exactly what creates these indexes, if they're necessary/default etc? But these are in the default neo4j docker image database, and in my neo4j desktop generated db as well.

Should activegraph be able to assume these to be empty? / for the label to be nil?

lukestadtler avatar Dec 23 '21 21:12 lukestadtler

Might be related, activegraph 10 doesn't seem to support neo4j above 4.0. 😢

Any idea when it will? I'm having the same issue trying to connect to AuraDB and I'm DYING to use Neo4j in my Rails 7 app. Please help :)

Can I downgrade to a version that is supported with AuraDB? I have bolt installed too. Just can't figure this out.

SabretWoW avatar Mar 08 '22 03:03 SabretWoW

I assume this has been fixed with https://github.com/neo4jrb/activegraph/pull/1669

amitsuryavanshi avatar Mar 08 '22 07:03 amitsuryavanshi

Can I confirm that this gem is not supported on AuraDB with v4?

Using the connection string like: neo4j+s://XXX.databases.neo4j.io throw:

Neo4j::Driver::Exceptions::ClientException: Unsupported URI scheme: neo4j+s

Is this only for JRuby and not MRI development?

mech avatar Apr 04 '22 07:04 mech

@amitsuryavanshi switching to gem 'activegraph', git: 'https://github.com/neo4jrb/activegraph', branch: '10'` resolved this issue, thank you

michalkorzawski avatar Apr 22 '22 17:04 michalkorzawski