I have a three tables named: audit_logs, users, admin_users, whose corresponding ActiveRecord classes are: AuditLog, User, AdminUser.
Table users's id is integer type, and table admin_users's id is string type, AND BOTH admin_users and users has username field
The table audit_logs has :user_id(string) and :user_type two columns, and AuditLog has a belongs_to relationship: belongs_to :user, polymorphic: true
AND when I use ransack to search: AuditLog.ransack("user_of_User_type_username_eq => 'test')
I got the following error: ActiveRecord::StatementInvalid: PG::UndefinedFunction: ERROR: operator does not exist: integer = character varying, it occurred when LEFT OUTER JOIN "users" ON "users"."id" = "audit_log.id".
I don't know if it is a correct behavior to raise error OR it is more reasonable to do a type cast in background in this case.
Hi, there:
I have a three tables named: audit_logs, users, admin_users, whose corresponding ActiveRecord classes are: AuditLog, User, AdminUser.
Table users's id is integer type, and table admin_users's id is string type, AND BOTH admin_users and users has username field
The table audit_logs has :user_id(string) and :user_type two columns, and AuditLog has a belongs_to relationship:
belongs_to :user, polymorphic: true
AND when I use ransack to search:
AuditLog.ransack("user_of_User_type_username_eq => 'test')
I got the following error:
ActiveRecord::StatementInvalid: PG::UndefinedFunction: ERROR: operator does not exist: integer = character varying
, it occurred whenLEFT OUTER JOIN "users" ON "users"."id" = "audit_log.id"
.I don't know if it is a correct behavior to raise error OR it is more reasonable to do a type cast in background in this case.
Thank you!