Skip to main content

build_query

Function build_query 

Source
pub fn build_query(
    table: &str,
    pk_columns: &[String],
    keys: &[Vec<String>],
    predicates: Option<&[Predicate]>,
    projection: Option<&[String]>,
) -> (String, Vec<String>)
Expand description

Build a SQL query from table name, primary keys, lookup keys, predicates, and an optional projection.

Returns (sql_string, parameter_values). Parameter values are embedded inline for predicates (using predicate_to_sql), while key lookups use ANY($1) for single-column PKs or (pk1, pk2) IN (...) for composite keys.

§Arguments

  • table - Table name (possibly schema-qualified)
  • pk_columns - Primary key column names
  • keys - Lookup key values as strings
  • predicates - Optional filter predicates (NOT NotEq — those are filtered out automatically)
  • projection - Optional column names to select (default: *)

§Returns

A tuple of (SQL string, parameter values for $N placeholders).