athena_rs 3.26.2

Hyper performant polyglot Database driver
Documentation
//! Constraint-query definitions for schema catalog introspection.
//!
//! This module owns raw SQL text for unique-constraint introspection queries
//! used by schema catalog endpoints.

/// Query for unique constraints on one table.
const UNIQUE_CONSTRAINTS_QUERY: &str = r#"
        SELECT tc.constraint_name, kcu.column_name
        FROM information_schema.table_constraints AS tc
        JOIN information_schema.key_column_usage AS kcu
          ON tc.constraint_name = kcu.constraint_name
         AND tc.table_schema = kcu.table_schema
         AND tc.table_name = kcu.table_name
        WHERE tc.constraint_type = 'UNIQUE'
          AND tc.table_name = $1
          AND tc.table_schema = $2
        ORDER BY tc.constraint_name, kcu.ordinal_position
        "#;

/// Returns the unique-constraints query text.
pub(super) fn unique_constraints_query() -> &'static str {
    UNIQUE_CONSTRAINTS_QUERY
}