1module ProjectM36.Session where
4import qualified Data.Map as M
6import qualified ProjectM36.DisconnectedTransaction as Discon
10--the persistence of a session is as long as the life of the database (not serialized to disk)
11-- sessions are not associated with connections and have separate lifetimes
12-- | Represents a pointer into the database's transaction graph which the 'DatabaseContextExpr's can then modify subsequently be committed to extend the transaction graph. The session contains staged (uncommitted) database changes as well as the means to switch between isomorphic schemas.
13data Session = Session DisconnectedTransaction SchemaName
15defaultSchemaName :: SchemaName
16defaultSchemaName = "main"
18disconnectedTransaction :: Session -> DisconnectedTransaction
19disconnectedTransaction (Session discon _) = discon
21isDirty :: Session -> DirtyFlag
22isDirty (Session discon _) = Discon.isDirty discon
24concreteDatabaseContext :: Session -> DatabaseContext
25concreteDatabaseContext (Session (DisconnectedTransaction _ (Schemas context _) _) _) = context
27parentId :: Session -> TransactionId
28parentId (Session (DisconnectedTransaction parentUUID _ _) _) = parentUUID
30subschemas :: Session -> Subschemas
31subschemas (Session (DisconnectedTransaction _ (Schemas _ s) _) _) = s
33schemas :: Session -> Schemas
34schemas (Session (DisconnectedTransaction _ s _) _) = s
36schemaName :: Session -> SchemaName
37schemaName (Session _ s) = s
39setSchemaName :: SchemaName -> Session -> Either RelationalError Session
40setSchemaName sname session = if sname == defaultSchemaName || M.member sname (subschemas session) then
41 pure (Session (disconnectedTransaction session) sname)
43 Left (SubschemaNameNotInUseError sname)
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list