-
Following is a example. SELECT universities.id, name, chong_wen_baos.university_remark
FROM universities left join chong_wen_baos on universities.id = chong_wen_baos.university_id; Sure i expect to merge with others where conditions on two tables, conditionally, like this: Add so, use BaseQuery instead of raw SQL is preferred. I checked the document, no see any related usage documented. Thanks |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
I test myself, hardly, use Avram::QueryBuilder again, the generated SQL is correct, but failed when try convert it to Avram::Queryable in the last. builder = Avram::QueryBuilder.new(table: :universities)
builder = builder.join(Avram::Join::Left.new(:universities, :chong_wen_baos))
builder = builder.select_direct(
[
"universities.id", "code", "name","chong_wen_baos.university_remark"
])
builder = builder.where(Avram::Where::Raw.new("chong_wen_baos.university_remark is not null")) if is_exists_description
if q.presence
builder = builder.where(Avram::Where::Raw.new("(name &@~ ? OR chong_wen_baos.university_remark &@~ ?)", q, q))
end
query = UniversityQuery.new.left_join_chong_wen_baos
query.query = builder With following error:
Because i need use paginate, so, i have to convert it to Queryable. |
Beta Was this translation helpful? Give feedback.
-
This is not really something supported in Avram. The issue with allowing for custom selects is that
|
Beta Was this translation helpful? Give feedback.
Hi, @jwoertink , in fact, i figure out how to solve my issue after fight with it one day, i don't want to select column in two table, i just don't know how to OR query on two table columns
following is the the expected answer.
As you can see…