dynamini 2.1.1 → 2.1.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 375aefa0350dd33fcd702b47d06896ffad78b986
4
- data.tar.gz: b8159e0743eb229c6c93e5ea27e2cb45ef3147c0
3
+ metadata.gz: f7b0c9b660d05e9791a38a79ee09b2847d9dff48
4
+ data.tar.gz: 5262cf9c63c4a2152a1182c2037712855e35ffda
5
5
  SHA512:
6
- metadata.gz: b3c7ac2347cafdcdad0e67d54c3cfaac1fbc94a34324b9dc43e9dcc83831e13b2c0423af95f01c434db677600f5ecb81547968845efed78288243675c24193ab
7
- data.tar.gz: 4bba1206df754d28ceddae3e7fe09214561a6368bd52c07d21da40628c36c9b90732a4bdc6c2b5c3836451c11f03abe1d7965f9f10f71ad7ea01d0b3bc91e5b9
6
+ metadata.gz: ad4de22dd7dce271017ee4badda3ce8babc3bb3b97592f88bb03c2485af77fc74a621e0bea47c7f9c610d7e39c2b7ac939fdbdf4b67672bccc5cabe20a769952
7
+ data.tar.gz: 06646d44a9ae44ae92560f4800ce3a5c6421405b915ab3dbcce0e721d246f3b1eaab59ac7122307025ee2b09246ee27050dea5ea9f2961eb09645f9daaf54e88
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- dynamini (2.1.1)
4
+ dynamini (2.1.2)
5
5
  activemodel (>= 3, < 5.0)
6
6
  aws-sdk (~> 2)
7
7
 
data/README.md CHANGED
@@ -105,7 +105,14 @@ The magic fields updated_at and created_at are handled as :time by default.
105
105
 
106
106
  Dynamini includes a query function that's much more narrow than ActiveRecord's where function. It's designed to retrieve a selection of records that belong to a given hash key but have various range key values. To use .query, your table needs to be configured with a range key, and you need to :handle that range field as a fundamentally numeric type - integer, float, date, or time. If your range key field isn't numeric, you won't be able to .query, but you'll still be able to .find your records normally.
107
107
 
108
- Query takes three arguments; a mandatory :hash_key, an optional :start, and an optional :end. Here's how you'd use it to find daily temperature data for a given city, selecting for specific date ranges:
108
+ Query takes the following arguments:
109
+ * :hash_key (required)
110
+ * :start (optional)
111
+ * :end (optional)
112
+ * :limit (optional)
113
+ * :scan_index_forward (optional - set to false to sort by range key in desc order)
114
+
115
+ Here's how you'd use it to find daily temperature data for a given city, selecting for specific date ranges:
109
116
 
110
117
  ```ruby
111
118
  class DailyWeather < Dynamini::Base
@@ -138,6 +145,12 @@ DailyWeather.query(hash_key: "Toronto", end: Date.new(2015,10,08))
138
145
 
139
146
  DailyWeather.query(hash_key: "Toronto", start: Date.new(2015,10,08), end: Date.new(2015,10,09))
140
147
  > [A, B]
148
+
149
+ DailyWeather.query(hash_key: "Toronto", limit: 2)
150
+ > [A, B]
151
+
152
+ DailyWeather.query(hash_key: "Toronto", scan_index_forward: false)
153
+ > [C, B, A]
141
154
  ```
142
155
 
143
156
  ## Array Support
data/dynamini.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'dynamini'
3
- s.version = '2.1.1'
3
+ s.version = '2.1.2'
4
4
  s.summary = 'DynamoDB interface'
5
5
  s.description = 'Lightweight DynamoDB interface gem designed as
6
6
  a drop-in replacement for ActiveRecord.
@@ -103,7 +103,7 @@ module Dynamini
103
103
  end
104
104
 
105
105
  tokens = args[:key_condition_expression].split(/\s+/)
106
- hash_key = tokens[2]
106
+ hash_key = args[:expression_attribute_values][":h"].is_a?(Integer) ? tokens[2].to_i : tokens[2]
107
107
  case tokens[5]
108
108
  when ">="
109
109
  start_val = tokens[6]
@@ -106,6 +106,23 @@ describe Dynamini::TestClient do
106
106
  test_client.update_item(table_name: table_name, key: {hash_key_field: 'foo', range_key_field: i + 1}, attribute_updates: {abc: {value: 'abc', action: 'PUT'}})
107
107
  end
108
108
  end
109
+
110
+ context 'on table with integer hash_key' do
111
+ it 'should return items correctly' do
112
+ test_client.update_item(table_name: 'integer_table', key: {hash_key_field: 1, range_key_field: 1}, attribute_updates: {abc: {value: 'abc', action: 'PUT'}})
113
+ response = test_client.query(
114
+ table_name: 'integer_table',
115
+ key_condition_expression: "hash_key_field = :h",
116
+ expression_attribute_values: {
117
+ ":h" => 1
118
+ }
119
+ )
120
+ expect(response.items.length).to eq(1)
121
+ expect(response.items.first[:range_key_field]).to eq(1)
122
+ expect(response.items.first[:hash_key_field]).to eq(1)
123
+ end
124
+ end
125
+
109
126
  context 'with LE operator' do
110
127
  it 'should return all items with range key less than or equal to the provided value' do
111
128
  response = test_client.query(
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dynamini
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.1
4
+ version: 2.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Greg Ward
@@ -15,7 +15,7 @@ authors:
15
15
  autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
- date: 2016-02-29 00:00:00.000000000 Z
18
+ date: 2016-03-03 00:00:00.000000000 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: activemodel