Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Requesting a sort on virtual attribute results in HTTP 500 #220

Closed
atruskie opened this issue Jun 28, 2015 · 1 comment
Closed

Requesting a sort on virtual attribute results in HTTP 500 #220

atruskie opened this issue Jun 28, 2015 · 1 comment

Comments

@atruskie
Copy link
Member

POST http://staging.ecosounds.org/audio_events/filter

Body:

{"filter":{"isReference":{"eq":true}},"paging":{"items":10,"page":1},"sorting":{"orderBy":"durationSeconds","direction":"desc"}}

Response:

{"meta":{"status":500,"message":"Internal Server Error","error":{"details":"Internal server error","info":null}},"data":null}

Expected:
Either

  • A 4xx (i.e. bad request) if sorting is not supported for virtual columns
  • Or for the request to work properly
@cofiem
Copy link
Contributor

cofiem commented Jun 29, 2015

An ActiveRecord::StatementInvalid occurred in audio_events#filter:

  PG::UndefinedColumn: ERROR:  column audio_events.duration_seconds does not exist
LINE 1: ...AND "audio_events"."is_reference" = 't'  ORDER BY "audio_eve...
                                                             ^
: SELECT  "audio_events"."id", "audio_events"."audio_recording_id", "audio_events"."start_time_seconds", "audio_events"."end_time_seconds", "audio_events"."low_frequency_hertz", "audio_events"."high_frequency_hertz", "audio_events"."is_reference", "audio_events"."creator_id", "audio_events"."updated_at", "audio_events"."created_at" FROM "audio_events" INNER JOIN "audio_recordings" ON "audio_recordings"."id" = "audio_events"."audio_recording_id" AND ("audio_recordings"."deleted_at" IS NULL) INNER JOIN "sites" ON "sites"."id" = "audio_recordings"."site_id" AND ("sites"."deleted_at" IS NULL) INNER JOIN "projects_sites" ON "projects_sites"."site_id" = "sites"."id" INNER JOIN "projects" ON "projects"."id" = "projects_sites"."project_id" AND ("projects"."deleted_at" IS NULL) WHERE ("audio_events"."deleted_at" IS NULL) AND (("projects"."id" IN (SELECT "projects"."id" FROM "projects" WHERE ("projects"."deleted_at" IS NULL) AND "projects"."creator_id" = 9) OR "projects"."id" IN (SELE!
 CT "permissions"."project_id" FROM "permissions" WHERE "permissions"."user_id" = 9 AND "permissions"."level" IN ('reader', 'writer', 'owner'))) OR "audio_events"."id" IN (SELECT "audio_events"."id" FROM "audio_events" WHERE ("audio_events"."deleted_at" IS NULL) AND "audio_events"."is_reference" = 't')) AND "audio_events"."is_reference" = 't'  ORDER BY "audio_events"."duration_seconds" DESC LIMIT 10 OFFSET 0
  lib/modules/api/controller_helper.rb:105:in `respond_filter'

@cofiem cofiem closed this as completed in 5f9584b Jun 29, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants