Remove comments from the query before checking for restricted keywords
This commit is contained in:
@@ -440,16 +440,22 @@ func testReadOnlyMode(t *testing.T) {
|
||||
err := client.SetReadOnlyMode()
|
||||
assert.NoError(t, err)
|
||||
|
||||
_, err = client.Query("CREATE TABLE foobar(id integer);")
|
||||
_, err = client.Query("\nCREATE TABLE foobar(id integer);\n")
|
||||
assert.NotNil(t, err)
|
||||
assert.Error(t, err, "query contains keywords not allowed in read-only mode")
|
||||
|
||||
// Turn off guard
|
||||
client.db.Exec("SET default_transaction_read_only=off;")
|
||||
|
||||
_, err = client.Query("CREATE TABLE foobar(id integer);")
|
||||
_, err = client.Query("\nCREATE TABLE foobar(id integer);\n")
|
||||
assert.NotNil(t, err)
|
||||
assert.Contains(t, err.Error(), "query contains keywords not allowed in read-only mode")
|
||||
|
||||
_, err = client.Query("-- CREATE TABLE foobar(id integer);\nSELECT 'foo';")
|
||||
assert.NoError(t, err)
|
||||
|
||||
_, err = client.Query("/* CREATE TABLE foobar(id integer); */ SELECT 'foo';")
|
||||
assert.NoError(t, err)
|
||||
}
|
||||
|
||||
func TestAll(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user