Your Question
I would like to perform a request in the form of:
SELECT …
ORDER BY ts_rank(ts, to_tsquery('english', 'tornado')), id DESC;
Where 'tornado' is a var, supplied by the user, so it must be treated as a var in a prepared statement and there is also id, which is a normal column, so something like that:
SELECT …
ORDER BY ts_rank(ts, to_tsquery('english', ?)), id DESC;
However .Order nor any of the clauses seem to support that
The document you expected this should be explained
https://gorm.io/docs/query.html#Order
Expected answer
Whether this is possible, and if not if it could be added to gorm
Thanks!
Comment From: github-actions[bot]
This issue has been automatically marked as stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 30 days
Comment From: jinzhu
There is an example in above link could resolve your issue?
db.Clauses(clause.OrderBy{
Expression: clause.Expr{SQL: "FIELD(id,?)", Vars: []interface{}{[]int{1, 2, 3}}, WithoutParentheses: true},
}).Find(&User{})
// SELECT * FROM users ORDER BY FIELD(id,1,2,3)