Skip to content

Commit 37698a7

Browse files
committed
Refactor Airline model N1QL query to use dynamic values for destination airport
1 parent 4b7e73d commit 37698a7

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

app/models/airline.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@ class Airline < CouchbaseOrm::Base
2525
n1ql :to_airport, query_fn: proc { |bucket, values, options|
2626
# limit = options[:limit] || 10
2727
# offset = options[:offset] || 0
28-
cluster.query("SELECT raw META(air).id FROM (SELECT DISTINCT META(airline).id AS airlineId FROM `#{bucket.name}` AS route JOIN `#{bucket.name}` AS airline ON route.airlineid = META(airline).id WHERE route.destinationairport = 'JFK') AS subquery JOIN `#{bucket.name}` AS air ON META(air).id = subquery.airlineId LIMIT 10 OFFSET 0", options)
28+
cluster.query("SELECT raw META(air).id FROM (SELECT DISTINCT META(airline).id AS airlineId FROM `#{bucket.name}` AS route JOIN `#{bucket.name}` AS airline ON route.airlineid = META(airline).id WHERE route.destinationairport = #{quote(values[0])}) AS subquery JOIN `#{bucket.name}` AS air ON META(air).id = subquery.airlineId LIMIT 10 OFFSET 0", options)
2929
}
3030
end

0 commit comments

Comments
 (0)