Skip to content

Commit 4f075f5

Browse files
committed
rename operators and remove panic
1 parent 0c9364a commit 4f075f5

File tree

6 files changed

+65
-67
lines changed

6 files changed

+65
-67
lines changed

src/builder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1311,7 +1311,7 @@ where
13111311
)?;
13121312
let _: Scalar = match field
13131313
.get_arg(arg_name)
1314-
.unwrap_or_else(|| panic!("failed to get {arg_name} argument"))
1314+
.expect(&format!("failed to get {} argument", arg_name))
13151315
.type_()
13161316
.unmodified_type()
13171317
{

src/graphql.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3357,9 +3357,9 @@ impl ToString for FilterOp {
33573357
Self::ILike => "ilike",
33583358
Self::RegEx => "regex",
33593359
Self::IRegEx => "iregex",
3360-
Self::Contains => "cs",
3361-
Self::ContainedBy => "cd",
3362-
Self::Overlap => "ov",
3360+
Self::Contains => "contains",
3361+
Self::ContainedBy => "containedBy",
3362+
Self::Overlap => "overlaps",
33633363
}
33643364
.to_string()
33653365
}
@@ -3383,9 +3383,9 @@ impl FromStr for FilterOp {
33833383
"ilike" => Ok(Self::ILike),
33843384
"regex" => Ok(Self::RegEx),
33853385
"iregex" => Ok(Self::IRegEx),
3386-
"cs" => Ok(Self::Contains),
3387-
"cd" => Ok(Self::ContainedBy),
3388-
"ov" => Ok(Self::Overlap),
3386+
"contains" => Ok(Self::Contains),
3387+
"containedBy" => Ok(Self::ContainedBy),
3388+
"overlaps" => Ok(Self::Overlap),
33893389
_ => Err("Invalid filter operation".to_string()),
33903390
}
33913391
}
@@ -3519,7 +3519,7 @@ impl ___Type for FilterTypeType {
35193519

35203520
supported_ops
35213521
.iter()
3522-
.map(|op| match op {
3522+
.filter_map(|op| match op {
35233523
FilterOp::Equal
35243524
| FilterOp::NotEqual
35253525
| FilterOp::GreaterThan
@@ -3530,14 +3530,14 @@ impl ___Type for FilterTypeType {
35303530
| FilterOp::Like
35313531
| FilterOp::ILike
35323532
| FilterOp::RegEx
3533-
| FilterOp::IRegEx => __InputValue {
3533+
| FilterOp::IRegEx => Some(__InputValue {
35343534
name_: op.to_string(),
35353535
type_: __Type::Scalar(scalar.clone()),
35363536
description: None,
35373537
default_value: None,
35383538
sql_type: None,
3539-
},
3540-
FilterOp::In => __InputValue {
3539+
}),
3540+
FilterOp::In => Some(__InputValue {
35413541
name_: op.to_string(),
35423542
type_: __Type::List(ListType {
35433543
type_: Box::new(__Type::NonNull(NonNullType {
@@ -3547,8 +3547,8 @@ impl ___Type for FilterTypeType {
35473547
description: None,
35483548
default_value: None,
35493549
sql_type: None,
3550-
},
3551-
FilterOp::Is => __InputValue {
3550+
}),
3551+
FilterOp::Is => Some(__InputValue {
35523552
name_: "is".to_string(),
35533553
type_: __Type::Enum(EnumType {
35543554
enum_: EnumSource::FilterIs,
@@ -3557,9 +3557,9 @@ impl ___Type for FilterTypeType {
35573557
description: None,
35583558
default_value: None,
35593559
sql_type: None,
3560-
},
3560+
}),
35613561
// shouldn't happen since we've covered all cases in supported_ops
3562-
_ => panic!("encountered unknown FilterOp"),
3562+
FilterOp::Contains | FilterOp::ContainedBy | FilterOp::Overlap => None,
35633563
})
35643564
.collect()
35653565
}

src/sql_types.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -662,8 +662,6 @@ impl Context {
662662
},
663663
};
664664

665-
//panic!("{:?}, {}", fk, self.fkey_is_selectable(&fk));
666-
667665
fkeys.push(Arc::new(fk));
668666
}
669667
}

test/expected/resolve_connection_filter.out

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -232,11 +232,11 @@ begin;
232232
(1 row)
233233

234234
rollback to savepoint a;
235-
-- cs - array column contains the input scalar
235+
-- contains - array column contains the input scalar
236236
select jsonb_pretty(
237237
graphql.resolve($$
238238
{
239-
accountCollection(filter: {tags: {cs: "customer"}}) {
239+
accountCollection(filter: {tags: {contains: "customer"}}) {
240240
edges {
241241
node {
242242
id
@@ -269,11 +269,11 @@ begin;
269269
(1 row)
270270

271271
rollback to savepoint a;
272-
-- cd - array column is contained by input scalar (aka, the only value in the array column is the input scalar)
272+
-- containedBy - array column is contained by input scalar (aka, the only value in the array column is the input scalar)
273273
select jsonb_pretty(
274274
graphql.resolve($$
275275
{
276-
accountCollection(filter: {tags: {cd: "customer"}}) {
276+
accountCollection(filter: {tags: {containedBy: "customer"}}) {
277277
edges {
278278
node {
279279
id
@@ -301,11 +301,11 @@ begin;
301301
(1 row)
302302

303303
rollback to savepoint a;
304-
-- cs - array column contains the input array
304+
-- contains - array column contains the input array
305305
select jsonb_pretty(
306306
graphql.resolve($$
307307
{
308-
accountCollection(filter: {tags: {cs: ["customer", "priority"]}}) {
308+
accountCollection(filter: {tags: {contains: ["customer", "priority"]}}) {
309309
edges {
310310
node {
311311
id
@@ -333,11 +333,11 @@ begin;
333333
(1 row)
334334

335335
rollback to savepoint a;
336-
-- cd - array column is contained by input array
336+
-- containedByd - array column is contained by input array
337337
select jsonb_pretty(
338338
graphql.resolve($$
339339
{
340-
accountCollection(filter: {tags: {cd: ["customer", "priority"]}}) {
340+
accountCollection(filter: {tags: {containedBy: ["customer", "priority"]}}) {
341341
edges {
342342
node {
343343
id
@@ -370,11 +370,11 @@ begin;
370370
(1 row)
371371

372372
rollback to savepoint a;
373-
-- ov - array column overlaps with input array
373+
-- overlaps - array column overlaps with input array
374374
select jsonb_pretty(
375375
graphql.resolve($$
376376
{
377-
accountCollection(filter: {tags: {ov: ["customer", "priority"]}}) {
377+
accountCollection(filter: {tags: {overlaps: ["customer", "priority"]}}) {
378378
edges {
379379
node {
380380
id

0 commit comments

Comments
 (0)