comparison .svn/pristine/e8/e8a36b01afd2a5cff14efeb28594cc967d6eb478.svn-base @ 1295:622f24f53b42 redmine-2.3

Update to Redmine SVN revision 11972 on 2.3-stable branch
author Chris Cannam
date Fri, 14 Jun 2013 09:02:21 +0100
parents
children
comparison
equal deleted inserted replaced
1294:3e4c3460b6ca 1295:622f24f53b42
1 # Redmine - project management software
2 # Copyright (C) 2006-2012 Jean-Philippe Lang
3 #
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
18 module ActiveRecord
19 module FinderMethods
20 def find_ids(*args)
21 find_ids_with_associations
22 end
23
24 private
25
26 def find_ids_with_associations
27 join_dependency = construct_join_dependency_for_association_find
28 relation = construct_relation_for_association_find_ids(join_dependency)
29 rows = connection.select_all(relation, 'SQL', relation.bind_values)
30 rows.map {|row| row["id"].to_i}
31 rescue ThrowResult
32 []
33 end
34
35 def construct_relation_for_association_find_ids(join_dependency)
36 relation = except(:includes, :eager_load, :preload, :select).select("#{table_name}.id")
37 apply_join_dependency(relation, join_dependency)
38 end
39 end
40 end