Skip to content

Commit f24ddf6

Browse files
fix: nullabe column query (#406)
1 parent 62ce45d commit f24ddf6

File tree

4 files changed

+6
-6
lines changed

4 files changed

+6
-6
lines changed

.sqlx/query-97da37af0d64378cb622cab14bb3b0ce33a0002d170200d77afeee60a7977278.json renamed to .sqlx/query-fa065a78ad10eeace15f64083f4d944b9d45eb6c60d7eece8878ed26b3530484.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/pgt_completions/src/providers/columns.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ pub fn complete_columns<'a>(ctx: &CompletionContext<'a>, builder: &mut Completio
2020
description: format!("Table: {}.{}", col.schema_name, col.table_name),
2121
kind: CompletionItemKind::Column,
2222
completion_text: None,
23-
detail: Some(col.type_name.to_string()),
23+
detail: col.type_name.as_ref().map(|t| t.to_string()),
2424
};
2525

2626
// autocomplete with the alias in a join clause if we find one

crates/pgt_schema_cache/src/columns.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ pub struct Column {
4848

4949
pub schema_name: String,
5050
pub type_id: i64,
51-
pub type_name: String,
51+
pub type_name: Option<String>,
5252
pub is_nullable: bool,
5353

5454
pub is_primary_key: bool,

crates/pgt_schema_cache/src/queries/columns.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,10 @@ from
5252
and atts.attnum = ix.attnum
5353
left join pg_catalog.pg_attrdef def on atts.attrelid = def.adrelid
5454
and atts.attnum = def.adnum
55-
left join pg_catalog.pg_type tps on tps.oid = atts.atttypid
55+
left join pg_catalog.pg_type tps on atts.atttypid = tps.oid
5656
where
5757
-- system columns, such as `cmax` or `tableoid`, have negative `attnum`s
58-
atts.attnum >= 0
58+
atts.attnum >= 0 and atts.atttypid is not null and tps.oid is not null
5959
order by
6060
schema_name desc,
6161
table_name,

0 commit comments

Comments
 (0)