Use correct bitfield offset for INCRBY using Lettuce.
Closes #2903 Original pull request: #2901
This commit is contained in:
committed by
Mark Paluch
parent
bdec99633b
commit
a77df79f44
@@ -79,6 +79,7 @@ import org.springframework.util.StringUtils;
|
|||||||
* @author Chris Bono
|
* @author Chris Bono
|
||||||
* @author Vikas Garg
|
* @author Vikas Garg
|
||||||
* @author John Blum
|
* @author John Blum
|
||||||
|
* @author Roman Osadchuk
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("ConstantConditions")
|
@SuppressWarnings("ConstantConditions")
|
||||||
public abstract class LettuceConverters extends Converters {
|
public abstract class LettuceConverters extends Converters {
|
||||||
@@ -720,7 +721,7 @@ public abstract class LettuceConverters extends Converters {
|
|||||||
args = args.overflow(type);
|
args = args.overflow(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
args = args.incrBy(bitFieldType, (int) subCommand.getOffset().getValue(), ((BitFieldIncrBy) subCommand).getValue());
|
args = args.incrBy(bitFieldType, offset, ((BitFieldIncrBy) subCommand).getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -43,6 +43,8 @@ import org.junit.jupiter.api.BeforeEach;
|
|||||||
import org.junit.jupiter.api.Disabled;
|
import org.junit.jupiter.api.Disabled;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.jupiter.api.condition.DisabledOnOs;
|
import org.junit.jupiter.api.condition.DisabledOnOs;
|
||||||
|
import org.junit.jupiter.params.ParameterizedTest;
|
||||||
|
import org.junit.jupiter.params.provider.ValueSource;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.dao.DataAccessException;
|
import org.springframework.dao.DataAccessException;
|
||||||
import org.springframework.data.domain.Range;
|
import org.springframework.data.domain.Range;
|
||||||
@@ -108,6 +110,7 @@ import org.springframework.data.util.Streamable;
|
|||||||
* @author Andrey Shlykov
|
* @author Andrey Shlykov
|
||||||
* @author Hendrik Duerkop
|
* @author Hendrik Duerkop
|
||||||
* @author Shyngys Sapraliyev
|
* @author Shyngys Sapraliyev
|
||||||
|
* @author Roman Osadchuk
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractConnectionIntegrationTests {
|
public abstract class AbstractConnectionIntegrationTests {
|
||||||
|
|
||||||
@@ -3574,6 +3577,23 @@ public abstract class AbstractConnectionIntegrationTests {
|
|||||||
assertThat(results.get(3)).isNotNull();
|
assertThat(results.get(3)).isNotNull();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ParameterizedTest // DATAREDIS-2903
|
||||||
|
@ValueSource(booleans = {false, true})
|
||||||
|
void bitFieldIncrByAndThenGetShouldWorkCorrectly(boolean isMultipliedByTypeLengthOffset) {
|
||||||
|
var offset = isMultipliedByTypeLengthOffset
|
||||||
|
? BitFieldSubCommands.Offset.offset(300L).multipliedByTypeLength()
|
||||||
|
: BitFieldSubCommands.Offset.offset(400L);
|
||||||
|
|
||||||
|
actual.add(connection.bitfield(KEY_1, create().incr(INT_8).valueAt(offset).by(1L)));
|
||||||
|
actual.add(connection.bitfield(KEY_1, create().get(INT_8).valueAt(offset)));
|
||||||
|
|
||||||
|
List<Object> results = getResults();
|
||||||
|
|
||||||
|
assertThat(results).hasSize(2)
|
||||||
|
// should return same results after INCRBY and GET operations for bitfield with same offset
|
||||||
|
.containsExactly(List.of(1L), List.of(1L));
|
||||||
|
}
|
||||||
|
|
||||||
@Test // DATAREDIS-562
|
@Test // DATAREDIS-562
|
||||||
void bitfieldShouldAllowMultipleSubcommands() {
|
void bitfieldShouldAllowMultipleSubcommands() {
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user