]> git.openstreetmap.org Git - rails.git/blobdiff - app/models/relation.rb
be a bit smarter about enlarging the bbox (note to self: must remember to put this...
[rails.git] / app / models / relation.rb
index 5d7092908baa302c868cf8725378fb7d43763355..c8516b58a3441c9f3b0ec38262d7628c8888d00f 100644 (file)
@@ -106,20 +106,32 @@ class Relation < ActiveRecord::Base
   end 
 
   def self.find_for_nodes(ids, options = {})
-    self.with_scope(:find => { :joins => "INNER JOIN current_relation_members ON current_relation_members.id = current_relations.id", :conditions => "current_relation_members.member_type = 'node' AND current_relation_members.member_id IN (#{ids.join(',')})" }) do
-      return self.find(:all, options)
+    if ids.empty?
+      return []
+    else
+      self.with_scope(:find => { :joins => "INNER JOIN current_relation_members ON current_relation_members.id = current_relations.id", :conditions => "current_relation_members.member_type = 'node' AND current_relation_members.member_id IN (#{ids.join(',')})" }) do
+        return self.find(:all, options)
+      end
     end
   end
 
   def self.find_for_ways(ids, options = {})
-    self.with_scope(:find => { :joins => "INNER JOIN current_relation_members ON current_relation_members.id = current_relations.id", :conditions => "current_relation_members.member_type = 'way' AND current_relation_members.member_id IN (#{ids.join(',')})" }) do
-      return self.find(:all, options)
+    if ids.empty?
+      return []
+    else
+      self.with_scope(:find => { :joins => "INNER JOIN current_relation_members ON current_relation_members.id = current_relations.id", :conditions => "current_relation_members.member_type = 'way' AND current_relation_members.member_id IN (#{ids.join(',')})" }) do
+        return self.find(:all, options)
+      end
     end
   end
 
   def self.find_for_relations(ids, options = {})
-    self.with_scope(:find => { :joins => "INNER JOIN current_relation_members ON current_relation_members.id = current_relations.id", :conditions => "current_relation_members.member_type = 'relation' AND current_relation_members.member_id IN (#{ids.join(',')})" }) do
-      return self.find(:all, options)
+    if ids.empty?
+      return []
+    else
+      self.with_scope(:find => { :joins => "INNER JOIN current_relation_members ON current_relation_members.id = current_relations.id", :conditions => "current_relation_members.member_type = 'relation' AND current_relation_members.member_id IN (#{ids.join(',')})" }) do
+        return self.find(:all, options)
+      end
     end
   end