neo4jrb / activegraph

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

Rake task neo4j:schema:dump fails #1682

Closed MatthewAger closed 1 year ago

MatthewAger commented 1 year ago

Hi,

Running bundle exec rake neo4j:schema:dump (and hence any other rake task that invokes that task) fails with

Neo4j::Driver::Exceptions::ClientException: There is no procedure with the name `db.constraints` registered for this database instance. Please ensure you've spelled the procedure name correctly and that the procedure is properly deployed.

This is clearly related to this recent change https://github.com/neo4jrb/activegraph/blob/7a5fc1d4087be83d3e8af8932bf56371e9fc8810/lib/active_graph/core/label.rb#L141-L143 in the v11.1.0 release and was perhaps just missed?

The culprit appears to be here https://github.com/neo4jrb/activegraph/blob/85abe96b29f5844b46c865c7a957cdf10087d80c/lib/active_graph/migrations/schema.rb#L22-L24

I attempted to fix that line in a similar way, but get

ArgumentError: comparison of Neo4j::Driver::Internal::InternalRecord with Neo4j::Driver::Internal::InternalRecord failed

which, incidentally, is what you get if you run neo4j:schema:dump on a v4.x database.

Runtime information:

Neo4j database version: 5.2 (and 4.4) activegraph (11.1.0) neo4j-rake_tasks (0.7.19) neo4j-ruby-driver (4.4.1) rails (7.0.4.1)

klobuczek commented 1 year ago

Could you show me your attempted fix?

MatthewAger commented 1 year ago

Hah! Was quite naïve...

def fetch_constraint_descriptions
  ActiveGraph::Base.query(
    ActiveGraph::Base.version?('<4.3') ?
      'CALL db.constraints() YIELD description' :
      'SHOW CONSTRAINTS YIELD createStatement'
  ).map(&:first)
end 

in the hope that in both cases the query returned an array. But as I say, I get the same error as I do as standard on Neo4j 4.x.

This is what that query returns on my test server btw

╒══════════════════════════════════════════════════════════════════════╕
│"createStatement"                                                     │
╞══════════════════════════════════════════════════════════════════════╡
│"CREATE CONSTRAINT `constraint_306769aa` FOR (n:`Artwork`) REQUIRE (n.│
│`uuid`) IS UNIQUE OPTIONS {indexConfig: {}, indexProvider: 'range-1.0'│
│}"                                                                    │
├──────────────────────────────────────────────────────────────────────┤
│"CREATE CONSTRAINT `constraint_8e2dcb08` FOR (n:`Portfolio`) REQUIRE (│
│n.`uuid`) IS UNIQUE OPTIONS {indexConfig: {}, indexProvider: 'range-1.│
│0'}"                                                                  │
├──────────────────────────────────────────────────────────────────────┤
│"CREATE CONSTRAINT `constraint_dbcee0a4` FOR (n:`ActiveGraph::Migratio│
│ns::SchemaMigration`) REQUIRE (n.`migration_id`) IS UNIQUE OPTIONS {in│
│dexConfig: {}, indexProvider: 'range-1.0'}"                           │
└──────────────────────────────────────────────────────────────────────┘