Skip to content

Commit

Permalink
Merge pull request #1710 from rqlite/blob-query
Browse files Browse the repository at this point in the history
Unit test querying by hex value
  • Loading branch information
otoolep committed Feb 28, 2024
2 parents 112189f + 4d681e4 commit bbfd606
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -2,6 +2,7 @@
### Implementation changes and bug fixes
- [PR #1708](https://github.com/rqlite/rqlite/pull/1708): Some more HTTP-level unit tests.
- [PR #1709](https://github.com/rqlite/rqlite/pull/1709): Unit test SQLite keyword `STRICT`.
- [PR #1710](https://github.com/rqlite/rqlite/pull/1710): Unit test querying a hex value. See issue [#1532](https://github.com/rqlite/rqlite/issues/1532).

## 8.22.1 (February 27th 2024)
### Implementation changes and bug fixes
Expand Down
19 changes: 19 additions & 0 deletions db/db_common_test.go
Expand Up @@ -213,6 +213,24 @@ func testBLOB(t *testing.T, db *DB) {
}
}

func testHexQuery(t *testing.T, db *DB) {
_, err := db.ExecuteStringStmt("CREATE TABLE foo(blob_column BLOB)")
if err != nil {
t.Fatalf("failed to create table: %s", err.Error())
}
_, err = db.ExecuteStringStmt(`INSERT INTO foo(blob_column) VALUES (x'53514C697465')`)
if err != nil {
t.Fatalf("failed to insert record: %s", err.Error())
}
r, err := db.QueryStringStmt("SELECT x'53514C697465' from foo")
if err != nil {
t.Fatalf("failed to query master table: %s", err.Error())
}
if exp, got := `[{"columns":["x'53514C697465'"],"types":["text"],"values":[["SQLite"]]}]`, asJSON(r); exp != got {
t.Fatalf("unexpected results for query, expected %s, got %s", exp, got)
}
}

func testSTRICT(t *testing.T, db *DB) {
_, err := db.ExecuteStringStmt("CREATE TABLE foo (name TEXT, data BLOB) STRICT")
if err != nil {
Expand Down Expand Up @@ -1636,6 +1654,7 @@ func Test_DatabaseCommonOperations(t *testing.T) {
{"NotNULLField", testNotNULLField},
{"RandomBlob", testSQLiteRandomBlob},
{"BasicBLOB", testBLOB},
{"HexQuery", testHexQuery},
{"Strict", testSTRICT},
{"EmptyStatements", testEmptyStatements},
{"SimpleSingleStatements", testSimpleSingleStatements},
Expand Down
4 changes: 2 additions & 2 deletions store/gzip/compressor_test.go
Expand Up @@ -163,9 +163,9 @@ func Test_Compressor_CompressFile(t *testing.T) {
}

func Test_Compressor_CompressLargeFile(t *testing.T) {
mb128 := int64(128*1024*1024) + 13
mb64 := int64(64*1024*1024) + 13
srcFD := mustOpenTempFile(t)
_, err := io.CopyN(srcFD, io.LimitReader(rand.New(rand.NewSource(0)), mb128), mb128)
_, err := io.CopyN(srcFD, io.LimitReader(rand.New(rand.NewSource(0)), mb64), mb64)
if err != nil {
t.Fatalf("Failed to write random data to source file: %v", err)
}
Expand Down

0 comments on commit bbfd606

Please sign in to comment.