squirrel
squirrel copied to clipboard
JoinSelect feature for joining a SelectBuilder
This would allow us to join against a subquery against another table with conditional where clauses. Otherwise, we need to join against the entire table, which does not satisfy our performance requirements.
I was able to work around this with the current interface using the JoinClause you can pass it a sqlizer, it looks something like this
squirrel.Select("resources.*").
From("resources").
JoinClause(
// join for permission checks
squirrel.Select("resource_id::uuid", "array_agg(action) AS actions").
From("resource_entities").
Where(squirel.Eq{"user_id": userID}).
GroupBy("resource_id").
Prefix("LEFT JOIN (").Suffix(") AS ra ON (resources.resource_id = ra.resource_id)"),
).
Where(filterSqlizer)
That is an ok workaround, but I would really like to see JoinSelect, as it would be significantly cleaner and not require use of Prefix and Suffix