You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the Examples section, for the resultant table to be valid, allow INSERTing new records, and work as expected, the example code should be changed from:
ADD COLUMN expires_at AS (date('now', '+30 days');
to
ADD COLUMN expires_at AS (date(timestamp, '+30 days');
Additional information
The Additional Considerations section immediately underneath even mentions that generated columns can only use deterministic functions, and date('now') isn't deterministic, so whilst the code will execute and update the table, you'll get an error when trying to INSERT into that table.
Even if it did let you INSERT records, it'd not work as intended, because the VIRTUAL column expression would be evaluated every time it was read, and so would always be 30 days in the future; the query to return expired records would therefore never return any records.
The text was updated successfully, but these errors were encountered:
Maddy-Cloudflare
changed the title
Incorrect example code in D1 generated columns documentation
[D1] Incorrect example code in D1 generated columns documentation
May 15, 2024
Existing documentation URL(s)
https://developers.cloudflare.com/d1/reference/generated-columns/
What changes are you suggesting?
In the Examples section, for the resultant table to be valid, allow INSERTing new records, and work as expected, the example code should be changed from:
ADD COLUMN expires_at AS (date('now', '+30 days');
to
ADD COLUMN expires_at AS (date(timestamp, '+30 days');
Additional information
The Additional Considerations section immediately underneath even mentions that generated columns can only use deterministic functions, and
date('now')
isn't deterministic, so whilst the code will execute and update the table, you'll get an error when trying to INSERT into that table.Even if it did let you INSERT records, it'd not work as intended, because the VIRTUAL column expression would be evaluated every time it was read, and so would always be 30 days in the future; the query to return expired records would therefore never return any records.
The text was updated successfully, but these errors were encountered: