Skip to content

Commit

Permalink
Merge pull request #8 from Sage/query_with_eq_fails
Browse files Browse the repository at this point in the history
Query with Eq Fails
  • Loading branch information
vaughanbrittonsage authored Aug 18, 2017
2 parents 59d30ec + ac49004 commit 1e35e62
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/dynamodb_framework/dynamodb_query.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ def method_missing(name)
end

def eq(value)
condition(expression: '==', value: value)
condition(expression: '=', value: value)
self
end

def not_eq(value)
condition(expression: '!=', value: value)
condition(expression: '<>', value: value)
self
end

Expand Down
2 changes: 1 addition & 1 deletion lib/dynamodb_framework/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module DynamoDbFramework
VERSION = '1.5.1'
VERSION = '1.5.2'
end
12 changes: 12 additions & 0 deletions spec/dynamodb_query_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,18 @@ def create_query_item(name, number)
expect(count).to eq 4
end
end
context 'when using eq' do
it 'should return the right values' do
results = ExampleTable2.query(partition: 'name 1').number.eq(1).execute(store: store)
expect(results.length).to eq(1)
end
end
context 'when using not_eq' do
it 'should return the right values' do
results = ExampleTable2.query(partition: 'name 1').number.not_eq(1).execute(store: store)
expect(results.length).to eq(3)
end
end
end

end
1 change: 1 addition & 0 deletions spec/dynamodb_table_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ def create_query_item(name, number)
.execute(store: store)
expect(results.length).to eq 4
end

context 'when limit is specified' do
it 'should return the expected items' do
results = ExampleTable2.query(partition: 'name 1')
Expand Down

0 comments on commit 1e35e62

Please sign in to comment.