Why does the same query not work using `select`?
I'm using SQLite and the "tags" field is a json data type.
This the following works fine:
Using
Error:
This the following works fine:
Using
select throws an error:Error:
selectYour "id" field references a column "items"."id", but the table "items" is not part of the query! Did you forget to join it?const statement = sql`select * from ${items}, json_each(${items.tags}) as "jsonTags"`
.append(sql` where "jsonTags"."value" ->> '$.name' = 'hello'`)
await searchDB().all(statement);const columns = getTableColumns(items);
await db
.select(columns)
.from(sql`${items}, json_each(${items.tags}) as "jsonTags"`)
.where(sql` "jsonTags"."value" ->> '$.name' = 'hello'`)