我有一个使用Ransack宝石的应用程序,我将它从Mysql转换为Postgres.
在排序列来自关联表并且distinct选项设置为true的实例中,Postgres会抛出此错误:
PG::InvalidColumnReference: ERROR: for SELECT DISTINCT, ORDER BY expressions must appear in select list
Run Code Online (Sandbox Code Playgroud)
Ransack github页面说,在这种情况下,"你是靠自己的."
什么是最好的 - 任何! - 处理这种情况的策略?
q = Contact.includes(:contact_type).search
q.sorts = ['contact_type_name asc']
q.result(distinct: true)
PG::InvalidColumnReference: ERROR: for SELECT DISTINCT, ORDER BY expressions must appear in select list
Run Code Online (Sandbox Code Playgroud)
谢谢!
我有以下格式的许多字符串.只有最后一个"/"之后的部分是不同的......
"http://www.google.com/calendar/feeds/user_name%40gmail.com/public/basic/_8gq3ecpo6gp3ib9n8h0jeb9k8l13ab9o85346b9k8gqk4g9h74s4aea26s"
Run Code Online (Sandbox Code Playgroud)
我需要捕获最后一个"/"之后的部分.
任何帮助表示赞赏.