Is it possible to write this query with honeysql?
select *
from foo
left join bar on (foo.id = bar.foo_id AND (bar.x = 'baz'))
where foo.label = 'xxx';Of course.
(sql/format {:select :*
:from :foo
:left-join [:bar
[:and [:= :foo/id :bar/foo-id] [:= :bar/x "baz"]]]
:where [:= :foo/label "xxx"]})
=> ["SELECT * FROM foo LEFT JOIN bar ON (foo.id = bar.foo_id) AND (bar.x = ?) WHERE foo.label = ?" "baz" "xxx"]If you need those strings to be inlined, just wrap them in [:inline ...].
thanks! I was getting an error, I thought it was an issue with the generated query, but after your response I noticed I did I typo on my original query. Also thanks for pointing me to [:inline ...] :)