Skip to content

Commit dd910d7

Browse files
authored
fix: where type issues (#958)
- Fixes issues with type counts. #### Migration notes --- - [ ] The change comes with new or modified tests - [ ] Hard-to-understand functions have explanatory comments - [ ] End-user documentation is updated to reflect the change <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Enhanced duplicate detection mechanism for type graphs. - Improved type identification and relationship tracking. - Added new root functions for dynamic entity management in type duplication. - **Refactor** - Updated model identifier handling in type generation. - Modified key management for skip models from type-based to string-based keys. - Transitioned from static to dynamic entity definitions for scalability. - **Bug Fixes** - Streamlined type duplicate detection logic. - Improved error handling for unsupported type scenarios. - Adjusted assertions for serialization size and type count limits in tests. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent eeb69c4 commit dd910d7

File tree

28 files changed

+982
-1130
lines changed

28 files changed

+982
-1130
lines changed

.ghjk/lock.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1986,7 +1986,7 @@
19861986
}
19871987
]
19881988
},
1989-
"bciqkxr25pjywutrwjgdbuqvhukulifkffcybdcswmbdp6g57uyxalty": {
1989+
"bciqmz5es3gg7277grznhdd22rd7tx646occ5qzm455dezuo24mfod6y": {
19901990
"provides": [
19911991
{
19921992
"ty": "posix.envVar",
@@ -2018,6 +2018,11 @@
20182018
"key": "V8_FORCE_DEBUG",
20192019
"val": "true"
20202020
},
2021+
{
2022+
"ty": "posix.envVar",
2023+
"key": "RUST_JOBS",
2024+
"val": "8"
2025+
},
20212026
{
20222027
"ty": "ghjk.ports.InstallSetRef",
20232028
"setId": "ghjkEnvProvInstSet___dev"
@@ -2066,7 +2071,7 @@
20662071
"_ecma": "bciqcqqs4e5l7nqt57e4bku3gjdxs2iruhfdl2ocayrkkcs4otx7ig7a",
20672072
"_rust": "bciqof7ogmp2lx2bzmkbrtmdmrmj7seytb6bl2sb4uhnsxkf5v24m75i",
20682073
"ci": "bciqbjavwy7rbire3zwlpgo2ifwzgnm6ywxqswnh6qxezwuvc4bqhrca",
2069-
"dev": "bciqkxr25pjywutrwjgdbuqvhukulifkffcybdcswmbdp6g57uyxalty",
2074+
"dev": "bciqmz5es3gg7277grznhdd22rd7tx646occ5qzm455dezuo24mfod6y",
20702075
"oci": "bciqmkulmynzdor24gykcjc2vtu2vmzcgavyyytftuf4sibd7yutzmvy"
20712076
}
20722077
}

ghjk.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,8 @@ env("dev")
109109
// debug v8 to fix MET-633: segementation fault bug with custom deno rt
110110
// doesn't appear in CI so only dev envs get it
111111
.var("V8_FORCE_DEBUG", "true")
112+
// limit to 8 cores to avoid exhausting memory
113+
.var("RUST_JOBS", "8")
112114
.install(
113115
ports.act(),
114116
ports.cargobi({ crateName: "whiz", locked: true }),

src/typegraph/core/src/runtimes/prisma/type_generation/input_type.rs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,23 +20,23 @@ enum Operation {
2020

2121
pub struct InputType {
2222
model_id: TypeId,
23-
skip_rel: Vec<String>,
23+
skip_rel: std::collections::BTreeSet<String>,
2424
operation: Operation,
2525
}
2626

2727
impl InputType {
2828
pub fn for_create(model_id: TypeId) -> Self {
2929
Self {
3030
model_id,
31-
skip_rel: vec![],
31+
skip_rel: Default::default(),
3232
operation: Operation::Create,
3333
}
3434
}
3535

3636
pub fn for_update(model_id: TypeId) -> Self {
3737
Self {
3838
model_id,
39-
skip_rel: vec![],
39+
skip_rel: Default::default(),
4040
operation: Operation::Update,
4141
}
4242
}
@@ -66,7 +66,7 @@ impl TypeGen for InputType {
6666
model_id: prop.model_type.type_id,
6767
skip_rel: {
6868
let mut skip_rel = self.skip_rel.clone();
69-
skip_rel.push(rel_name.to_string());
69+
skip_rel.insert(rel_name.to_string());
7070
skip_rel
7171
},
7272
operation: Operation::Create,
@@ -98,7 +98,7 @@ impl TypeGen for InputType {
9898
model_id: prop.model_type.type_id,
9999
skip_rel: {
100100
let mut skip_rel = self.skip_rel.clone();
101-
skip_rel.push(rel_name.to_string());
101+
skip_rel.insert(rel_name.to_string());
102102
skip_rel
103103
},
104104
operation: Operation::Update,
@@ -218,7 +218,14 @@ impl TypeGen for InputType {
218218
let suffix = if self.skip_rel.is_empty() {
219219
"".to_string()
220220
} else {
221-
format!("_excluding_{}", self.skip_rel.join("_and_"))
221+
format!(
222+
"_excluding_{}",
223+
self.skip_rel
224+
.iter()
225+
.map(|owned| &owned[..])
226+
.collect::<Vec<_>>()
227+
.join("_and_")
228+
)
222229
};
223230
let op = match self.operation {
224231
Operation::Create => "create",

src/typegraph/core/src/runtimes/prisma/type_generation/out_type.rs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ use super::{Cardinality, TypeGen};
1212

1313
pub struct OutType {
1414
model_id: TypeId,
15-
skip_rel: Vec<String>, // list of relationships to skip to avoid infinite recursion
15+
skip_rel: std::collections::BTreeSet<String>, // list of relationships to skip to avoid infinite recursion
1616
}
1717

1818
impl OutType {
1919
pub fn new(model_id: TypeId) -> Self {
2020
Self {
2121
model_id,
22-
skip_rel: vec![],
22+
skip_rel: Default::default(),
2323
}
2424
}
2525
}
@@ -45,7 +45,7 @@ impl TypeGen for OutType {
4545
}
4646

4747
let mut skip_rel = self.skip_rel.clone();
48-
skip_rel.push(rel_name.clone());
48+
skip_rel.insert(rel_name.clone());
4949

5050
let out_type = context.generate(&OutType {
5151
model_id: prop.model_type.type_id,
@@ -78,7 +78,14 @@ impl TypeGen for OutType {
7878
let suffix = if self.skip_rel.is_empty() {
7979
String::new()
8080
} else {
81-
format!("_excluding_{}", self.skip_rel.join("_and_"))
81+
format!(
82+
"_excluding_{}",
83+
self.skip_rel
84+
.iter()
85+
.map(|owned| &owned[..])
86+
.collect::<Vec<_>>()
87+
.join("_and_")
88+
)
8289
};
8390
Ok(format!("{model_name}_output{suffix}"))
8491
}

src/typegraph/core/src/runtimes/prisma/type_generation/snapshots/typegraph_core__runtimes__prisma__type_generation__query_where_expr__tests__Post__QueryWhereExpr.snap

Lines changed: 26 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -2,51 +2,33 @@
22
source: src/typegraph/core/src/runtimes/prisma/type_generation/query_where_expr.rs
33
expression: "tree::print(post_where_expr)"
44
---
5-
root: struct 'Post_query_where_input' #122
6-
├── [AND]: optional #119
7-
│ └── item: list #118
8-
│ └── item: &Post_query_where_input #117
9-
├── [NOT]: optional #120
10-
│ └── item: &Post_query_where_input #117
11-
├── [OR]: optional #119
12-
│ └── item: list #118
13-
│ └── item: &Post_query_where_input #117
14-
├── [author]: optional #114
15-
│ └── item: struct 'User_where_excluding_Post' #113
16-
│ ├── [id]: optional #95
5+
root: struct 'Post_query_where_input' #103
6+
├── [AND]: optional #100
7+
│ └── item: list #99
8+
│ └── item: &Post_query_where_input #98
9+
├── [NOT]: optional #101
10+
│ └── item: &Post_query_where_input #98
11+
├── [OR]: optional #100
12+
│ └── item: list #99
13+
│ └── item: &Post_query_where_input #98
14+
├── [author]: optional #95
15+
│ └── item: struct 'User_where_excluding_Post' #94
16+
│ ├── [id]: optional #82
1717
│ │ └── item: &_prisma_integer_filter_ex #16
18-
│ ├── [name]: optional #96
18+
│ ├── [name]: optional #83
1919
│ │ └── item: &_prisma_string_filter_ex #33
20-
│ └── [posts]: optional #111
21-
│ └── item: union #110
22-
│ ├── variant_0: struct #105
23-
│ │ └── [every]: optional #104
24-
│ │ └── item: struct 'Post_where_excluding_User_and_Post' #103
25-
│ │ ├── [author]: optional #101
26-
│ │ │ └── item: &User_where_excluding_Post #100
27-
│ │ ├── [id]: optional #98
28-
│ │ │ └── item: &_prisma_integer_filter_ex #16
29-
│ │ └── [title]: optional #99
30-
│ │ └── item: &_prisma_string_filter_ex #33
31-
│ ├── variant_1: struct #107
32-
│ │ └── [some]: optional #106
33-
│ │ └── item: struct 'Post_where_excluding_User_and_Post' #103
34-
│ │ ├── [author]: optional #101
35-
│ │ │ └── item: &User_where_excluding_Post #100
36-
│ │ ├── [id]: optional #98
37-
│ │ │ └── item: &_prisma_integer_filter_ex #16
38-
│ │ └── [title]: optional #99
39-
│ │ └── item: &_prisma_string_filter_ex #33
40-
│ └── variant_2: struct #109
41-
│ └── [none]: optional #108
42-
│ └── item: struct 'Post_where_excluding_User_and_Post' #103
43-
│ ├── [author]: optional #101
44-
│ │ └── item: &User_where_excluding_Post #100
45-
│ ├── [id]: optional #98
46-
│ │ └── item: &_prisma_integer_filter_ex #16
47-
│ └── [title]: optional #99
48-
│ └── item: &_prisma_string_filter_ex #33
49-
├── [id]: optional #92
20+
│ └── [posts]: optional #92
21+
│ └── item: union #91
22+
│ ├── variant_0: struct #86
23+
│ │ └── [every]: optional #85
24+
│ │ └── item: &Post_where #84
25+
│ ├── variant_1: struct #88
26+
│ │ └── [some]: optional #87
27+
│ │ └── item: &Post_where #84
28+
│ └── variant_2: struct #90
29+
│ └── [none]: optional #89
30+
│ └── item: &Post_where #84
31+
├── [id]: optional #79
5032
│ └── item: &_prisma_integer_filter_ex #16
51-
└── [title]: optional #93
33+
└── [title]: optional #80
5234
└── item: &_prisma_string_filter_ex #33

src/typegraph/core/src/runtimes/prisma/type_generation/snapshots/typegraph_core__runtimes__prisma__type_generation__query_where_expr__tests__User__QueryWhereExpr.snap

Lines changed: 26 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
source: src/typegraph/core/src/runtimes/prisma/type_generation/query_where_expr.rs
33
expression: "tree::print(user_where_expr)"
44
---
5-
root: struct 'User_query_where_input' #89
6-
├── [AND]: optional #86
7-
│ └── item: list #85
8-
│ └── item: &User_query_where_input #84
9-
├── [NOT]: optional #87
10-
│ └── item: &User_query_where_input #84
11-
├── [OR]: optional #86
12-
│ └── item: list #85
13-
│ └── item: &User_query_where_input #84
5+
root: struct 'User_query_where_input' #76
6+
├── [AND]: optional #73
7+
│ └── item: list #72
8+
│ └── item: &User_query_where_input #71
9+
├── [NOT]: optional #74
10+
│ └── item: &User_query_where_input #71
11+
├── [OR]: optional #73
12+
│ └── item: list #72
13+
│ └── item: &User_query_where_input #71
1414
├── [id]: optional #32
1515
│ └── item: optional '_prisma_integer_filter_ex' #31
1616
│ └── item: union #29
@@ -107,76 +107,31 @@ root: struct 'User_query_where_input' #89
107107
│ │ └── item: string #35
108108
│ └── [startsWith]: optional #36
109109
│ └── item: string #35
110-
└── [posts]: optional #81
111-
└── item: union #80
112-
├── variant_0: struct #75
113-
│ └── [every]: optional #74
114-
│ └── item: struct 'Post_where_excluding_User' #73
115-
│ ├── [author]: optional #71
116-
│ │ └── item: struct 'User_where_excluding_Post_and_User' #70
117-
│ │ ├── [id]: optional #58
118-
│ │ │ └── item: &_prisma_integer_filter_ex #16
119-
│ │ ├── [name]: optional #59
120-
│ │ │ └── item: &_prisma_string_filter_ex #33
121-
│ │ └── [posts]: optional #68
122-
│ │ └── item: union #67
123-
│ │ ├── variant_0: struct #62
124-
│ │ │ └── [every]: optional #61
125-
│ │ │ └── item: &Post_where_excluding_User #60
126-
│ │ ├── variant_1: struct #64
127-
│ │ │ └── [some]: optional #63
128-
│ │ │ └── item: &Post_where_excluding_User #60
129-
│ │ └── variant_2: struct #66
130-
│ │ └── [none]: optional #65
131-
│ │ └── item: &Post_where_excluding_User #60
110+
└── [posts]: optional #68
111+
└── item: union #67
112+
├── variant_0: struct #62
113+
│ └── [every]: optional #61
114+
│ └── item: struct 'Post_where_excluding_User' #60
115+
│ ├── [author]: optional #58
116+
│ │ └── item: &User_where #57
132117
│ ├── [id]: optional #55
133118
│ │ └── item: &_prisma_integer_filter_ex #16
134119
│ └── [title]: optional #56
135120
│ └── item: &_prisma_string_filter_ex #33
136-
├── variant_1: struct #77
137-
│ └── [some]: optional #76
138-
│ └── item: struct 'Post_where_excluding_User' #73
139-
│ ├── [author]: optional #71
140-
│ │ └── item: struct 'User_where_excluding_Post_and_User' #70
141-
│ │ ├── [id]: optional #58
142-
│ │ │ └── item: &_prisma_integer_filter_ex #16
143-
│ │ ├── [name]: optional #59
144-
│ │ │ └── item: &_prisma_string_filter_ex #33
145-
│ │ └── [posts]: optional #68
146-
│ │ └── item: union #67
147-
│ │ ├── variant_0: struct #62
148-
│ │ │ └── [every]: optional #61
149-
│ │ │ └── item: &Post_where_excluding_User #60
150-
│ │ ├── variant_1: struct #64
151-
│ │ │ └── [some]: optional #63
152-
│ │ │ └── item: &Post_where_excluding_User #60
153-
│ │ └── variant_2: struct #66
154-
│ │ └── [none]: optional #65
155-
│ │ └── item: &Post_where_excluding_User #60
121+
├── variant_1: struct #64
122+
│ └── [some]: optional #63
123+
│ └── item: struct 'Post_where_excluding_User' #60
124+
│ ├── [author]: optional #58
125+
│ │ └── item: &User_where #57
156126
│ ├── [id]: optional #55
157127
│ │ └── item: &_prisma_integer_filter_ex #16
158128
│ └── [title]: optional #56
159129
│ └── item: &_prisma_string_filter_ex #33
160-
└── variant_2: struct #79
161-
└── [none]: optional #78
162-
└── item: struct 'Post_where_excluding_User' #73
163-
├── [author]: optional #71
164-
│ └── item: struct 'User_where_excluding_Post_and_User' #70
165-
│ ├── [id]: optional #58
166-
│ │ └── item: &_prisma_integer_filter_ex #16
167-
│ ├── [name]: optional #59
168-
│ │ └── item: &_prisma_string_filter_ex #33
169-
│ └── [posts]: optional #68
170-
│ └── item: union #67
171-
│ ├── variant_0: struct #62
172-
│ │ └── [every]: optional #61
173-
│ │ └── item: &Post_where_excluding_User #60
174-
│ ├── variant_1: struct #64
175-
│ │ └── [some]: optional #63
176-
│ │ └── item: &Post_where_excluding_User #60
177-
│ └── variant_2: struct #66
178-
│ └── [none]: optional #65
179-
│ └── item: &Post_where_excluding_User #60
130+
└── variant_2: struct #66
131+
└── [none]: optional #65
132+
└── item: struct 'Post_where_excluding_User' #60
133+
├── [author]: optional #58
134+
│ └── item: &User_where #57
180135
├── [id]: optional #55
181136
│ └── item: &_prisma_integer_filter_ex #16
182137
└── [title]: optional #56

0 commit comments

Comments
 (0)