diff --git a/fixme-new/lib/Fixme/Run.hs b/fixme-new/lib/Fixme/Run.hs index c7691aa1..bcb48b5b 100644 --- a/fixme-new/lib/Fixme/Run.hs +++ b/fixme-new/lib/Fixme/Run.hs @@ -101,6 +101,7 @@ silence = do setLoggingOff @ERROR setLoggingOff @WARN setLoggingOff @NOTICE + setLoggingOff @TRACE readConfig :: FixmePerks m => FixmeM m [Syntax C] @@ -323,11 +324,17 @@ runTop forms = do _ -> throwIO $ BadFormException @C nil + entry $ bindMatch "log:trace:on" $ nil_ $ const do + lift $ setLogging @TRACE $ toStderr . logPrefix "" + + entry $ bindMatch "log:trace:off" $ nil_ $ const do + lift $ setLoggingOff @TRACE + conf <- readConfig argz <- liftIO getArgs - let args = zipWith (\i s -> bindValue (mkId ("%" <> show i)) (mkStr @C s )) [1..] argz + let args = zipWith (\i s -> bindValue (mkId ("$_" <> show i)) (mkStr @C s )) [1..] argz & HM.unions run (dict <> args) (conf <> forms) >>= eatNil display diff --git a/fixme-new/lib/Fixme/State.hs b/fixme-new/lib/Fixme/State.hs index a1e6a290..53109a9c 100644 --- a/fixme-new/lib/Fixme/State.hs +++ b/fixme-new/lib/Fixme/State.hs @@ -469,16 +469,16 @@ genPredQ tbl what = go what All -> ("true", mempty) FixmeHashExactly x -> - ([qc|({tbl}.fixme = ?)|], [Bound x]) + ([qc|(s2.fixme = ?)|], [Bound x]) AttrLike "fixme-hash" val -> do let binds = [Bound (val <> "%")] - ([qc|({tbl}.fixme like ?)|], binds) + ([qc|(s2.fixme like ?)|], binds) AttrLike name val -> do let x = val <> "%" let binds = [Bound x] - ([qc|(json_extract({tbl}.json, '$."{name}"') like ?)|], binds) + ([qc|(json_extract({tbl}, '$."{name}"') like ?)|], binds) Not a -> do let (sql, bound) = go a @@ -527,7 +527,7 @@ updateFixmeJson = do selectFixmeThin :: (FixmePerks m, HasPredicate a) => a -> FixmeM m [FixmeThin] selectFixmeThin a = withState do - let predic = genPredQ "j" (predicate a) + let predic = genPredQ "blob" (predicate a) let emptyObect = [q|'{}'|] :: String @@ -537,14 +537,18 @@ with s1 as ( select m.hash as hash , cast(json_group_object(m.attr,m.value) as blob) as json from fixmestagemod m -) +), -select cast(json_patch(j.json, coalesce(s.json,{emptyObect})) as blob) as blob +s2 as + ( select cast(json_patch(j.json, coalesce(s.json,{emptyObect})) as blob) as blob, j.fixme as fixme -from - fixmejson j join fixmeactual f on f.fixme = j.fixme - join fixme f0 on f0.id = f.fixme - left join s1 s on s.hash = j.fixme + from + fixmejson j join fixmeactual f on f.fixme = j.fixme + join fixme f0 on f0.id = f.fixme + left join s1 s on s.hash = j.fixme + ) + +select s2.blob from s2 where