I’m trying to set up an `UPDATE` that returns the ...
# squarelibraries
m
I’m trying to set up an
UPDATE
that returns the original values being replaced. It seems
RETURNING
is the way to go but sqldelight won’t allow the
WITH
table columns to be referenced like this. Is this a limitation of sqldelight or have I got the syntax wrong?
Copy code
WITH old_values AS (
    SELECT id, date FROM history
    WHERE date NOT GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]'
)
UPDATE history
SET date = '1970-01-01'
WHERE id IN (SELECT id FROM old_values)
RETURNING old_values.date; // compilation error