Skip to content

Commit 1ed74bf

Browse files
committed
Add "EmptyQuery" test
1 parent 50a824f commit 1ed74bf

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

lib/sqlrunner_test.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,26 @@ func TestDbRunnerNoScientificNotation(t *testing.T) {
263263
assert.Equal(t, "1145141919.81", result.Rows[1][0])
264264
}
265265

266+
func TestDbRunnerEmptyQuery(t *testing.T) {
267+
t.Parallel()
268+
269+
runner, err := sqlrunner.NewSQLRunner(`
270+
CREATE TABLE emptytest (
271+
value TEXT
272+
);
273+
274+
INSERT INTO emptytest (value) VALUES ('hello');
275+
INSERT INTO emptytest (value) VALUES ('world');
276+
`)
277+
require.NoError(t, err)
278+
279+
result, err := runner.Query(context.TODO(), "")
280+
require.NoError(t, err)
281+
282+
assert.Len(t, result.Rows, 0)
283+
assert.Len(t, result.Columns, 0)
284+
}
285+
266286
func BenchmarkDbrunner(b *testing.B) {
267287
b.ReportAllocs()
268288

0 commit comments

Comments
 (0)