bynk.types.select_tail_has_select
Error A D1, Postgres or MySql select[T] or firstAs[T] statement does not start at FROM (for example it begins with SELECT, WITH or a parenthesis); the compiler writes the SELECT and column list from T.
select[T] and firstAs[T] write the SELECT and the column list themselves, from the fields of the row record T, so the SQL you give is only the rest, starting at FROM. That way the columns are spelt once and cannot drift from the type. Start at FROM. A query that cannot (a WITH or a parenthesised one) is read with all and Json.decodeSql, which take the whole statement.
Example
let _ <- Orders.select[Order]("SELECT id, total FROM orders", []) // ✗ the compiler writes `SELECT`
let _ <- Orders.select[Order]("FROM orders", []) // ✓In the Book
See also
- The grammar rule it governs:
method_call. - Every code in its category, Type checking, on the diagnostic index.
bynk explain bynk.types.select_tail_has_selectshows the same from the installed toolchain, without a network.