Skip to content

Commit d8d240d

Browse files
author
Zoran Cvetkov
committed
fix graphql_query tests
1 parent 67507c9 commit d8d240d

File tree

4 files changed

+44
-47
lines changed

4 files changed

+44
-47
lines changed

store/postgres/src/relational/ddl.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ use std::{
44
};
55

66
use graph::{
7-
data::subgraph::schema::POI_TABLE,
87
prelude::{BLOCK_NUMBER_MAX, ENV_VARS},
98
schema::InputSchema,
109
};
@@ -117,7 +116,7 @@ impl Table {
117116
Ok(cols)
118117
}
119118

120-
let vid_type = if self.name.as_str() == POI_TABLE {
119+
let vid_type = if self.object.is_poi() || !self.object.is_object_type() {
121120
"bigserial"
122121
} else {
123122
"bigint"

store/postgres/src/relational/ddl_tests.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -895,7 +895,7 @@ create index attr_0_1_data_amount
895895
on "sgd0815"."data" using btree("amount");
896896
897897
create table "sgd0815"."stats_hour" (
898-
vid bigint primary key,
898+
vid bigserial primary key,
899899
block$ int not null,
900900
"id" int8 not null,
901901
"timestamp" timestamptz not null,
@@ -913,7 +913,7 @@ create index attr_1_2_stats_hour_max_price
913913
on "sgd0815"."stats_hour" using btree("max_price");
914914
915915
create table "sgd0815"."stats_day" (
916-
vid bigint primary key,
916+
vid bigserial primary key,
917917
block$ int not null,
918918
"id" int8 not null,
919919
"timestamp" timestamptz not null,
@@ -992,7 +992,7 @@ create index attr_0_3_data_amount
992992
on "sgd0815"."data" using btree("amount");
993993
994994
create table "sgd0815"."stats_1_hour" (
995-
vid bigint primary key,
995+
vid bigserial primary key,
996996
block$ int not null,
997997
"id" int8 not null,
998998
"timestamp" timestamptz not null,
@@ -1008,7 +1008,7 @@ on "sgd0815"."stats_1_hour" using btree("volume");
10081008
10091009
10101010
create table "sgd0815"."stats_1_day" (
1011-
vid bigint primary key,
1011+
vid bigserial primary key,
10121012
block$ int not null,
10131013
"id" int8 not null,
10141014
"timestamp" timestamptz not null,
@@ -1024,7 +1024,7 @@ on "sgd0815"."stats_1_day" using btree("volume");
10241024
10251025
10261026
create table "sgd0815"."stats_2_hour" (
1027-
vid bigint primary key,
1027+
vid bigserial primary key,
10281028
block$ int not null,
10291029
"id" int8 not null,
10301030
"timestamp" timestamptz not null,
@@ -1044,7 +1044,7 @@ create index stats_2_hour_dims
10441044
on "sgd0815"."stats_2_hour"(group_1, timestamp);
10451045
10461046
create table "sgd0815"."stats_2_day" (
1047-
vid bigint primary key,
1047+
vid bigserial primary key,
10481048
block$ int not null,
10491049
"id" int8 not null,
10501050
"timestamp" timestamptz not null,
@@ -1064,7 +1064,7 @@ create index stats_2_day_dims
10641064
on "sgd0815"."stats_2_day"(group_1, timestamp);
10651065
10661066
create table "sgd0815"."stats_3_hour" (
1067-
vid bigint primary key,
1067+
vid bigserial primary key,
10681068
block$ int not null,
10691069
"id" int8 not null,
10701070
"timestamp" timestamptz not null,
@@ -1087,7 +1087,7 @@ create index stats_3_hour_dims
10871087
on "sgd0815"."stats_3_hour"(group_2, group_1, timestamp);
10881088
10891089
create table "sgd0815"."stats_3_day" (
1090-
vid bigint primary key,
1090+
vid bigserial primary key,
10911091
block$ int not null,
10921092
"id" int8 not null,
10931093
"timestamp" timestamptz not null,

store/test-store/tests/graph/entity_cache.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -193,11 +193,8 @@ fn sort_by_entity_key(mut mods: Vec<EntityModification>) -> Vec<EntityModificati
193193
fn filter_vid(arr: Vec<Entity>) -> Vec<Entity> {
194194
arr.into_iter()
195195
.map(|mut e| {
196-
// println!("E1: {:?}", e);
197196
e.remove("vid");
198-
// println!("E2: {:?}", e);
199197
e.remove_null_fields();
200-
// println!("E3: {:?}", e);
201198
e
202199
})
203200
.collect()

store/test-store/tests/graphql/query.rs

Lines changed: 35 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -468,25 +468,25 @@ async fn insert_test_entities(
468468
(
469469
"Musician",
470470
vec![
471-
entity! { is => id: "m1", name: "John", mainBand: "b1", bands: vec!["b1", "b2"], favoriteCount: 10, birthDate: timestamp.clone() },
472-
entity! { is => id: "m2", name: "Lisa", mainBand: "b1", bands: vec!["b1"], favoriteCount: 100, birthDate: timestamp.clone() },
471+
entity! { is => id: "m1", name: "John", mainBand: "b1", bands: vec!["b1", "b2"], favoriteCount: 10, birthDate: timestamp.clone(), vid: 0i64 },
472+
entity! { is => id: "m2", name: "Lisa", mainBand: "b1", bands: vec!["b1"], favoriteCount: 100, birthDate: timestamp.clone(), vid: 1i64 },
473473
],
474474
),
475475
("Publisher", vec![entity! { is => id: pub1 }]),
476476
(
477477
"Band",
478478
vec![
479-
entity! { is => id: "b1", name: "The Musicians", originalSongs: vec![s[1], s[2]] },
480-
entity! { is => id: "b2", name: "The Amateurs", originalSongs: vec![s[1], s[3], s[4]] },
479+
entity! { is => id: "b1", name: "The Musicians", originalSongs: vec![s[1], s[2]], vid: 0i64 },
480+
entity! { is => id: "b2", name: "The Amateurs", originalSongs: vec![s[1], s[3], s[4]], vid: 1i64 },
481481
],
482482
),
483483
(
484484
"Song",
485485
vec![
486-
entity! { is => id: s[1], sid: "s1", title: "Cheesy Tune", publisher: pub1, writtenBy: "m1", media: vec![md[1], md[2]] },
487-
entity! { is => id: s[2], sid: "s2", title: "Rock Tune", publisher: pub1, writtenBy: "m2", media: vec![md[3], md[4]] },
488-
entity! { is => id: s[3], sid: "s3", title: "Pop Tune", publisher: pub1, writtenBy: "m1", media: vec![md[5]] },
489-
entity! { is => id: s[4], sid: "s4", title: "Folk Tune", publisher: pub1, writtenBy: "m3", media: vec![md[6]] },
486+
entity! { is => id: s[1], sid: "s1", title: "Cheesy Tune", publisher: pub1, writtenBy: "m1", media: vec![md[1], md[2]], vid: 0i64 },
487+
entity! { is => id: s[2], sid: "s2", title: "Rock Tune", publisher: pub1, writtenBy: "m2", media: vec![md[3], md[4]], vid: 1i64 },
488+
entity! { is => id: s[3], sid: "s3", title: "Pop Tune", publisher: pub1, writtenBy: "m1", media: vec![md[5]], vid: 2i64 },
489+
entity! { is => id: s[4], sid: "s4", title: "Folk Tune", publisher: pub1, writtenBy: "m3", media: vec![md[6]], vid: 3i64 },
490490
],
491491
),
492492
(
@@ -498,31 +498,31 @@ async fn insert_test_entities(
498498
(
499499
"SongStat",
500500
vec![
501-
entity! { is => id: s[1], played: 10 },
502-
entity! { is => id: s[2], played: 15 },
501+
entity! { is => id: s[1], played: 10, vid: 0i64 },
502+
entity! { is => id: s[2], played: 15, vid: 1i64 },
503503
],
504504
),
505505
(
506506
"BandReview",
507507
vec![
508-
entity! { is => id: "r1", body: "Bad musicians", band: "b1", author: "u1" },
509-
entity! { is => id: "r2", body: "Good amateurs", band: "b2", author: "u2" },
510-
entity! { is => id: "r5", body: "Very Bad musicians", band: "b1", author: "u3" },
508+
entity! { is => id: "r1", body: "Bad musicians", band: "b1", author: "u1", vid: 0i64 },
509+
entity! { is => id: "r2", body: "Good amateurs", band: "b2", author: "u2", vid: 1i64 },
510+
entity! { is => id: "r5", body: "Very Bad musicians", band: "b1", author: "u3", vid: 2i64 },
511511
],
512512
),
513513
(
514514
"SongReview",
515515
vec![
516-
entity! { is => id: "r3", body: "Bad", song: s[2], author: "u1" },
517-
entity! { is => id: "r4", body: "Good", song: s[3], author: "u2" },
518-
entity! { is => id: "r6", body: "Very Bad", song: s[2], author: "u3" },
516+
entity! { is => id: "r3", body: "Bad", song: s[2], author: "u1", vid: 0i64 },
517+
entity! { is => id: "r4", body: "Good", song: s[3], author: "u2", vid: 1i64 },
518+
entity! { is => id: "r6", body: "Very Bad", song: s[2], author: "u3", vid: 2i64 },
519519
],
520520
),
521521
(
522522
"User",
523523
vec![
524-
entity! { is => id: "u1", name: "Baden", latestSongReview: "r3", latestBandReview: "r1", latestReview: "r1" },
525-
entity! { is => id: "u2", name: "Goodwill", latestSongReview: "r4", latestBandReview: "r2", latestReview: "r2" },
524+
entity! { is => id: "u1", name: "Baden", latestSongReview: "r3", latestBandReview: "r1", latestReview: "r1", vid: 0i64 },
525+
entity! { is => id: "u2", name: "Goodwill", latestSongReview: "r4", latestBandReview: "r2", latestReview: "r2", vid: 1i64 },
526526
],
527527
),
528528
(
@@ -534,17 +534,17 @@ async fn insert_test_entities(
534534
(
535535
"Photo",
536536
vec![
537-
entity! { is => id: md[1], title: "Cheesy Tune Single Cover", author: "u1" },
538-
entity! { is => id: md[3], title: "Rock Tune Single Cover", author: "u1" },
539-
entity! { is => id: md[5], title: "Pop Tune Single Cover", author: "u1" },
537+
entity! { is => id: md[1], title: "Cheesy Tune Single Cover", author: "u1", vid: 0i64 },
538+
entity! { is => id: md[3], title: "Rock Tune Single Cover", author: "u1", vid: 1i64 },
539+
entity! { is => id: md[5], title: "Pop Tune Single Cover", author: "u1", vid: 2i64 },
540540
],
541541
),
542542
(
543543
"Video",
544544
vec![
545-
entity! { is => id: md[2], title: "Cheesy Tune Music Video", author: "u2" },
546-
entity! { is => id: md[4], title: "Rock Tune Music Video", author: "u2" },
547-
entity! { is => id: md[6], title: "Folk Tune Music Video", author: "u2" },
545+
entity! { is => id: md[2], title: "Cheesy Tune Music Video", author: "u2", vid: 0i64 },
546+
entity! { is => id: md[4], title: "Rock Tune Music Video", author: "u2", vid: 1i64 },
547+
entity! { is => id: md[6], title: "Folk Tune Music Video", author: "u2", vid: 2i64 },
548548
],
549549
),
550550
(
@@ -554,29 +554,30 @@ async fn insert_test_entities(
554554
(
555555
"Single",
556556
vec![
557-
entity! { is => id: "rl2", title: "Rock", songs: vec![s[2]] },
558-
entity! { is => id: "rl3", title: "Cheesy", songs: vec![s[1]] },
559-
entity! { is => id: "rl4", title: "Silence", songs: Vec::<graph::prelude::Value>::new() },
557+
entity! { is => id: "rl2", title: "Rock", songs: vec![s[2]], vid: 0i64 },
558+
entity! { is => id: "rl3", title: "Cheesy", songs: vec![s[1]], vid: 1i64 },
559+
entity! { is => id: "rl4", title: "Silence", songs: Vec::<graph::prelude::Value>::new(), vid: 2i64 },
560560
],
561561
),
562562
(
563563
"Plays",
564564
vec![
565-
entity! { is => id: 1i64, timestamp: ts0, song: s[1], user: "u1"},
566-
entity! { is => id: 2i64, timestamp: ts0, song: s[1], user: "u2"},
567-
entity! { is => id: 3i64, timestamp: ts0, song: s[2], user: "u1"},
568-
entity! { is => id: 4i64, timestamp: ts0, song: s[1], user: "u1"},
569-
entity! { is => id: 5i64, timestamp: ts0, song: s[1], user: "u1"},
565+
entity! { is => id: 1i64, timestamp: ts0, song: s[1], user: "u1", vid: 0i64 },
566+
entity! { is => id: 2i64, timestamp: ts0, song: s[1], user: "u2", vid: 1i64 },
567+
entity! { is => id: 3i64, timestamp: ts0, song: s[2], user: "u1", vid: 2i64 },
568+
entity! { is => id: 4i64, timestamp: ts0, song: s[1], user: "u1", vid: 3i64 },
569+
entity! { is => id: 5i64, timestamp: ts0, song: s[1], user: "u1", vid: 4i64 },
570570
],
571571
),
572572
];
573+
573574
let entities0 = insert_ops(&manifest.schema, entities0);
574575

575576
let entities1 = vec![(
576577
"Musician",
577578
vec![
578-
entity! { is => id: "m3", name: "Tom", mainBand: "b2", bands: vec!["b1", "b2"], favoriteCount: 5, birthDate: timestamp.clone() },
579-
entity! { is => id: "m4", name: "Valerie", bands: Vec::<String>::new(), favoriteCount: 20, birthDate: timestamp.clone() },
579+
entity! { is => id: "m3", name: "Tom", mainBand: "b2", bands: vec!["b1", "b2"], favoriteCount: 5, birthDate: timestamp.clone(), vid: 2i64 },
580+
entity! { is => id: "m4", name: "Valerie", bands: Vec::<String>::new(), favoriteCount: 20, birthDate: timestamp.clone(), vid: 3i64 },
580581
],
581582
)];
582583
let entities1 = insert_ops(&manifest.schema, entities1);

0 commit comments

Comments
 (0)