Skip to main content

select

Function select 

Source
pub fn select<I, E>(expressions: I) -> SelectBuilder
where I: IntoIterator<Item = E>, E: IntoExpr,
Expand description

Start building a SELECT query with the given column expressions.

Accepts any iterable of items implementing IntoExpr, which includes &str (interpreted as column names), Expr values, and raw Expression nodes. Returns a SelectBuilder that can be further refined with .from(), .where_(), .order_by(), etc.

ยงExamples

use polyglot_sql::builder::*;

// Using string slices (converted to column refs automatically)
let sql = select(["id", "name"]).from("users").to_sql();
assert_eq!(sql, "SELECT id, name FROM users");

// Using Expr values for computed columns
let sql = select([col("price").mul(col("qty")).alias("total")])
    .from("items")
    .to_sql();
assert_eq!(sql, "SELECT price * qty AS total FROM items");