aub-record_filter 0.9.8 → 0.9.9
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +5 -0
- data/VERSION.yml +1 -1
- data/lib/record_filter/filter.rb +10 -1
- data/record_filter.gemspec +2 -2
- data/spec/select_spec.rb +11 -0
- data/spec/test.db +0 -0
- metadata +2 -2
data/CHANGELOG
CHANGED
data/VERSION.yml
CHANGED
data/lib/record_filter/filter.rb
CHANGED
@@ -70,7 +70,16 @@ module RecordFilter
|
|
70
70
|
end
|
71
71
|
|
72
72
|
def do_with_scope(count_query=false, &block) # :nodoc:
|
73
|
-
|
73
|
+
options = proxy_options(count_query)
|
74
|
+
@clazz.send(:with_scope, { :find => options, :create => options }, :reverse_merge) do
|
75
|
+
scoped_methods = @current_scoped_methods
|
76
|
+
# This is annoying, but we want the select statement from the proxy options to win if
|
77
|
+
# it is more specific than one in the current options from DISTINCT.
|
78
|
+
if scoped_methods && scoped_methods[:find] && scoped_methods[:find][:select] && options[:select] &&
|
79
|
+
options[:select] == "DISTINCT #{scoped_methods[:find][:select]}"
|
80
|
+
scoped_methods[:find] = scoped_methods[:find].dup
|
81
|
+
scoped_methods[:find].delete(:select)
|
82
|
+
end
|
74
83
|
if @current_scoped_methods
|
75
84
|
@clazz.send(:with_scope, @current_scoped_methods) do
|
76
85
|
block.call
|
data/record_filter.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{record_filter}
|
5
|
-
s.version = "0.9.
|
5
|
+
s.version = "0.9.9"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Aubrey Holland", "Mat Brown"]
|
9
|
-
s.date = %q{2009-06-
|
9
|
+
s.date = %q{2009-06-22}
|
10
10
|
s.description = %q{RecordFilter is a Pure-ruby criteria API for building complex queries in ActiveRecord. It supports queries that are built on the fly as well as named filters that can be added to objects and chained to create complex queries. It also gets rid of the nasty hard-coded SQL that shows up in most ActiveRecord code with a clean API that makes queries simple and intuitive to build.}
|
11
11
|
s.email = %q{aubreyholland@gmail.com}
|
12
12
|
s.extra_rdoc_files = [
|
data/spec/select_spec.rb
CHANGED
@@ -64,4 +64,15 @@ describe 'with custom selects for cases where DISTINCT is required' do
|
|
64
64
|
Blog.last_find[:select].should == %q(DISTINCT "blogs".*)
|
65
65
|
end
|
66
66
|
end
|
67
|
+
|
68
|
+
describe 'using the distinct method when chaining named scopes with joins that do not need it' do
|
69
|
+
it 'should add distinct' do
|
70
|
+
Comment.named_filter(:dirty) do
|
71
|
+
with(:offensive, true)
|
72
|
+
distinct
|
73
|
+
end
|
74
|
+
Blog.first.comments.dirty.inspect
|
75
|
+
Comment.last_find[:select].should == %q(DISTINCT "comments".*)
|
76
|
+
end
|
77
|
+
end
|
67
78
|
end
|
data/spec/test.db
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aub-record_filter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aubrey Holland
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2009-06-
|
13
|
+
date: 2009-06-22 00:00:00 -07:00
|
14
14
|
default_executable:
|
15
15
|
dependencies: []
|
16
16
|
|