1module TutorialD.Interpreter.SchemaOperator where
3import Text.Megaparsec.Text
6import ProjectM36.IsomorphicSchema
7import ProjectM36.Session
8import ProjectM36.Client
10import TutorialD.Interpreter.RelationalExpr
11import TutorialD.Interpreter.Base
13data SchemaOperator = ModifySchemaExpr SchemaExpr |
14 SetCurrentSchema SchemaName
17schemaOperatorP :: Parser SchemaOperator
18schemaOperatorP = (ModifySchemaExpr <$> schemaExprP) <|>
21setCurrentSchemaP :: Parser SchemaOperator
24 SetCurrentSchema <$> identifier
26schemaExprP :: Parser SchemaExpr
27schemaExprP = addSubschemaP <|>
30addSubschemaP :: Parser SchemaExpr
33 AddSubschema <$> identifier <*> parens (sepBy schemaIsomorphP comma)
35schemaIsomorphP :: Parser SchemaIsomorph
36schemaIsomorphP = isoRestrictP <|> isoUnionP <|> isoRenameP <|> isoPassthrough
38removeSubschemaP :: Parser SchemaExpr
40 reserved ":removeschema"
41 RemoveSubschema <$> identifier
43isoRestrictP :: Parser SchemaIsomorph
45 reserved "isorestrict"
47 relvarsOut <- isoRestrictOutRelVarsP
48 IsoRestrict <$> pure relVarIn <*> restrictionPredicateP <*> pure relvarsOut
50isoRestrictOutRelVarsP :: Parser (RelVarName, RelVarName)
51isoRestrictOutRelVarsP = (,) <$> qrelVarP <*> qrelVarP
53qrelVarP :: Parser RelVarName
54qrelVarP = quotedString
56isoUnionP :: Parser SchemaIsomorph
59 relVarsIn <- isoUnionInRelVarsP
60 relVarsOut <- qrelVarP
61 IsoUnion <$> pure relVarsIn <*> restrictionPredicateP <*> pure relVarsOut
63isoRenameP :: Parser SchemaIsomorph
66 IsoRename <$> qrelVarP <*> qrelVarP
68isoPassthrough :: Parser SchemaIsomorph
70 reserved "isopassthrough"
72 pure (IsoRename rv rv)
74isoUnionInRelVarsP :: Parser (RelVarName, RelVarName)
75isoUnionInRelVarsP = (,) <$> qrelVarP <*> qrelVarP
77evalSchemaOperator :: SessionId -> Connection -> SchemaOperator -> IO (Maybe RelationalError)
78evalSchemaOperator sessionId conn (ModifySchemaExpr expr) = executeSchemaExpr sessionId conn expr
79evalSchemaOperator 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