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 #4457 from prisma/MongoCursorBug
Mongo Aggregation Fixes
- Loading branch information
Showing
4 changed files
with
121 additions
and
27 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
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
51 changes: 51 additions & 0 deletions
51
server/servers/api/src/test/scala/com/prisma/api/queries/RelationFilterOrderingSpec.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,51 @@ | ||
package com.prisma.api.queries | ||
|
||
import com.prisma.api.{ApiSpecBase, TestDataModels} | ||
import org.scalatest.{FlatSpec, Matchers} | ||
|
||
class RelationFilterOrderingSpec extends FlatSpec with Matchers with ApiSpecBase { | ||
|
||
val datamodels = { | ||
val dm1 = """type Blog { | ||
id: ID! @id | ||
title: String! | ||
score: Int! | ||
labels: [Label!]! @relation(name: "BlogLabels", link: INLINE) | ||
} | ||
type Label { | ||
id: ID! @id | ||
text: String! @unique | ||
}""" | ||
|
||
val dm2 = """type Blog { | ||
id: ID! @id | ||
title: String! | ||
score: Int! | ||
labels: [Label!]! @relation(name: "BlogLabels", link: TABLE) | ||
} | ||
type Label { | ||
id: ID! @id | ||
text: String! @unique | ||
}""" | ||
|
||
TestDataModels(mongo = Vector(dm1), sql = Vector(dm2)) | ||
} | ||
|
||
"Using relational filters" should "return items in the specified order" in { | ||
datamodels.testV11 { project => | ||
server.query(s"""mutation {createLabel(data: {text: "x"}) {text }}""", project) | ||
|
||
server.query(s"""mutation {createBlog(data: {title: "blog_1", score: 10,labels: {connect: {text: "x"}}}) {title}}""", project) | ||
server.query(s"""mutation {createBlog(data: {title: "blog_1", score: 20,labels: {connect: {text: "x"}}}) {title}}""", project) | ||
server.query(s"""mutation {createBlog(data: {title: "blog_1", score: 30,labels: {connect: {text: "x"}}}) {title}}""", project) | ||
|
||
val res1 = server.query("""query {blogs(first: 2, orderBy: score_DESC) {title, score}}""", project) | ||
|
||
res1.toString should be("""{"data":{"blogs":[{"title":"blog_1","score":30},{"title":"blog_1","score":20}]}}""") | ||
|
||
val res2 = server.query("""query {blogs (first: 2, orderBy: score_DESC, where:{labels_some: {text: "x"}}) {title, score}}""", project) | ||
res2.toString should be("""{"data":{"blogs":[{"title":"blog_1","score":30},{"title":"blog_1","score":20}]}}""") | ||
|
||
} | ||
} | ||
} |