How to set Custom fields on query


Im working with rust nightly and diesel 1.3.0 and mysql feature

Hello, I have something like this.
let results = places::table

What I pretend is to change the line
.select(places::table::all_columns()) to something like
.select(“MY CUSTOM FIELDS”) taking the fields from a

THanks in advence


That is not possible in a general way, so that’s nothing that could be fixed by diesel 2.0
Let’s try to elaborate the problem on a example.

table! {
    example(id) {
        id -> Integer,
        some_text -> Text,
        some_bool -> Bool,

enum ColumnToSelect {

fn select_from_example(column: ColumnToSelect, conn: &PgConnection, id: i32) -> Result<MyQueryResult, MyError> {
    let query = example::table.filter(example::id.eq(id));
    let query = match column {
        ColumnToSelect::Id =>,
        ColumnToSelect::SomeText =>,
        ColumnToSelect::SomeBool =>,

So the question to answer is how should MyQueryResult look like? We really need to know which types are returned by some query to deserialize the result correctly.

Beside of that it is already possible do do such things today if and only if all queries return the same type using boxed queries or diesel-dynamic-schema


I am also looking to find a solution for this.

Is it possible to add an unsafe first function that returns a pointer? This is already being done in the database connection modules. Can this be sent to the caller as a raw pointer or would it not be feasible to free the memory after the user uses it?

Alternately they can get wrapped inside an enum.