1module TutorialD.Interpreter.SchemaOperator where
3import Text.Megaparsec.Text
6import ProjectM36.IsomorphicSchema
7import ProjectM36.Session
8import ProjectM36.Client
9import TutorialD.Interpreter.RelationalExpr
10import TutorialD.Interpreter.Base
12data SchemaOperator = ModifySchemaExpr SchemaExpr |
13 SetCurrentSchema SchemaName
16schemaOperatorP :: Parser SchemaOperator
17schemaOperatorP = (ModifySchemaExpr <$> schemaExprP) <|>
20setCurrentSchemaP :: Parser SchemaOperator
23 SetCurrentSchema <$> identifier
25schemaExprP :: Parser SchemaExpr
26schemaExprP = addSubschemaP <|>
29addSubschemaP :: Parser SchemaExpr
32 AddSubschema <$> identifier <*> parens (sepBy schemaIsomorphP comma)
34schemaIsomorphP :: Parser SchemaIsomorph
35schemaIsomorphP = isoRestrictP <|> isoUnionP <|> isoRenameP <|> isoPassthrough
37removeSubschemaP :: Parser SchemaExpr
39 reserved ":removeschema"
40 RemoveSubschema <$> identifier
42isoRestrictP :: Parser SchemaIsomorph
44 reserved "isorestrict"
46 relvarsOut <- isoRestrictOutRelVarsP
47 IsoRestrict <$> pure relVarIn <*> restrictionPredicateP <*> pure relvarsOut
49isoRestrictOutRelVarsP :: Parser (RelVarName, RelVarName)
50isoRestrictOutRelVarsP = (,) <$> qrelVarP <*> qrelVarP
52qrelVarP :: Parser RelVarName
53qrelVarP = quotedString
55isoUnionP :: Parser SchemaIsomorph
58 relVarsIn <- isoUnionInRelVarsP
59 relVarsOut <- qrelVarP
60 IsoUnion <$> pure relVarsIn <*> restrictionPredicateP <*> pure relVarsOut
62isoRenameP :: Parser SchemaIsomorph
65 IsoRename <$> qrelVarP <*> qrelVarP
67isoPassthrough :: Parser SchemaIsomorph
69 reserved "isopassthrough"
71 pure (IsoRename rv rv)
73isoUnionInRelVarsP :: Parser (RelVarName, RelVarName)
74isoUnionInRelVarsP = (,) <$> qrelVarP <*> qrelVarP
76evalSchemaOperator :: SessionId -> Connection -> SchemaOperator -> IO (Either RelationalError ())
77evalSchemaOperator sessionId conn (ModifySchemaExpr expr) = executeSchemaExpr sessionId conn expr
78evalSchemaOperator sessionId conn (SetCurrentSchema sname) = setCurrentSchemaName sessionId conn 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