jackc / edge

Edge provides graph functionality to ActiveRecord.
MIT License
90 stars 10 forks source link

PSQLException: ERROR: could not identify an equality operator for type json #4

Closed TheKidCoder closed 10 years ago

TheKidCoder commented 10 years ago

I have a postgres 9.3, Rails 4.0.2 app running on jRuby using edge.

Edge works well in most places except for a table that has JSON type rows. When I try to run 'with_descendants' I get the follow error:

ActiveRecord::StatementInvalid: ActiveRecord::JDBCError: org.postgresql.util.PSQLException: ERROR: could not identify an equality operator for type json

It generates the following SQL query:

Position: 142: SELECT  "application_documents".* FROM "application_documents"  WHERE "application_documents"."id" = (WITH RECURSIVE "all_nodes" AS ( SELECT "application_documents".* FROM "application_documents" UNION SELECT "application_documents"."id", "application_documents"."app_type", "application_documents"."name", "application_documents"."state", "application_documents"."carrier", "application_documents"."esignature", "application_documents"."pdf_file_name", "application_documents"."pdf", "application_documents"."created_at", "application_documents"."updated_at", "application_documents"."annotations", "application_documents"."schema", "application_documents"."parent_id" FROM "application_documents" INNER JOIN "all_nodes" ON "application_documents"."parent_id" = "all_nodes"."id" ) SELECT id FROM "all_nodes")  ORDER BY "application_documents"."id" ASC LIMIT 1

With the "schema" & "annotations" columns being JSON.

TheKidCoder commented 10 years ago

@JackC You are awesome!