aboutsummaryrefslogtreecommitdiffstats
path: root/app/models/referential.rb
diff options
context:
space:
mode:
authorTeddy Wing2018-02-22 17:05:36 +0100
committerTeddy Wing2018-02-22 17:11:48 +0100
commitea84163e3cfcb721c184772721373ccbbd6b337a (patch)
tree10c67196d2a6d9ed393f9bdbb1f0ff7620ab627b /app/models/referential.rb
parent435b6682d70e637e7911f19e94977d1146a63b1b (diff)
downloadchouette-core-ea84163e3cfcb721c184772721373ccbbd6b337a.tar.bz2
VehicleJourney#in_purchase_window: Use table namespace in query
We were getting this errorwhen filtering by purchase window on the `ReferentialVehicleJourneys#index` page. An example of a filter query that triggered the error: http://stif-boiv.dev:3000/referentials/4/vehicle_journeys?utf8=✓&q[published_journey_name_or_objectid_cont]=&q[company_id_eq_any][]=&q[route_line_id_eq]=&q[published_journey_name_gteq]=&q[published_journey_name_lteq]=&q[stop_area_ids][]=&q[purchase_window][start_date(3i)]=12&q[purchase_window][start_date(2i)]=1&q[purchase_window][start_date(1i)]=2018&q[purchase_window][end_date(3i)]=15&q[purchase_window][end_date(2i)]=1&q[purchase_window][end_date(1i)]=2019&q[time_table][start_date(3i)]=&q[time_table][start_date(2i)]=&q[time_table][start_date(1i)]=&q[time_table][end_date(3i)]=&q[time_table][end_date(2i)]=&q[time_table][end_date(1i)]=&commit=Filtrer ActiveRecord::StatementInvalid in ReferentialVehicleJourneys#index Showing stif-boiv/app/views/referential_vehicle_journeys/_filters.html.slim where line #24 raised: PG::AmbiguousColumn: ERROR: column reference "id" is ambiguous LINE 1: ...RE "vehicle_journeys"."journey_category" = 0 AND (id IN (SEL... ^ : SELECT "public"."lines".* FROM "public"."lines" WHERE (id IN (SELECT routes.line_id FROM "vehicle_journeys" INNER JOIN "routes" ON "routes"."id" = "vehicle_journeys"."route_id" WHERE "vehicle_journeys"."journey_category" = 0 AND (id IN (SELECT DISTINCT vehicle_journeys.id FROM "purchase_windows" INNER JOIN "purchase_windows_vehicle_journeys" ON "purchase_windows_vehicle_journeys"."purchase_window_id" = "purchase_windows"."id" INNER JOIN "vehicle_journeys" ON "vehicle_journeys"."id" = "purchase_windows_vehicle_journeys"."vehicle_journey_id" AND "vehicle_journeys"."journey_category" = 0 WHERE (daterange('2018-01-12', '2019-01-16') && any (date_ranges)))) ORDER BY "vehicle_journeys"."published_journey_name" ASC LIMIT 10 OFFSET 0)) Extracted source (around line #24): class: 'control-label' .form-inline.filter_menu = f.input :route_line_id_eq, as: :select, include_blank: t(".all"), collection: @vehicle_journeys.lines, Trace of template inclusion: app/views/referential_vehicle_journeys/index.html.slim We're trying to match `VehicleJourney`s here, so qualify the `id` column with the table name to fix the error. Refs #5943
Diffstat (limited to 'app/models/referential.rb')
0 files changed, 0 insertions, 0 deletions