Support passing values to select(fields...)
for insert into ... select from
#3068
-
The issue #1106 and then the PR #1496 added support for this kind of request : INSERT INTO the_table (id, name, description)
SELECT id + 1, name, description FROM the_table Using this construct : table! (
the_table {
id -> Integer,
name -> Text,
description -> Text,
}
);
diesel::insert_into(the_table)
.values(the_table.select(id + 1, name, description))
.execute(conn); However, it is not possible to re-create this following query using Diesel: INSERT INTO the_table (id, name, description)
SELECT 55, name, description FROM the_table diesel::insert_into(the_table)
.values(the_table.select(55, name, description))
.execute(conn); This rust code produce the following errors:
Would it be possible to support passing direct values to |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
I've converted this to a discussion as this clearly is not a bug report and it does not follow the issue template (that's mandatory). |
Beta Was this translation helpful? Give feedback.
I've converted this to a discussion as this clearly is not a bug report and it does not follow the issue template (that's mandatory).
To answer this as question: Yes this is already possible. You need to convert the rust value explicitly to a diesel query builder expression. This can be done by for example calling
IntoSql::into_sql()
.