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 @@ -626,7 +626,7 @@ public byte[] getBytes(int columnIndex) throws SQLException {
case Value.Blob b -> b.bytes();
case Value.Text t -> t.value().getBytes(java.nio.charset.StandardCharsets.UTF_8);
case Value.Integer i -> Long.toString(i.value()).getBytes(java.nio.charset.StandardCharsets.UTF_8);
case Value.Float f -> Double.toString(f.value()).getBytes(java.nio.charset.StandardCharsets.UTF_8);
case Value.Float f -> sqliteRealText(f.value()).getBytes(java.nio.charset.StandardCharsets.UTF_8);
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import org.junit.jupiter.params.provider.MethodSource;

import java.math.BigDecimal;
import java.nio.charset.StandardCharsets;
import java.sql.SQLException;
import java.util.List;
import java.util.stream.Stream;
Expand Down Expand Up @@ -95,6 +96,17 @@ void realTextUsesFixedNotationBetweenNegativeFourAndSixteen(String sqliteValue,
assertThat(rs.getString(1)).isEqualTo(expected);
}

@ParameterizedTest(name = "{0} -> {1}")
@MethodSource("canonicalText")
void realBytesMatchCanonicalText(String sqliteValue, String expected) throws SQLException {
LibsqlResultSet rs = resultSet(new Value.Float(Double.parseDouble(sqliteValue)));
assertThat(rs.next()).isTrue();

assertThat(rs.getBytes(1)).isEqualTo(expected.getBytes(StandardCharsets.UTF_8));
assertThat(rs.getBytes(1))
.isEqualTo(rs.getString(1).getBytes(StandardCharsets.UTF_8));
}

private static LibsqlResultSet resultSet(Value... values) {
List<Col> cols = Stream.generate(() -> new Col("c", null)).limit(values.length).toList();
StmtResult result = new StmtResult(cols, List.of(new Row(List.of(values))), 1, null);
Expand Down
Loading