Skip to content

Commit 561ae3a

Browse files
committed
load index names for onConflict clause
1 parent 8744da7 commit 561ae3a

File tree

4 files changed

+11
-16
lines changed

4 files changed

+11
-16
lines changed

sql/load_sql_context.sql

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,11 +278,14 @@ select
278278
array[]::text[]
279279
),
280280
'is_unique', pi.indisunique,
281-
'is_primary_key', pi.indisprimary
281+
'is_primary_key', pi.indisprimary,
282+
'name', pc_ix.relname
282283
)
283284
)
284285
from
285286
pg_catalog.pg_index pi
287+
join pg_catalog.pg_class pc_ix
288+
on pi.indexrelid = pc_ix.oid
286289
where
287290
pi.indrelid = pc.oid
288291
),

src/graphql.rs

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -788,7 +788,7 @@ impl ___Type for __Type {
788788
Self::Node(x) => x.enum_values(_include_deprecated),
789789
Self::NodeInterface(x) => x.enum_values(_include_deprecated),
790790
Self::InsertInput(x) => x.enum_values(_include_deprecated),
791-
Self::InsertOnConflictInput(x) => x.enum_values(),
791+
Self::InsertOnConflictInput(x) => x.enum_values(_include_deprecated),
792792
Self::InsertResponse(x) => x.enum_values(_include_deprecated),
793793
Self::UpdateInput(x) => x.enum_values(_include_deprecated),
794794
Self::UpdateResponse(x) => x.enum_values(_include_deprecated),
@@ -1454,17 +1454,9 @@ impl ___Type for MutationType {
14541454
},
14551455
__InputValue {
14561456
name_: "onConflict".to_string(),
1457-
type_: __Type::NonNull(NonNullType {
1458-
type_: Box::new(__Type::List(ListType {
1459-
type_: Box::new(__Type::NonNull(NonNullType {
1460-
type_: Box::new(__Type::InsertOnConflictInput(
1461-
InsertOnConflictType {
1462-
table: Arc::clone(table),
1463-
schema: Arc::clone(&self.schema),
1464-
},
1465-
)),
1466-
})),
1467-
})),
1457+
type_: __Type::InsertOnConflictInput(InsertOnConflictType {
1458+
table: Arc::clone(table),
1459+
schema: Arc::clone(&self.schema),
14681460
}),
14691461
description: None,
14701462
default_value: None,
@@ -3437,7 +3429,6 @@ impl ___Type for FuncCallResponseType {
34373429
}
34383430

34393431
use std::str::FromStr;
3440-
use std::string::ToString;
34413432

34423433
#[derive(Clone, Copy, Debug)]
34433434
pub enum FilterOp {
@@ -4155,7 +4146,7 @@ impl __Schema {
41554146
enum_: EnumSource::TableColumns(Arc::clone(table)),
41564147
schema: Arc::clone(&schema_rc),
41574148
}));
4158-
types_.push(__Type::InsertOnConflictType(InsertOnConflictType {
4149+
types_.push(__Type::InsertOnConflictInput(InsertOnConflictType {
41594150
table: Arc::clone(table),
41604151
schema: Arc::clone(&schema_rc),
41614152
}));

src/sql_types.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,7 @@ pub struct Index {
405405
pub column_names: Vec<String>,
406406
pub is_unique: bool,
407407
pub is_primary_key: bool,
408+
pub name: String,
408409
}
409410

410411
#[derive(Deserialize, Clone, Debug, Eq, PartialEq, Hash)]
@@ -530,6 +531,7 @@ impl Table {
530531
column_names: column_names.clone(),
531532
is_unique: true,
532533
is_primary_key: true,
534+
name: "dummy".to_string(),
533535
})
534536
}
535537
} else {

src/transpile.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ use crate::builder::*;
22
use crate::graphql::*;
33
use crate::sql_types::{Column, ForeignKey, ForeignKeyTableInfo, Function, Table, TypeDetails};
44
use itertools::Itertools;
5-
use pgrx::pg_sys::PgBuiltInOids;
65
use pgrx::prelude::*;
76
use pgrx::spi::SpiClient;
87
use pgrx::{direct_function_call, JsonB};

0 commit comments

Comments
 (0)