Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions schema-engine/sql-schema-describer/src/postgres.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1300,20 +1300,25 @@

async fn get_enums(&self, sql_schema: &mut SqlSchema) -> DescriberResult<()> {
let namespaces = &sql_schema.namespaces;
let is_external_clause = if self.is_cockroach() {
" AND t.typname NOT LIKE 'crdb_internal%'"
} else {
""

Check warning on line 1306 in schema-engine/sql-schema-describer/src/postgres.rs

View workflow job for this annotation

GitHub Actions / run lints and formatting checks

Diff in /home/runner/work/prisma-engines/prisma-engines/schema-engine/sql-schema-describer/src/postgres.rs
};

let sql = "
let sql = format!(r#"
SELECT
t.typname AS name,
e.enumlabel AS value,
n.nspname AS namespace,
obj_description(t.oid, 'pg_type') AS description
FROM pg_type t
JOIN pg_enum e ON t.oid = e.enumtypid

Check warning on line 1316 in schema-engine/sql-schema-describer/src/postgres.rs

View workflow job for this annotation

GitHub Actions / run lints and formatting checks

Diff in /home/runner/work/prisma-engines/prisma-engines/schema-engine/sql-schema-describer/src/postgres.rs
JOIN pg_catalog.pg_namespace n ON n.oid = t.typnamespace
WHERE n.nspname = ANY ( $1 )
ORDER BY e.enumsortorder";
WHERE n.nspname = ANY ( $1 ) {is_external_clause}
ORDER BY e.enumsortorder"#);

let rows = self.conn.query_raw(sql, &[Value::array(namespaces)]).await?;
let rows = self.conn.query_raw(sql.as_str(), &[Value::array(namespaces)]).await?;
let mut enum_values: BTreeMap<(NamespaceId, String, Option<String>), Vec<String>> = BTreeMap::new();

for row in rows.into_iter() {
Expand Down Expand Up @@ -1385,7 +1390,7 @@
let index_name = row.get_expect_string("index_name");
let is_unique = row.get_expect_bool("is_unique");
let is_primary_key = row.get_expect_bool("is_primary_key");
let column_index = row.get_expect_i64("column_index");

Check failure on line 1393 in schema-engine/sql-schema-describer/src/postgres.rs

View workflow job for this annotation

GitHub Actions / sqlite / json query 1/4

unused variable: `column_index`

Check failure on line 1393 in schema-engine/sql-schema-describer/src/postgres.rs

View workflow job for this annotation

GitHub Actions / sqlite / json query 4/4

unused variable: `column_index`

Check failure on line 1393 in schema-engine/sql-schema-describer/src/postgres.rs

View workflow job for this annotation

GitHub Actions / sqlite / graphql query 4/4

unused variable: `column_index`

Check failure on line 1393 in schema-engine/sql-schema-describer/src/postgres.rs

View workflow job for this annotation

GitHub Actions / sqlite on Linux / sqlite

unused variable: `column_index`

Check failure on line 1393 in schema-engine/sql-schema-describer/src/postgres.rs

View workflow job for this annotation

GitHub Actions / sqlite / graphql query 1/4

unused variable: `column_index`

Check failure on line 1393 in schema-engine/sql-schema-describer/src/postgres.rs

View workflow job for this annotation

GitHub Actions / sqlite / graphql query 3/4

unused variable: `column_index`

Check failure on line 1393 in schema-engine/sql-schema-describer/src/postgres.rs

View workflow job for this annotation

GitHub Actions / sqlite / json query 2/4

unused variable: `column_index`

Check failure on line 1393 in schema-engine/sql-schema-describer/src/postgres.rs

View workflow job for this annotation

GitHub Actions / MongoDB v5 / graphql query 4/4

unused variable: `column_index`

Check failure on line 1393 in schema-engine/sql-schema-describer/src/postgres.rs

View workflow job for this annotation

GitHub Actions / MongoDB v5 / graphql query 3/4

unused variable: `column_index`

Check failure on line 1393 in schema-engine/sql-schema-describer/src/postgres.rs

View workflow job for this annotation

GitHub Actions / sqlite / graphql query 2/4

unused variable: `column_index`

Check failure on line 1393 in schema-engine/sql-schema-describer/src/postgres.rs

View workflow job for this annotation

GitHub Actions / Postgres v16 / json join 3/4

unused variable: `column_index`

Check failure on line 1393 in schema-engine/sql-schema-describer/src/postgres.rs

View workflow job for this annotation

GitHub Actions / Postgres v16 / json query 2/4

unused variable: `column_index`

Check failure on line 1393 in schema-engine/sql-schema-describer/src/postgres.rs

View workflow job for this annotation

GitHub Actions / Postgres v16 / json query 3/4

unused variable: `column_index`

Check failure on line 1393 in schema-engine/sql-schema-describer/src/postgres.rs

View workflow job for this annotation

GitHub Actions / Postgres v16 / graphql query 2/4

unused variable: `column_index`

Check failure on line 1393 in schema-engine/sql-schema-describer/src/postgres.rs

View workflow job for this annotation

GitHub Actions / MongoDB v5 / json query 4/4

unused variable: `column_index`

Check failure on line 1393 in schema-engine/sql-schema-describer/src/postgres.rs

View workflow job for this annotation

GitHub Actions / Postgres v16 / graphql query 3/4

unused variable: `column_index`

Check failure on line 1393 in schema-engine/sql-schema-describer/src/postgres.rs

View workflow job for this annotation

GitHub Actions / MongoDB v5 / json query 2/4

unused variable: `column_index`

Check failure on line 1393 in schema-engine/sql-schema-describer/src/postgres.rs

View workflow job for this annotation

GitHub Actions / Postgres v16 / graphql query 1/4

unused variable: `column_index`

Check failure on line 1393 in schema-engine/sql-schema-describer/src/postgres.rs

View workflow job for this annotation

GitHub Actions / postgres16 on Linux / postgres16

unused variable: `column_index`

Check failure on line 1393 in schema-engine/sql-schema-describer/src/postgres.rs

View workflow job for this annotation

GitHub Actions / Postgres v16 / json join 1/4

unused variable: `column_index`

Check failure on line 1393 in schema-engine/sql-schema-describer/src/postgres.rs

View workflow job for this annotation

GitHub Actions / Postgres v16 / json join 2/4

unused variable: `column_index`

Check failure on line 1393 in schema-engine/sql-schema-describer/src/postgres.rs

View workflow job for this annotation

GitHub Actions / MongoDB v5 / json query 3/4

unused variable: `column_index`

Check failure on line 1393 in schema-engine/sql-schema-describer/src/postgres.rs

View workflow job for this annotation

GitHub Actions / Postgres v16 / graphql join 3/4

unused variable: `column_index`

Check failure on line 1393 in schema-engine/sql-schema-describer/src/postgres.rs

View workflow job for this annotation

GitHub Actions / Postgres v16 / json query 1/4

unused variable: `column_index`

Check failure on line 1393 in schema-engine/sql-schema-describer/src/postgres.rs

View workflow job for this annotation

GitHub Actions / test

unused variable: `column_index`

Check failure on line 1393 in schema-engine/sql-schema-describer/src/postgres.rs

View workflow job for this annotation

GitHub Actions / Postgres v16 / json query 4/4

unused variable: `column_index`

Check failure on line 1393 in schema-engine/sql-schema-describer/src/postgres.rs

View workflow job for this annotation

GitHub Actions / MSSQL v2022 / json query 2/4

unused variable: `column_index`

Check failure on line 1393 in schema-engine/sql-schema-describer/src/postgres.rs

View workflow job for this annotation

GitHub Actions / MSSQL v2022 / json query 4/4

unused variable: `column_index`

Check failure on line 1393 in schema-engine/sql-schema-describer/src/postgres.rs

View workflow job for this annotation

GitHub Actions / MSSQL v2022 / graphql query 3/4

unused variable: `column_index`

Check failure on line 1393 in schema-engine/sql-schema-describer/src/postgres.rs

View workflow job for this annotation

GitHub Actions / MSSQL v2022 / graphql query 4/4

unused variable: `column_index`

Check failure on line 1393 in schema-engine/sql-schema-describer/src/postgres.rs

View workflow job for this annotation

GitHub Actions / MongoDB v5 / graphql query 1/4

unused variable: `column_index`

Check failure on line 1393 in schema-engine/sql-schema-describer/src/postgres.rs

View workflow job for this annotation

GitHub Actions / MongoDB v5 / graphql query 2/4

unused variable: `column_index`

Check failure on line 1393 in schema-engine/sql-schema-describer/src/postgres.rs

View workflow job for this annotation

GitHub Actions / Postgres v16 / graphql join 2/4

unused variable: `column_index`

Check failure on line 1393 in schema-engine/sql-schema-describer/src/postgres.rs

View workflow job for this annotation

GitHub Actions / Postgres v16 / graphql query 4/4

unused variable: `column_index`

Check failure on line 1393 in schema-engine/sql-schema-describer/src/postgres.rs

View workflow job for this annotation

GitHub Actions / mssql_2022 on Linux / mssql_2022

unused variable: `column_index`

Check failure on line 1393 in schema-engine/sql-schema-describer/src/postgres.rs

View workflow job for this annotation

GitHub Actions / MSSQL v2022 / graphql query 2/4

unused variable: `column_index`

Check failure on line 1393 in schema-engine/sql-schema-describer/src/postgres.rs

View workflow job for this annotation

GitHub Actions / Postgres v16 / json join 4/4

unused variable: `column_index`

Check failure on line 1393 in schema-engine/sql-schema-describer/src/postgres.rs

View workflow job for this annotation

GitHub Actions / Postgres v16 / graphql join 1/4

unused variable: `column_index`

Check failure on line 1393 in schema-engine/sql-schema-describer/src/postgres.rs

View workflow job for this annotation

GitHub Actions / MSSQL v2022 / graphql query 1/4

unused variable: `column_index`

Check failure on line 1393 in schema-engine/sql-schema-describer/src/postgres.rs

View workflow job for this annotation

GitHub Actions / test (postgres16, false, postgres, 16)

unused variable: `column_index`

Check failure on line 1393 in schema-engine/sql-schema-describer/src/postgres.rs

View workflow job for this annotation

GitHub Actions / Postgres v16 / graphql join 4/4

unused variable: `column_index`

Check failure on line 1393 in schema-engine/sql-schema-describer/src/postgres.rs

View workflow job for this annotation

GitHub Actions / MSSQL v2022 / json query 1/4

unused variable: `column_index`

Check failure on line 1393 in schema-engine/sql-schema-describer/src/postgres.rs

View workflow job for this annotation

GitHub Actions / MSSQL v2022 / json query 3/4

unused variable: `column_index`

Check failure on line 1393 in schema-engine/sql-schema-describer/src/postgres.rs

View workflow job for this annotation

GitHub Actions / MySQL v8 / graphql join 1/4

unused variable: `column_index`

Check failure on line 1393 in schema-engine/sql-schema-describer/src/postgres.rs

View workflow job for this annotation

GitHub Actions / MySQL v8 / json join 4/4

unused variable: `column_index`

Check failure on line 1393 in schema-engine/sql-schema-describer/src/postgres.rs

View workflow job for this annotation

GitHub Actions / MySQL v8 / json query 1/4

unused variable: `column_index`

Check failure on line 1393 in schema-engine/sql-schema-describer/src/postgres.rs

View workflow job for this annotation

GitHub Actions / sqlite / json query 3/4

unused variable: `column_index`

Check failure on line 1393 in schema-engine/sql-schema-describer/src/postgres.rs

View workflow job for this annotation

GitHub Actions / MySQL v8 / graphql query 3/4

unused variable: `column_index`

Check failure on line 1393 in schema-engine/sql-schema-describer/src/postgres.rs

View workflow job for this annotation

GitHub Actions / MySQL v8 / graphql query 1/4

unused variable: `column_index`

Check failure on line 1393 in schema-engine/sql-schema-describer/src/postgres.rs

View workflow job for this annotation

GitHub Actions / MySQL v8 / json join 1/4

unused variable: `column_index`

Check failure on line 1393 in schema-engine/sql-schema-describer/src/postgres.rs

View workflow job for this annotation

GitHub Actions / MySQL v8 / json query 2/4

unused variable: `column_index`

Check failure on line 1393 in schema-engine/sql-schema-describer/src/postgres.rs

View workflow job for this annotation

GitHub Actions / MySQL v8 / json join 2/4

unused variable: `column_index`

Check failure on line 1393 in schema-engine/sql-schema-describer/src/postgres.rs

View workflow job for this annotation

GitHub Actions / MySQL v8 / json query 3/4

unused variable: `column_index`

Check failure on line 1393 in schema-engine/sql-schema-describer/src/postgres.rs

View workflow job for this annotation

GitHub Actions / mysql_8 on Linux / mysql_8

unused variable: `column_index`

Check failure on line 1393 in schema-engine/sql-schema-describer/src/postgres.rs

View workflow job for this annotation

GitHub Actions / MySQL v8 / graphql join 4/4

unused variable: `column_index`

Check failure on line 1393 in schema-engine/sql-schema-describer/src/postgres.rs

View workflow job for this annotation

GitHub Actions / MySQL v8 / json query 4/4

unused variable: `column_index`

Check failure on line 1393 in schema-engine/sql-schema-describer/src/postgres.rs

View workflow job for this annotation

GitHub Actions / MySQL v8 / json join 3/4

unused variable: `column_index`

Check failure on line 1393 in schema-engine/sql-schema-describer/src/postgres.rs

View workflow job for this annotation

GitHub Actions / MySQL v8 / graphql query 4/4

unused variable: `column_index`

Check failure on line 1393 in schema-engine/sql-schema-describer/src/postgres.rs

View workflow job for this annotation

GitHub Actions / MySQL v8 / graphql join 2/4

unused variable: `column_index`

Check failure on line 1393 in schema-engine/sql-schema-describer/src/postgres.rs

View workflow job for this annotation

GitHub Actions / MySQL v8 / graphql query 2/4

unused variable: `column_index`

Check failure on line 1393 in schema-engine/sql-schema-describer/src/postgres.rs

View workflow job for this annotation

GitHub Actions / MySQL v8 / graphql join 3/4

unused variable: `column_index`

Check failure on line 1393 in schema-engine/sql-schema-describer/src/postgres.rs

View workflow job for this annotation

GitHub Actions / MongoDB v5 / json query 1/4

unused variable: `column_index`

Check failure on line 1393 in schema-engine/sql-schema-describer/src/postgres.rs

View workflow job for this annotation

GitHub Actions / compilation (ubuntu-latest, schema-engine-cli) / compile schema-engine-cli @ ubuntu-latest

unused variable: `column_index`

Check failure on line 1393 in schema-engine/sql-schema-describer/src/postgres.rs

View workflow job for this annotation

GitHub Actions / compilation (windows-latest, schema-engine-cli) / compile schema-engine-cli @ windows-latest

unused variable: `column_index`
let index_algo = row.get_expect_string("index_algo");

let sort_order = row.get_string("column_order").map(|v| match v.as_ref() {
Expand Down Expand Up @@ -1415,7 +1420,7 @@
};

// * Note: Expression Indexes can have 1 & 2
if column_index == 0 {
if current_index.is_none() {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise, for multi-region tables this fails on line 1452 due to the unwrap.

We filter out "hidden" columns on tables, and the multi-region configuration is hidden, but does show up in the index, therefore column_index ends up being 1 for the the first "real" column in the index.

// new index!
let index_id = if is_primary_key {
sql_schema.push_primary_key(table_id, index_name)
Expand Down
Loading