ArcadeData / arcadedb

ArcadeDB Multi-Model Database, one DBMS that supports SQL, Cypher, Gremlin, HTTP/JSON, MongoDB and Redis. ArcadeDB is a conceptual fork of OrientDB, the first Multi-Model DBMS. ArcadeDB supports Vector Embeddings.
https://arcadedb.com
Apache License 2.0
469 stars 57 forks source link

DEFAULT with function call only works with ALTER PROPERTY #1609

Closed TimMensch closed 1 month ago

TimMensch commented 1 month ago

ArcadeDB Version:

v24.4.1 (build c714a4f5c827d742d6edd0f7788fe049bc63607b/1713579699346/main)

OS and JDK Version:

Running on Linux 5.15.146.1-microsoft-standard-WSL2 - OpenJDK 64-Bit Server VM 11.0.22 (Temurin-11.0.22+7)

Expected behavior

Setting DEFAULT sysdate() during create should be identical to adding DEFAULT sysdate() during ALTER PROPERTY.

Actual behavior

When I say:

CREATE VERTEX TYPE Test;
CREATE PROPERTY Test.createdAt IF NOT EXISTS DATETIME (mandatory true, readonly, DEFAULT sysdate());
CREATE VERTEX Test; -- Wait a couple of seconds
CREATE VERTEX Test; -- Wait a couple of seconds 
CREATE VERTEX Test;

The three vertices all have the same createdAt field. Whereas if I say:

ALTER PROPERTY Test.createdAt DEFAULT sysdate();

Then

CREATE VERTEX Test;  -- Wait a couple of seconds
CREATE VERTEX Test;  -- Wait a couple of seconds
CREATE VERTEX Test;

...creates vertices with three unique timestamps.

I'm using the Docker Hub image version 24.4.1.

Originally posted by @TimMensch in https://github.com/ArcadeData/arcadedb/issues/905#issuecomment-2118528446

gramian commented 1 month ago

Hmm, I can reproduce this. It seems the timestamp in the first case is the creation date of the property, not the vertex.

Could you try:

CREATE PROPERTY Test.createdAt IF NOT EXISTS DATETIME (mandatory true, readonly, DEFAULT `sysdate()`);

this seems to work for me.

TimMensch commented 1 month ago

OK, sure, that works. Thanks.

lvca commented 1 month ago

I guess the docs are not clear on this point. I found this example that is misleading:

ArcadeDB> CREATE PROPERTY Employee.hiredAt DATETIME (readonly, default sysdate('YYYY-MM-DD HH:MM:SS'))
lvca commented 1 month ago

Ok, I haven't seen this from @gramian https://github.com/ArcadeData/arcadedb/pull/1611. Now it should be fixed.