Manual column lists are easy to mistype, especially when a recursive step spans
multiple tables. The columns! macro accepts individual column paths and emits
both the runtime names and the tuple of Diesel column types. Use
table_columns! to refer to a Diesel table definition and capture every column
in declaration order.
use diesel::{prelude::*, sql_types::Integer};
use diesel_cte_ext::{columns, table_columns, Columns};
diesel::table! {
employees (id) {
id -> Integer,
manager_id -> Integer,
}
}
const MANAGER_COLUMNS: Columns<(employees::id, employees::manager_id)> =
columns!(employees::id, employees::manager_id);
const FULL_TABLE: Columns<employees::table> = table_columns!(employees::table);