tomjaguarpaw / haskell-opaleye

Other
599 stars 115 forks source link

forUpdate is wrong #540

Closed tomjaguarpaw closed 2 years ago

tomjaguarpaw commented 2 years ago

I'm not exactly sure what forUpdate is supposed to do, but I'm pretty sure it's not this:

> traverse_ putStrLn $ showSql $ (values [1 :: Field SqlInt4, 2] *> forUpdate (values [10 :: Field SqlInt4, 20]))
SELECT
"values0_2" as "result1_3"
FROM (SELECT
      *
      FROM (SELECT
            *
            FROM (SELECT "column1" as "values0_1"
                  FROM
                  (VALUES
                   (CAST(1 AS integer)),
                   (CAST(2 AS integer))) as "V") as "T1",
                 (SELECT "column1" as "values0_2"
                  FROM
                  (VALUES
                   (CAST(10 AS integer)),
                   (CAST(20 AS integer))) as "V") as "T2") as "T1"
      FOR UPDATE) as "T1"

The FOR UPDATE should presumably apply only to the inner query.