Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for select shims in FV #1090

Merged
merged 2 commits into from
Jan 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src-tool/Pact/Analyze/Patterns.hs
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,10 @@ pattern ShortTableName tn <- Table _node (Lang.TableName tn)
pattern NativeFuncSpecial :: forall a. Text -> AST a -> Fun a
pattern NativeFuncSpecial f bdy <- FNative _ f _ (Just (_,SBinding bdy))

pattern AST_Select :: Node -> Text -> [AST Node] -> AST Node -> AST Node
pattern AST_Select node tn columns filters
<- App node (NativeFunc "select") [ShortTableName tn, List _ columns, filters]

pattern AST_Read :: Node -> Text -> AST Node -> AST Node
pattern AST_Read node tn key <- App node (NativeFunc "read") [ShortTableName tn, key]

Expand Down
6 changes: 6 additions & 0 deletions src-tool/Pact/Analyze/Translate.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1322,6 +1322,12 @@ translateNode astNode = withAstContext astNode $ case astNode of

AST_NFun _node "pact-version" [] -> pure $ Some SStr PactVersion

AST_Select node _tn _columns _filters -> translateType node >>= \case
EType (SList tableSchema) -> do
let elist = Some (SList tableSchema) EmptyList
shimNative' node "select" [] "[]" elist
_ -> unexpectedNode astNode

AST_WithRead node table key bindings schemaNode body -> translateType schemaNode >>= \case
EType rowTy@SObject{} -> translateNode key >>= \case
Some SStr key' -> typeOfPartialBind rowTy bindings >>= \case
Expand Down