rocking_chair 0.0.8 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -29,6 +29,7 @@ module RockingChair
29
29
  'reduce' => false,
30
30
  'limit' => nil,
31
31
  'key' => nil,
32
+ 'filter_by_key' => false,
32
33
  'descending' => false,
33
34
  'include_docs' => false,
34
35
  'without_deleted' => false,
@@ -37,9 +38,14 @@ module RockingChair
37
38
  'endkey_docid' => nil,
38
39
  'startkey_docid' => nil
39
40
  }.update(options)
40
- @options.assert_valid_keys('reduce', 'limit', 'key', 'descending', 'include_docs', 'without_deleted', 'endkey', 'startkey', 'endkey_docid', 'startkey_docid')
41
+ @options.assert_valid_keys('reduce', 'limit', 'key', 'descending', 'include_docs', 'without_deleted', 'endkey', 'startkey', 'endkey_docid', 'startkey_docid', 'filter_by_key')
41
42
  RockingChair::Helper.jsonfy_options(@options, 'key', 'startkey', 'endkey', 'startkey_docid', 'endkey_docid')
42
43
 
44
+ if options.has_key?('key')
45
+ # still filter even if key is nil
46
+ @options['filter_by_key'] = true
47
+ end
48
+
43
49
  normalize_view_name
44
50
  normalize_descending_options
45
51
  end
@@ -151,7 +157,7 @@ module RockingChair
151
157
  def filter_items_by_key(attributes)
152
158
  if options['startkey']
153
159
  filter_items_by_range(attributes)
154
- elsif options['key']
160
+ elsif options['filter_by_key'] || options['key']
155
161
  filter_items_by_exact_key(attributes)
156
162
  end
157
163
  end
@@ -202,6 +202,11 @@ class SimplyStoredTest < Test::Unit::TestCase
202
202
  assert_equal 2, Project.count_by_title(nil)
203
203
  assert_equal 1, Project.count_by_manager_id(12)
204
204
  assert_equal 1, Project.count_by_manager_id_and_title(12, nil)
205
+
206
+ Project.create(:title => 'Hi There')
207
+
208
+ assert_equal 3, Project.count
209
+ assert_equal 2, Project.count_by_title(nil)
205
210
  end
206
211
 
207
212
  context "with deleted" do
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
+ - 1
7
8
  - 0
8
- - 8
9
- version: 0.0.8
9
+ version: 0.1.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Jonathan Weiss