feat(data-grid): support manual reference display values
This commit is contained in:
24 files changed
+893
-90
No files matched your search
@@ -3585,7 +3585,7 @@ fn postgres_indexes_for_relations_query_tiers() -> [&'static str; 2] {
|
||||
fn postgres_indexes_for_relations_sql() -> &'static str {
|
||||
"SELECT t.oid::bigint AS relid, i.relname AS index_name, \
|
||||
array_agg(COALESCE(a.attname, pg_get_indexdef(ix.indexrelid, k.n::int, true)) ORDER BY k.n) AS columns, \
|
||||
ix.indisunique AS is_unique, \
|
||||
(ix.indisunique AND ix.indisvalid) AS is_unique, \
|
||||
ix.indisprimary AS is_primary, \
|
||||
pg_get_expr(ix.indpred, ix.indrelid) AS filter_expr, \
|
||||
am.amname AS index_type, \
|
||||
@@ -3600,7 +3600,7 @@ fn postgres_indexes_for_relations_sql() -> &'static str {
|
||||
JOIN LATERAL unnest(ix.indkey) WITH ORDINALITY AS k(attnum, n) ON true \
|
||||
LEFT JOIN pg_attribute a ON a.attrelid = t.oid AND a.attnum = k.attnum AND k.attnum > 0 \
|
||||
WHERE t.oid = ANY($1::bigint[]) \
|
||||
GROUP BY t.oid, i.relname, i.oid, ix.indisunique, ix.indisprimary, ix.indpred, ix.indrelid, am.amname, ix.indnkeyatts, ix.indkey \
|
||||
GROUP BY t.oid, i.relname, i.oid, ix.indisunique, ix.indisvalid, ix.indisprimary, ix.indpred, ix.indrelid, am.amname, ix.indnkeyatts, ix.indkey \
|
||||
ORDER BY t.oid, i.relname"
|
||||
}
|
||||
|
||||
@@ -3617,7 +3617,7 @@ fn postgres_indexes_for_relations_compat_sql() -> &'static str {
|
||||
AND a.attnum > 0 \
|
||||
ORDER BY pos.n \
|
||||
) AS columns, \
|
||||
ix.indisunique AS is_unique, \
|
||||
(ix.indisunique AND ix.indisvalid) AS is_unique, \
|
||||
ix.indisprimary AS is_primary, \
|
||||
pg_get_expr(ix.indpred, ix.indrelid) AS filter_expr, \
|
||||
am.amname AS index_type, \
|
||||
@@ -6517,7 +6517,7 @@ async fn execute_query_with_max_rows_inner(
|
||||
// (schema, table) instead of a batch of oids — see the note there.
|
||||
const POSTGRES_INDEXES_SQL: &str = "SELECT i.relname AS index_name, \
|
||||
array_agg(COALESCE(a.attname, pg_get_indexdef(ix.indexrelid, k.n::int, true)) ORDER BY k.n) AS columns, \
|
||||
ix.indisunique AS is_unique, \
|
||||
(ix.indisunique AND ix.indisvalid) AS is_unique, \
|
||||
ix.indisprimary AS is_primary, \
|
||||
pg_get_expr(ix.indpred, ix.indrelid) AS filter_expr, \
|
||||
am.amname AS index_type, \
|
||||
@@ -6533,7 +6533,7 @@ const POSTGRES_INDEXES_SQL: &str = "SELECT i.relname AS index_name, \
|
||||
JOIN LATERAL unnest(ix.indkey) WITH ORDINALITY AS k(attnum, n) ON true \
|
||||
LEFT JOIN pg_attribute a ON a.attrelid = t.oid AND a.attnum = k.attnum AND k.attnum > 0 \
|
||||
WHERE t.oid = (CASE WHEN $1 = '' THEN quote_ident($2) ELSE quote_ident($1) || '.' || quote_ident($2) END)::regclass \
|
||||
GROUP BY i.relname, i.oid, ix.indisunique, ix.indisprimary, ix.indpred, ix.indrelid, am.amname, ix.indnkeyatts, ix.indkey \
|
||||
GROUP BY i.relname, i.oid, ix.indisunique, ix.indisvalid, ix.indisprimary, ix.indpred, ix.indrelid, am.amname, ix.indnkeyatts, ix.indkey \
|
||||
ORDER BY i.relname";
|
||||
|
||||
// Compat-tier sibling of `postgres_indexes_for_relations_compat_sql` (~line
|
||||
@@ -6548,7 +6548,7 @@ const POSTGRES_INDEXES_COMPAT_SQL: &str = "SELECT i.relname AS index_name, \
|
||||
AND a.attnum > 0 \
|
||||
ORDER BY pos.n \
|
||||
) AS columns, \
|
||||
ix.indisunique AS is_unique, \
|
||||
(ix.indisunique AND ix.indisvalid) AS is_unique, \
|
||||
ix.indisprimary AS is_primary, \
|
||||
pg_get_expr(ix.indpred, ix.indrelid) AS filter_expr, \
|
||||
am.amname AS index_type, \
|
||||
@@ -10739,6 +10739,14 @@ mod tests {
|
||||
assert!(!POSTGRES_INDEXES_COMPAT_SQL.contains("WITH ORDINALITY"));
|
||||
assert!(POSTGRES_INDEXES_COMPAT_SQL.contains("generate_series"));
|
||||
assert!(POSTGRES_INDEXES_COMPAT_SQL.contains("string_to_array(ix.indkey::text, ' ')"));
|
||||
for sql in [
|
||||
POSTGRES_INDEXES_SQL,
|
||||
POSTGRES_INDEXES_COMPAT_SQL,
|
||||
postgres_indexes_for_relations_sql(),
|
||||
postgres_indexes_for_relations_compat_sql(),
|
||||
] {
|
||||
assert!(sql.contains("ix.indisunique AND ix.indisvalid"));
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in new issue
Block a user