This repository has been archived by the owner on Sep 2, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 860
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4811 from prisma/OneRelationIsNullBug
One relation is null bug
- Loading branch information
Showing
3 changed files
with
102 additions
and
2 deletions.
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
94 changes: 94 additions & 0 deletions
94
...er/servers/api/src/test/scala/com/prisma/api/filters/nonEmbedded/RelationIsNullSpec.scala
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,94 @@ | ||
package com.prisma.api.filters.nonEmbedded | ||
|
||
import com.prisma.api.ApiSpecBase | ||
import com.prisma.shared.models.ConnectorCapability | ||
import com.prisma.shared.models.ConnectorCapability.{JoinRelationLinksCapability, Prisma2Capability} | ||
import com.prisma.shared.schema_dsl.SchemaDsl | ||
import org.scalatest._ | ||
|
||
class RelationIsNullSpec extends FlatSpec with Matchers with ApiSpecBase { | ||
override def runOnlyForCapabilities = Set(JoinRelationLinksCapability) | ||
override def doNotRunForCapabilities = Set(Prisma2Capability) | ||
|
||
val project = SchemaDsl.fromStringV11() { | ||
""" | ||
|type Message { | ||
| id: ID! @id | ||
| image: Image @relation(link: INLINE, name: "MessageImageRelation") | ||
| messageName: String | ||
|} | ||
| | ||
|type Image { | ||
| id: ID! @id | ||
| message: Message @relation(name: "MessageImageRelation") | ||
| imageName: String | ||
|} | ||
""" | ||
} | ||
|
||
override protected def beforeAll(): Unit = { | ||
super.beforeAll() | ||
database.setup(project) | ||
} | ||
|
||
override def beforeEach() = { | ||
super.beforeEach() | ||
database.truncateProjectTables(project) | ||
|
||
// add data | ||
server.query( | ||
"""mutation {createMessage( | ||
| data: { | ||
| messageName: "message 1", | ||
| } | ||
|){messageName}}""", | ||
project = project | ||
) | ||
|
||
server.query( | ||
"""mutation {createMessage( | ||
| data: { | ||
| messageName: "message 2", | ||
| image:{create:{imageName:"image 1"}} | ||
| } | ||
|){messageName}}""", | ||
project = project | ||
) | ||
|
||
server.query( | ||
"""mutation {createImage( | ||
| data: { | ||
| imageName: "image 2" | ||
| } | ||
|){imageName}}""", | ||
project = project | ||
) | ||
|
||
} | ||
|
||
"Filtering on whether a relation is null" should "work" in { | ||
server | ||
.query( | ||
query = """query { | ||
| images(where: { message: null }) { | ||
| imageName | ||
| } | ||
|}""", | ||
project = project | ||
) | ||
.toString should be("""{"data":{"images":[{"imageName":"image 2"}]}}""") | ||
} | ||
|
||
"Filtering on whether a relation is null" should "work 2" in { | ||
server | ||
.query( | ||
query = """query { | ||
| messages(where: { image: null }) { | ||
| messageName | ||
| } | ||
|}""", | ||
project = project | ||
) | ||
.toString should be("""{"data":{"messages":[{"messageName":"message 1"}]}}""") | ||
} | ||
} |
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