Skip to content

Commit 83c6abb

Browse files
committed
KeyFieldsDetector. Skip detecting GSI if LSI with matching sort key found
1 parent 634cffb commit 83c6abb

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

lib/dynamoid/criteria/key_fields_detector.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,13 @@ def detect_keys
3939
@range_key = lsi.range_key
4040
@index_name = lsi.name
4141
end
42+
43+
return if @range_key.present?
4244
end
4345

4446
# See if can use any global secondary index
45-
# Chooses the first GSI found that can be utilized for the query
47+
# Chooses the last GSI found that can be utilized for the query
48+
# GSI with range key used in query has higher priority
4649
# But only do so if projects ALL attributes otherwise we won't
4750
# get back full data
4851
@source.global_secondary_indexes.each do |_, gsi|

0 commit comments

Comments
 (0)