This is an example of a query we have, using PostGreSQL's WITH statement:
WITH updated_records AS (
UPDATE records SET updated_at = NOW(), foo = 'bar'
WHERE type = 'custom_type'
RETURNING id
)
INSERT INTO record_histories (record_id, action)
SELECT
id AS record_id,
'set_to_bar' AS action
FROM updated_records
Breaking it down into one UPDATE records... and one INSERT INTO record_histories.. queries would solve the issue but we'd like to avoid this solution if possible and keep our current codebase as is.
For minimal break of codebase, possible solutions rely on modifying the matcher regexp to either remove the leading \A (but then every test query that includes INSERT INTO xxxxx will add xxxxx to the tables to clean) or adding support for WITH xxxxx AS (...) INSERT INTO...-style queries to the regexp (which sounds dauting enough).
What would be your thoughts?
This is an example of a query we have, using PostGreSQL's WITH statement:
Breaking it down into one
UPDATE records...and oneINSERT INTO record_histories..queries would solve the issue but we'd like to avoid this solution if possible and keep our current codebase as is.For minimal break of codebase, possible solutions rely on modifying the matcher regexp to either remove the leading
\A(but then every test query that includesINSERT INTO xxxxxwill addxxxxxto the tables to clean) or adding support forWITH xxxxx AS (...) INSERT INTO...-style queries to the regexp (which sounds dauting enough).What would be your thoughts?