-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Adds support for view and type blocks #2179
Merged
Merged
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
module Wasp.Psl.Ast.Type | ||
( Type (..), | ||
) | ||
where | ||
|
||
import Wasp.Psl.Ast.Common (Name) | ||
import Wasp.Psl.Ast.Model (Body) | ||
|
||
data Type | ||
= Type | ||
Name | ||
Body | ||
deriving (Show, Eq) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
module Wasp.Psl.Ast.View | ||
( View (..), | ||
) | ||
where | ||
|
||
import Wasp.Psl.Ast.Common (Name) | ||
import Wasp.Psl.Ast.Model (Body) | ||
|
||
data View | ||
= View | ||
Name | ||
Body | ||
deriving (Show, Eq) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
module Wasp.Psl.Parser.Type | ||
( typeBlock, | ||
) | ||
where | ||
|
||
import Text.Parsec.String (Parser) | ||
import qualified Wasp.Psl.Ast.Type as Psl.Type | ||
import Wasp.Psl.Parser.Common | ||
( braces, | ||
identifier, | ||
reserved, | ||
) | ||
import Wasp.Psl.Parser.Model (body) | ||
|
||
-- | Parses PSL (Prisma Schema Language) type. | ||
-- Example of PSL type: | ||
-- type Photo { | ||
-- height Int @default(200) | ||
-- width Int @default(100) | ||
-- url String | ||
-- } | ||
typeBlock :: Parser Psl.Type.Type | ||
typeBlock = do | ||
reserved "type" | ||
typeName <- identifier | ||
Psl.Type.Type typeName <$> braces body |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
module Wasp.Psl.Parser.View | ||
( view, | ||
) | ||
where | ||
|
||
import Text.Parsec.String (Parser) | ||
import qualified Wasp.Psl.Ast.View as Psl.View | ||
import Wasp.Psl.Parser.Common | ||
( braces, | ||
identifier, | ||
reserved, | ||
) | ||
import Wasp.Psl.Parser.Model (body) | ||
|
||
-- | Parses PSL (Prisma Schema Language) view. | ||
-- Example of PSL view: | ||
-- view User { | ||
-- id Int @id | ||
-- name String | ||
-- } | ||
view :: Parser Psl.View.View | ||
view = do | ||
reserved "view" | ||
viewName <- identifier | ||
Psl.View.View viewName <$> braces body |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So does type actually support anything that can go into Model body, or is it a subset? That is relevant both here for AST and also for parser. If it is indeed anything that goes into model, then great. If not (and I would guess so, at least for view), then I would consider putting a comment here explaining that a bit.
Same goes for
view
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm only looking at this from the point of view of Prisma grammar and
type
andview
are separate blocks. They are not subsets of model in any way.You can however, use composite types (
type
block) in models by using them as field types e.g.:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added some comments to both view and type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i meant in the sense that their ast/parser is subset of model's