Skip to content

Allow GSI in TableConfig without capacity settings #141

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
Unreleased Changes
------------------

* Issue - Allow `global_secondary_index` to be defined in `TableConfig` without
supplying capacity settings. (#140)

2.13.1 (2024-07-18)
------------------

Expand Down
2 changes: 1 addition & 1 deletion lib/aws-record/record/table_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ def write_capacity_units(units)
# @api private
def global_secondary_index(name, &block)
gsi = GlobalSecondaryIndex.new
gsi.instance_eval(&block)
gsi.instance_eval(&block) if block_given?
@global_secondary_indexes[name] = gsi
end

Expand Down
28 changes: 19 additions & 9 deletions spec/aws-record/record/table_config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,26 @@ def configure_test_client(client)
end
end

it 'accepts global secondary indexes in the definition' do
TableConfig.define do |t|
t.model_class(TestModelWithGsi)
t.read_capacity_units(2)
t.write_capacity_units(2)
t.global_secondary_index(:gsi) do |i|
i.read_capacity_units(1)
i.write_capacity_units(1)
context 'global secondary indexes' do
it 'accepts with capacity settings defined' do
TableConfig.define do |t|
t.model_class(TestModelWithGsi)
t.read_capacity_units(2)
t.write_capacity_units(2)
t.global_secondary_index(:gsi) do |i|
i.read_capacity_units(1)
i.write_capacity_units(1)
end
t.client_options(stub_responses: true)
end
end

it 'accepts without capacity settings defined' do
TableConfig.define do |t|
t.model_class(TestModelWithGsi)
t.global_secondary_index(:gsi)
t.client_options(stub_responses: true)
end
t.client_options(stub_responses: true)
end
end

Expand Down
Loading