aboutsummaryrefslogtreecommitdiffstats
path: root/app/models/chouette/line.rb
diff options
context:
space:
mode:
authorTeddy Wing2018-03-07 11:37:30 +0100
committerJohan Van Ryseghem2018-03-07 13:19:41 +0100
commit186662b9ef2e996ec649298debb3df352f9849bf (patch)
treed342dd7d774a359a2a699beb3f683239a01ae6b2 /app/models/chouette/line.rb
parent7034809b7ce458c32597026d69afdf5c37db6bd4 (diff)
downloadchouette-core-186662b9ef2e996ec649298debb3df352f9849bf.tar.bz2
Chouette::Line#by_name: Use `LEFT OUTER JOIN` on "companies"
Thanks to Johan for helping me with this. He correctly remarked that what I had before will do an `INNER JOIN`, which ends up excluding lines that don't have an associated company. I didn't really think about the data, and didn't realise we had lines without a company. Big thanks to Johan for seeing that I needed to add `public.` to qualify the `companies` table in order for the join to work. Otherwise it doesn't work correctly and we can't filter by company name. Refs #5889
Diffstat (limited to 'app/models/chouette/line.rb')
-rw-r--r--app/models/chouette/line.rb2
1 files changed, 1 insertions, 1 deletions
diff --git a/app/models/chouette/line.rb b/app/models/chouette/line.rb
index f65d313b3..2f83fc5bf 100644
--- a/app/models/chouette/line.rb
+++ b/app/models/chouette/line.rb
@@ -44,7 +44,7 @@ module Chouette
t: "%#{text.downcase}%") }
scope :by_name, ->(name) {
- joins(:company)
+ joins('LEFT OUTER JOIN public.companies ON companies.id = lines.company_id')
.where('
lines.number LIKE :q
OR lines.name LIKE :q