Skip to content

Commit 758ca22

Browse files
committed
load index names for onConflict clause
1 parent 01492e1 commit 758ca22

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
@@ -281,11 +281,14 @@ select
281281
array[]::text[]
282282
),
283283
'is_unique', pi.indisunique and pi.indpred is null,
284-
'is_primary_key', pi.indisprimary
284+
'is_primary_key', pi.indisprimary,
285+
'name', pc_ix.relname
285286
)
286287
)
287288
from
288289
pg_catalog.pg_index pi
290+
join pg_catalog.pg_class pc_ix
291+
on pi.indexrelid = pc_ix.oid
289292
where
290293
pi.indrelid = pc.oid
291294
),

src/graphql.rs

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -786,7 +786,7 @@ impl ___Type for __Type {
786786
Self::Node(x) => x.enum_values(_include_deprecated),
787787
Self::NodeInterface(x) => x.enum_values(_include_deprecated),
788788
Self::InsertInput(x) => x.enum_values(_include_deprecated),
789-
Self::InsertOnConflictInput(x) => x.enum_values(),
789+
Self::InsertOnConflictInput(x) => x.enum_values(_include_deprecated),
790790
Self::InsertResponse(x) => x.enum_values(_include_deprecated),
791791
Self::UpdateInput(x) => x.enum_values(_include_deprecated),
792792
Self::UpdateResponse(x) => x.enum_values(_include_deprecated),
@@ -1460,17 +1460,9 @@ impl ___Type for MutationType {
14601460
},
14611461
__InputValue {
14621462
name_: "onConflict".to_string(),
1463-
type_: __Type::NonNull(NonNullType {
1464-
type_: Box::new(__Type::List(ListType {
1465-
type_: Box::new(__Type::NonNull(NonNullType {
1466-
type_: Box::new(__Type::InsertOnConflictInput(
1467-
InsertOnConflictType {
1468-
table: Arc::clone(table),
1469-
schema: Arc::clone(&self.schema),
1470-
},
1471-
)),
1472-
})),
1473-
})),
1463+
type_: __Type::InsertOnConflictInput(InsertOnConflictType {
1464+
table: Arc::clone(table),
1465+
schema: Arc::clone(&self.schema),
14741466
}),
14751467
description: None,
14761468
default_value: None,
@@ -3444,7 +3436,6 @@ impl ___Type for FuncCallResponseType {
34443436
}
34453437

34463438
use std::str::FromStr;
3447-
use std::string::ToString;
34483439

34493440
#[derive(Clone, Copy, Debug)]
34503441
pub enum FilterOp {
@@ -4289,7 +4280,7 @@ impl __Schema {
42894280
enum_: EnumSource::TableColumns(Arc::clone(table)),
42904281
schema: Arc::clone(&schema_rc),
42914282
}));
4292-
types_.push(__Type::InsertOnConflictType(InsertOnConflictType {
4283+
types_.push(__Type::InsertOnConflictInput(InsertOnConflictType {
42934284
table: Arc::clone(table),
42944285
schema: Arc::clone(&schema_rc),
42954286
}));

src/sql_types.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,7 @@ pub struct Index {
417417
pub column_names: Vec<String>,
418418
pub is_unique: bool,
419419
pub is_primary_key: bool,
420+
pub name: String,
420421
}
421422

422423
#[derive(Deserialize, Clone, Debug, Eq, PartialEq, Hash)]
@@ -544,6 +545,7 @@ impl Table {
544545
column_names: column_names.clone(),
545546
is_unique: true,
546547
is_primary_key: true,
548+
name: "dummy".to_string(),
547549
})
548550
}
549551
} 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)