orientechnologies / orientdb

OrientDB is the most versatile DBMS supporting Graph, Document, Reactive, Full-Text and Geospatial models in one Multi-Model product. OrientDB can run distributed (Multi-Master), supports SQL, ACID Transactions, Full-Text indexing and Reactive Queries.
https://orientdb.dev
Apache License 2.0
4.73k stars 869 forks source link

Creating OrientDB instance using Java API with database URL plocal:/tmp/documents1663429065341 throws exception #9873

Closed jonbullock closed 1 year ago

jonbullock commented 2 years ago

OrientDB Version: 3.1.20

Java Version: OpenJDK 11.0.16

OS: Ubuntu 20.04

Expected behavior

Create database on disk (type = PLOCAL) using path with slashes in it:

String type = "plocal";
String name = "/tmp/documents1663429065341";
OrientDB db = new OrientDB(type + ":" + name, OrientDBConfig.defaultConfig());
db.createIfNotExists(name, ODatabaseType.valueOf(type.toUpperCase()));

Actual behavior

Exception is thrown:

com.orientechnologies.orient.core.exception.ODatabaseException: Invalid database name:'/tmp/documents1663429065341'
    at app//com.orientechnologies.orient.core.db.OrientDBEmbedded.checkDatabaseName(OrientDBEmbedded.java:1113)
    at app//com.orientechnologies.orient.core.db.OrientDBEmbedded.create(OrientDBEmbedded.java:613)
    at app//com.orientechnologies.orient.core.db.OrientDB.createIfNotExists(OrientDB.java:269)
    at app//com.orientechnologies.orient.core.db.OrientDB.createIfNotExists(OrientDB.java:256)

This worked in v3.0.41 and contradicts docs: http://orientdb.org/docs/3.1.x/datamodeling/Concepts.html#database-url

tglman commented 1 year ago

Hi,

the API of OrientDB is supposed to work like this:

OrientDB db = new OrientDB("embedded:/tmp/", OrientDBConfig.defaultConfig());
db.createIfNotExists("documents1663429065341", ODatabaseType.PLOCAL);

this is because it allow to have a API that make sense either with embedded connection, or remote connection, ex remote:

OrientDB db = new OrientDB("remote:/localhost/","root","rootpassword", OrientDBConfig.defaultConfig());
db.createIfNotExists("documents1663429065341", ODatabaseType.PLOCAL);

as you see here only the creation of the OrientDB Instance change not the way you interact for manage databases.

In some version we had some backward compatible behavior, that was allowing too much, towards the future this is the API, so is better to convert the code this way, this works as well in 3.0.x series.