neo4jrb / activegraph

An active model wrapper for the Neo4j Graph Database for Ruby.
http://neo4jrb.io
MIT License
1.39k stars 276 forks source link

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

Open michalkorzawski opened 2 years ago

michalkorzawski commented 2 years ago

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?

harmjanblok commented 2 years ago

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

amitsuryavanshi commented 2 years ago

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

jeperkins4 commented 2 years ago

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.

lukestadtler commented 2 years ago

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?

SabretWoW commented 2 years ago

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.

amitsuryavanshi commented 2 years ago

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

mech commented 2 years ago

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?

michalkorzawski commented 2 years ago

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