-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(temporal data): add time slice key to conflict clause #249
Conversation
It would be great if this fix could make it in the next release. This would simplify my life a lot! Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sjvans Could you add a test which shows the effects of this change?
Hi all, thanks for moving this topic forward! Am I right, that only one check is missing until it could be merged? That would be awesome! BR, Nico |
@nocin Is it an option for you to make |
Hi @johannes-vogel, thanks for the hint! I now spend some time thinking about this approach, but it would mean a lot of work in backend, frontend and another external program which pushes data in the application, as in our case it is the "main" table of the project. Therefore, I would prefer to stick to a single UUID as key and will wait for this feature, until I continue working on my feature request. BR, Nico |
hana/lib/HANAService.js
Outdated
} | ||
|
||
const val = _managed[element[annotation]?.['=']] | ||
|| !isUpdate && (element['@cds.valid.from'] ? '$valid.from' : element['@cds.valid.to'] ? '$valid.to' : null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is || !isUpdate && (element['@cds.valid.from'] ? '$valid.from' : element['@cds.valid.to'] ? '$valid.to' : null)
required?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
otherwise you cannot insert/ upsert data without specifying both validFrom
and validTo
in the payload.
in other words:
coalesce(ISO(value->>'$."validFrom"'), session_context('$valid.from'))
instead of just
ISO(value->>'$."validFrom"')
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@BobdenOs @johannes-vogel
was the default validTo
changed? i now get $now
but i would have expected something like 9999-12-31T23:59:59.999Z
. with $now
this defaulting logic is not good.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
session_context('$now')
will return the timestamp from the tx.timestamp
. Or is the $now
part of the entries || data
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
new Date().toISOString().replace(/(\dZ?)$/, d => parseInt(d[0]) + 1 + d[1] || '')) |
$now
(logically)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see what you mean. I don't know what the behavior used to be.
I am also not sure whether the max timestamp default is correct in the temporal context as I would expect that any new insert with the same key values should become the validTo
of the last value.
await INSERT({ID: 1/*, validFrom: $now, validTo: timestamp_max */}).into(temporal)
await sleep(...)
await Promise.all([
INSERT({ID:1/*, validFrom: $now, validTo: timestamp_max */}).into(temporal),
UPDATE(temporal).data({validTo: $now}).where(`ID = ${1} and validTo = ${timestamp_max}`),
])
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we did not support/document how to write temporal data so far.
For now I think it's fine that the input is required by the user → #344
@@ -874,7 +874,6 @@ class CQN2SQLRenderer { | |||
if (converter && sql[0] !== '$') sql = converter(sql, element) | |||
|
|||
let val = _managed[element[annotation]?.['=']] | |||
|| !isUpdate && (element['@cds.valid.from'] ? '$valid.from' : element['@cds.valid.to'] ? '$valid.to' : null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does not look correct. If the session context contains the from
and to
it should be considered.
changelogwill happen automatically once merged