Replies: 2 comments 4 replies
-
For this case, you would just use raw SQL so you can fine tune exactly what you need. As long as the returning columns match up with a model, you can still cast to the model instance you need. query = <<-SQL
SELECT DISTINCT chong_wen_baos.updated_at, universities.id, ... universites.updated_at FROM universities left join chong_wen_baos on universities.id = chong_wen_baos.university_id ORDER BY chong_wen_baos.updated_at DESC NULLS LAST LIMIT 50 OFFSET 0.
SQL
AppDatabase.query_all(query, as: ChongWenBaos) |
Beta Was this translation helpful? Give feedback.
2 replies
-
How to concat this raw query with exists Queryable,and return a queryable
object which used for paginate? thanks
Jeremy Woertink ***@***.***> 于 2024年7月2日周二 22:32写道:
… all my exists work need to be rewrite, right?
No. You can use raw SQL for this query and use Avram::Queryable for the
other ones. I always use both in my projects.
—
Reply to this email directly, view it on GitHub
<#1904 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAEGCBRSFXONANXUNYDD3EDZKK2XNAVCNFSM6AAAAABKEAQD32VHI2DSMVQWIX3LMV43SRDJONRXK43TNFXW4Q3PNVWWK3TUHM4TSMZXGY3TK>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Basically, i build a SQL like following:
I built the order_by SQL use code like this:
But, as you can see, I only built the order by clause myself, but, pg complain, i need add same column into SELECT.
That is, it have to built following SQL to works.
So, is there a way to built above
SELECT DISTINCT chong_wen_baos.updated_at
manually?Thanks.
Beta Was this translation helpful? Give feedback.
All reactions