1module TutorialD.Interpreter.SchemaOperator where
4import ProjectM36.IsomorphicSchema
5import ProjectM36.Session
6import ProjectM36.Client
7import TutorialD.Interpreter.RelationalExpr
8import TutorialD.Interpreter.Base
10data SchemaOperator = ModifySchemaExpr SchemaExpr |
11 SetCurrentSchema SchemaName
14schemaOperatorP :: Parser SchemaOperator
15schemaOperatorP = (ModifySchemaExpr <$> schemaExprP) <|>
18setCurrentSchemaP :: Parser SchemaOperator
21 SetCurrentSchema <$> identifier
23schemaExprP :: Parser SchemaExpr
24schemaExprP = addSubschemaP <|>
27addSubschemaP :: Parser SchemaExpr
30 AddSubschema <$> identifier <*> parens (sepBy schemaIsomorphP comma)
32schemaIsomorphP :: Parser SchemaIsomorph
33schemaIsomorphP = isoRestrictP <|> isoUnionP <|> isoRenameP <|> isoPassthrough
35removeSubschemaP :: Parser SchemaExpr
37 reserved ":removeschema"
38 RemoveSubschema <$> identifier
40isoRestrictP :: Parser SchemaIsomorph
42 reserved "isorestrict"
44 relvarsOut <- isoRestrictOutRelVarsP
45 IsoRestrict <$> pure relVarIn <*> restrictionPredicateP <*> pure relvarsOut
47isoRestrictOutRelVarsP :: Parser (RelVarName, RelVarName)
48isoRestrictOutRelVarsP = (,) <$> qrelVarP <*> qrelVarP
50qrelVarP :: Parser RelVarName
51qrelVarP = quotedString
53isoUnionP :: Parser SchemaIsomorph
56 relVarsIn <- isoUnionInRelVarsP
57 relVarsOut <- qrelVarP
58 IsoUnion <$> pure relVarsIn <*> restrictionPredicateP <*> pure relVarsOut
60isoRenameP :: Parser SchemaIsomorph
63 IsoRename <$> qrelVarP <*> qrelVarP
65isoPassthrough :: Parser SchemaIsomorph
67 reserved "isopassthrough"
69 pure (IsoRename rv rv)
71isoUnionInRelVarsP :: Parser (RelVarName, RelVarName)
72isoUnionInRelVarsP = (,) <$> qrelVarP <*> qrelVarP
74evalSchemaOperator :: SessionId -> Connection -> SchemaOperator -> IO (Either RelationalError ())
75evalSchemaOperator sessionId conn (ModifySchemaExpr expr) = executeSchemaExpr sessionId conn expr
76evalSchemaOperator 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