mirror of
https://github.com/wasp-lang/wasp.git
synced 2024-12-25 01:52:00 +03:00
Fixes Prisma array expr for empty arrays (#2249)
This commit is contained in:
parent
eb5f6703fc
commit
0aabddaa75
@ -18,7 +18,6 @@ import Wasp.Psl.Parser.Common
|
||||
( brackets,
|
||||
colon,
|
||||
commaSep,
|
||||
commaSep1,
|
||||
float,
|
||||
identifier,
|
||||
integer,
|
||||
@ -69,7 +68,7 @@ funcCallExpr =
|
||||
arrayExpr :: Parser Psl.Argument.Expression
|
||||
arrayExpr =
|
||||
Psl.Argument.ArrayExpr
|
||||
<$> brackets (commaSep1 expression)
|
||||
<$> brackets (commaSep expression)
|
||||
|
||||
-- NOTE: For now we are not supporting negative numbers.
|
||||
-- I couldn't figure out from Prisma docs if there could be the case
|
||||
|
@ -15,6 +15,7 @@ sampleBodySchema =
|
||||
posts Post[] @relation("UserPosts", references: [id]) @customattr
|
||||
weirdType Unsupported("weird")
|
||||
anotherId String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
|
||||
someField String[] @default([])
|
||||
|
||||
@@someattr([id, username], [posts])
|
||||
|]
|
||||
@ -114,6 +115,20 @@ sampleBodyAst =
|
||||
]
|
||||
}
|
||||
),
|
||||
Psl.Model.ElementField
|
||||
( Psl.Model.Field
|
||||
{ Psl.Model._name = "someField",
|
||||
Psl.Model._type = Psl.Model.String,
|
||||
Psl.Model._typeModifiers = [Psl.Model.List],
|
||||
Psl.Model._attrs =
|
||||
[ Psl.Attribute.Attribute
|
||||
{ Psl.Attribute._attrName = "default",
|
||||
Psl.Attribute._attrArgs =
|
||||
[Psl.Argument.ArgUnnamed (Psl.Argument.ArrayExpr [])]
|
||||
}
|
||||
]
|
||||
}
|
||||
),
|
||||
Psl.Model.ElementBlockAttribute
|
||||
( Psl.Attribute.Attribute
|
||||
{ Psl.Attribute._attrName = "someattr",
|
||||
|
@ -36,6 +36,9 @@ spec_parseArgumentPslPart = do
|
||||
Psl.Argument.IdentifierExpr "pg_trgm",
|
||||
Psl.Argument.FuncExpr "postgis" [Psl.Argument.ArgNamed "version" (Psl.Argument.StringExpr "2.1")]
|
||||
]
|
||||
),
|
||||
( "[]",
|
||||
Psl.Argument.ArgUnnamed (Psl.Argument.ArrayExpr [])
|
||||
)
|
||||
]
|
||||
let runTest (psl, expected) =
|
||||
|
@ -53,6 +53,12 @@ spec_parseAttributePslPart = do
|
||||
]
|
||||
)
|
||||
]
|
||||
),
|
||||
( "@default([])",
|
||||
Psl.Attribute.Attribute
|
||||
"default"
|
||||
[ Psl.Argument.ArgUnnamed $ Psl.Argument.ArrayExpr []
|
||||
]
|
||||
)
|
||||
]
|
||||
runTestsFor attribute tests
|
||||
|
@ -63,6 +63,7 @@ spec_parsePslSchema = do
|
||||
user User @relation(fields: [userId], references: [id])
|
||||
userId Int
|
||||
votes TaskVote[]
|
||||
someField String[] @default([])
|
||||
}
|
||||
|
||||
model TaskVote {
|
||||
@ -230,7 +231,16 @@ spec_parsePslSchema = do
|
||||
"votes"
|
||||
(Psl.Model.UserType "TaskVote")
|
||||
[Psl.Model.List]
|
||||
[]
|
||||
[],
|
||||
Psl.Model.ElementField $
|
||||
Psl.Model.Field
|
||||
"someField"
|
||||
Psl.Model.String
|
||||
[Psl.Model.List]
|
||||
[ Psl.Attribute.Attribute
|
||||
"default"
|
||||
[Psl.Argument.ArgUnnamed $ Psl.Argument.ArrayExpr []]
|
||||
]
|
||||
]
|
||||
),
|
||||
Psl.Schema.ModelBlock $
|
||||
|
Loading…
Reference in New Issue
Block a user