split into multiple test cases
@@ -11,8 +11,6 @@ class VeryManyMutationsSpec extends FlatSpec with Matchers with ApiSpecBase with
override def runOnlyForCapabilities = Set(JoinRelationLinksCapability)
//Postgres has a limit of 32678 parameters to a query
-
- "The delete many Mutation" should "delete the items matching the where clause" in {
val project: Project = SchemaDsl.fromStringV11() {
s"""
|model Top {
@@ -24,9 +22,13 @@ class VeryManyMutationsSpec extends FlatSpec with Matchers with ApiSpecBase with
|model Middle {
| id String @id @default(cuid())
| int Int
+ | top Top?
|}
"""
}
+
+ override protected def beforeAll(): Unit = {
+ super.beforeAll()
database.setup(project)
def createTop(int: Int): Unit = {
@@ -83,13 +85,26 @@ class VeryManyMutationsSpec extends FlatSpec with Matchers with ApiSpecBase with
val futures = (1 to 1000).map(int => Future { createTop(int) })
val five_minutes = 300
Future.sequence(futures).await(five_minutes)
+ }
- // relations must work with that many records
- println(server.query("""query {tops { middles { int } }}""", project))
+ "Expanding relations for a lot 1000 records" should "work" in {
+ // get 1000 tops and their middles
+ server.query("""query {tops { middles { int } }}""", project)
+ }
+ // The Postgres communication protocol uses a signed 16 bit integer to identify the number of query parameters, so you can't execute a query that contains more than 32,768 of them.
+ // source: https://github.com/sfackler/rust-postgres/issues/356#issuecomment-391415848
+ "Expanding relations for a lot 40000 records" should "work" taggedAs (IgnorePostgres) in {
+ // get 40000 middles and their tops
+ server.query("""query {middles { top { int } }}""", project)
+ }
+
+ "The update many Mutation" should "work" in {
val update = server.query("""mutation {updateManyMiddles(where: { int_gt: 100 } data:{int: 500}){count}}""", project)
update.pathAsLong("data.updateManyMiddles.count") should equal(36291)
+ }
+ "The delete many Mutation" should "work" in {
val result = server.query("""mutation {deleteManyMiddles(where: { int_gt: 100 }){count}}""", project)
result.pathAsLong("data.deleteManyMiddles.count") should equal(36291)
}
