Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ public TypeInfo decodeTypeInfo(ByteBuf byteBuf) {

@Override
public Object decodeValue(ByteBuf byteBuf, TypeInfo typeInfo) {
return new BigDecimal(byteBuf.readIntLE()).divide(new BigDecimal("10000"), 2, RoundingMode.UP);
return new BigDecimal(byteBuf.readIntLE()).divide(new BigDecimal("10000"), 4, RoundingMode.UP);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public void testDecodeAllColumns(TestContext ctx) {
ctx.assertEquals(Buffer.buffer("venice of the north"), row.getValue("test_varbinary_max"));
ctx.assertEquals(Buffer.buffer("paris of the west"), row.getValue("test_image"));
ctx.assertEquals(new BigDecimal("12.3456"), row.getValue("test_money"));
ctx.assertEquals(new BigDecimal("12.34"), row.getValue("test_smallmoney"));
ctx.assertEquals(new BigDecimal("12.3400"), row.getValue("test_smallmoney"));
});
}

Expand Down Expand Up @@ -266,7 +266,7 @@ public void testDecodeMoney(TestContext ctx) {
@Test
public void testDecodeSmallMoney(TestContext ctx) {
testDecodeNotNullValue(ctx, "test_smallmoney", row -> {
checkNumber(row, "test_smallmoney", new BigDecimal("12.34"));
checkNumber(row, "test_smallmoney", new BigDecimal("12.3400"));
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ public void testEncodeMoney(TestContext ctx) {
@Test
public void testEncodeSmallMoney(TestContext ctx) {
testPreparedQueryEncodeGeneric(ctx, "not_nullable_datatype", "test_smallmoney", "€12.12", row -> {
checkNumber(row, "test_smallmoney", new BigDecimal("12.12"));
checkNumber(row, "test_smallmoney", new BigDecimal("12.1200"));
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ public void testEncodeNullMoney(TestContext ctx) {

@Test
public void testEncodeNullSmallMoney(TestContext ctx) {
testEncodeNumber(ctx, "test_smallmoney", new BigDecimal("123.13"));
testEncodeNumber(ctx, "test_smallmoney", new BigDecimal("123.1313"));
}

private void testEncodeBufferValue(TestContext ctx, String columnName, Object value, Object expected) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,31 +23,41 @@ public class MSSQLSmallMoneyDataTypeTest extends MSSQLDataTypeTestBase {

@Test
public void testQueryLargeMoney(TestContext ctx) {
testQueryDecodeGenericWithoutTable(ctx, "test_smallmoney", "SMALLMONEY", "214748.36", new BigDecimal("214748.36"));
testQueryDecodeGenericWithoutTable(ctx, "test_smallmoney", "SMALLMONEY", "214748.36", new BigDecimal("214748.3600"));
}

@Test
public void testQueryMaxMoney(TestContext ctx) {
testQueryDecodeGenericWithoutTable(ctx, "test_smallmoney", "SMALLMONEY", "214748.3647", new BigDecimal("214748.3647"));
}

@Test
public void testQueryLargeNegativeMoney(TestContext ctx) {
testQueryDecodeGenericWithoutTable(ctx, "test_smallmoney", "SMALLMONEY", "-214748.36", new BigDecimal("-214748.36"));
testQueryDecodeGenericWithoutTable(ctx, "test_smallmoney", "SMALLMONEY", "-214748.36", new BigDecimal("-214748.3600"));
}

@Test
public void testQueryMoneyWithCurrency(TestContext ctx) {
testQueryDecodeGenericWithoutTable(ctx, "test_smallmoney", "SMALLMONEY", "$12.34", new BigDecimal("12.34"));
testQueryDecodeGenericWithoutTable(ctx, "test_smallmoney", "SMALLMONEY", "$12.34", new BigDecimal("12.3400"));
}

@Test
public void testPreparedQueryLargeMoney(TestContext ctx) {
testPreparedQueryDecodeGenericWithoutTable(ctx, "test_smallmoney", "SMALLMONEY", "214748.36", new BigDecimal("214748.36"));
testPreparedQueryDecodeGenericWithoutTable(ctx, "test_smallmoney", "SMALLMONEY", "214748.36", new BigDecimal("214748.3600"));
}

@Test
public void testPreparedQueryMaxMoney(TestContext ctx) {
testPreparedQueryDecodeGenericWithoutTable(ctx, "test_smallmoney", "SMALLMONEY", "214748.3647", new BigDecimal("214748.3647"));
}

@Test
public void testPreparedQueryLargeNegativeMoney(TestContext ctx) {
testPreparedQueryDecodeGenericWithoutTable(ctx, "test_smallmoney", "SMALLMONEY", "-214748.36", new BigDecimal("-214748.36"));
testPreparedQueryDecodeGenericWithoutTable(ctx, "test_smallmoney", "SMALLMONEY", "-214748.36", new BigDecimal("-214748.3600"));
}

@Test
public void testPreparedQueryMoneyWithCurrency(TestContext ctx) {
testPreparedQueryDecodeGenericWithoutTable(ctx, "test_smallmoney", "SMALLMONEY", "$12.34", new BigDecimal("12.34"));
testPreparedQueryDecodeGenericWithoutTable(ctx, "test_smallmoney", "SMALLMONEY", "$12.34", new BigDecimal("12.3400"));
}
}
Loading