0

What is the purpose of the VALUE @expression clause in a DEFINE FIELD <field> ON <table> statement?

I expect it to return the result of the @expression if the <field> is queried on <table>. However, it always returns null, regardless of the @expression configured.

Here is an example:

DEFINE TABLE test SCHEMAFUL;
DEFINE FIELD time ON test VALUE time::now();

CREATE test:some;

SELECT time FROM test:some; # This is where I expect to get the current time

The result however dislays a null value.

In the following query:

SELECT * FROM test;

the time field does not even show up.

Juiko
  • 1
  • 1
  • can't reproduce this on `surreal 1.0.0-beta.8+20220930.c246533 for linux on x86_64`. It seems to work just fine, although it does only set the time at creation of the row. So it does not show the current time when querying, but the time when the row was inserted. – Tobias S. Oct 09 '22 at 16:30
  • Thanks for the clarification! I will do further testing to see if the issue persists. – Juiko Oct 09 '22 at 16:49

1 Answers1

0

So the @expression part is evaluated upon creating a new record on <table> and stored in the <field> on that table.

In the given example, a SELECT * FROM test would display the creation time of test:some. The field being empty cannot be reproduced.

Juiko
  • 1
  • 1