johannessen / neo4j-driver-perl

Neo4j graph database driver (Bolt/Jolt) for Perl
https://metacpan.org/pod/Neo4j::Driver
Artistic License 2.0
5 stars 1 forks source link

Constructor hashref syntax fails to set default URI #14

Closed johannessen closed 2 years ago

johannessen commented 3 years ago

While not explicitly documented, the intention was that calling the Neo4j::Driver constructor with a hash that has no uri entry should result in the uri config option automatically being assigned a defined default value (currently http://localhost:7474). This is not in fact the case in 0.27.

$d = Neo4j::Driver->new({ })->session->server->address
# Expected:  localhost:7474
# Actual:    dies: config() without options unsupported at Neo4j/Driver.pm line 124.
Neo4j::Driver->new({ cypher_params => v2 })->session->server->address
# Expected:  localhost:7474
# Actual:    dies: Can't call method "scheme" on an undefined value at Neo4j/Driver/Session.pm line 22.

In contrast, calling the constructor without parameters at all works as intended:

Neo4j::Driver->new->config('uri')
# http://localhost:7474

Until this issue is addressed, the workaround is to always include an explicit uri entry in the hash ref, even if the value is undefined:

Neo4j::Driver->new({ uri => undef })->config('uri')
# http://localhost:7474
johannessen commented 2 years ago

Fix released with 0.28.