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

Adds support for view and type blocks #2179

Merged
merged 3 commits into from
Jul 15, 2024
Merged

Conversation

infomiho
Copy link
Contributor

Adds support for view and type blocks by reusing the model parser.

waspc/src/Wasp/Psl/Ast/Model.hs Outdated Show resolved Hide resolved
waspc/src/Wasp/Psl/Ast/Model.hs Outdated Show resolved Hide resolved
waspc/src/Wasp/Psl/Ast/Model/Common.hs Outdated Show resolved Hide resolved
@infomiho infomiho force-pushed the miho-adds-view-type-supoprt branch from e9516cb to 1c74597 Compare July 15, 2024 09:32
@infomiho
Copy link
Contributor Author

@Martinsos Now I've implemented the view and type parser based on importing the body parser from Wasp.Psl.Ast.Model module. Looks cleaner and it's clear that the view and type blocks are "model-like" blocks.

Copy link
Member

@Martinsos Martinsos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Approved but also left a couple of smaller comments.

waspc/src/Wasp/Psl/Parser/Schema.hs Show resolved Hide resolved
waspc/src/Wasp/Psl/Parser/Model.hs Outdated Show resolved Hide resolved
data Type
= Type
Name
Body
Copy link
Member

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.

Copy link
Contributor Author

@infomiho infomiho Jul 15, 2024

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?

I'm only looking at this from the point of view of Prisma grammar and type and view 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.:

model MyModel {
  id String @id
  someType SomeType
}

type SomeType {
  name String
  age Int
}

Copy link
Contributor Author

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.

Copy link
Member

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

@infomiho infomiho merged commit e62f89a into main Jul 15, 2024
6 checks passed
@infomiho infomiho deleted the miho-adds-view-type-supoprt branch July 15, 2024 11:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants