@@ -404,12 +404,14 @@ setCurrentSchemaName sessionId conn@(RemoteProcessConnection _ _) sname = remote
404404-- | Execute a relational expression in the context of the session and connection. Relational expressions are queries and therefore cannot alter the database.
405405executeRelationalExpr :: SessionId -> Connection -> RelationalExpr -> IO (Either RelationalError Relation)
406406executeRelationalExpr sessionId (InProcessConnection _ _ sessions _ _) expr = excEither $ atomically $ do
407− eSession <- sessionForSessionId sessionId sessions
407+ eSession <- sessionAndSchema sessionId sessions
408408 case eSession of
409409 Left err -> pure $ Left err
410− Right session -> case evalState (RE.evalRelationalExpr expr) (Sess.concreteDatabaseContext session) of
411− Left err -> pure (Left err)
412− Right rel -> pure (force (Right rel)) -- this is necessary so that any undefined/error exceptions are spit out here
410+ Right (session, schema) -> case Schema.processRelationalExprInSchema schema expr of
411+ Left err -> pure (Left err)
412+ Right expr' -> case evalState (RE.evalRelationalExpr expr') (Sess.concreteDatabaseContext session) of
413+ Left err -> pure (Left err)
414+ Right rel -> pure (force (Right rel)) -- this is necessary so that any undefined/error exceptions are spit out here
413415executeRelationalExpr sessionId conn@(RemoteProcessConnection _ _) relExpr = remoteCall conn (ExecuteRelationalExpr sessionId relExpr)
414416
415417-- | Execute a database context expression in the context of the session and connection. Database expressions modify the current session's disconnected transaction but cannot modify the transaction graph.