Closed tomsseisums closed 1 year ago
For now can be worked around by defining default value on container field:
DEFINE TABLE metrics SCHEMALESS;
DEFINE FIELD custom ON metrics TYPE object VALUE {};
DEFINE FIELD custom.sales_difference ON metrics VALUE expected_sales - previous_sales;
CREATE metrics CONTENT {
expected_sales: 5000,
previous_sales: 2000
};
Will produce record with expected structure:
[
/* ...redacted... */
{
"time": "465.125µs",
"status": "OK",
"result": [
{
"custom": {
"sales_difference": 3000,
},
"expected_sales": 5000,
"id": "metrics:ryifdi3sxsdwst9s6j4d",
"previous_sales": 2000
}
]
}
]
Describe the bug
A defined computed field that uses dot separated path to set a nested field, in case the record does not have the containing field defined, the computed value will be stored without nesting and with an invalid name (only using the first bit of the dot separated path).
Steps to reproduce
On an empty database:
Without defining container field:
With container field definition:
Both approaches return:
Expected behaviour
In either case, to compute and store in nested manner keeping correct names:
SurrealDB version
surreal 1.0.0-beta.7 for macos on aarch64
Contact Details
@tomsseisums
Is there an existing issue for this?
Code of Conduct