Adds a tricky user to test
This allows us to test aclitem encoding with tricky SQL identifiers. The user actually has to exist, or the aclitem will be incorrect.
This commit is contained in:
@@ -36,6 +36,7 @@ before_script:
|
||||
- psql -U postgres -c "create user pgx_ssl SUPERUSER PASSWORD 'secret'"
|
||||
- psql -U postgres -c "create user pgx_md5 SUPERUSER PASSWORD 'secret'"
|
||||
- psql -U postgres -c "create user pgx_pw SUPERUSER PASSWORD 'secret'"
|
||||
- psql -U postgres -c "create user \" tricky, ' } \"\" \\ test user \" superuser password 'secret'"
|
||||
|
||||
install:
|
||||
- go get -u github.com/shopspring/decimal
|
||||
|
||||
@@ -66,6 +66,7 @@ To setup the normal test environment, first install these dependencies:
|
||||
Then run the following SQL:
|
||||
|
||||
create user pgx_md5 password 'secret';
|
||||
create user " tricky, ' } "" \ test user " superuser password 'secret';
|
||||
create database pgx_test;
|
||||
|
||||
Connect to database pgx_test and run:
|
||||
|
||||
@@ -265,7 +265,18 @@ func (n NullString) Encode(w *WriteBuf, oid Oid) error {
|
||||
return encodeString(w, oid, n.String)
|
||||
}
|
||||
|
||||
// AclItem is used for PostgreSQL's aclitem data type.
|
||||
// AclItem is used for PostgreSQL's aclitem data type. A sample aclitem
|
||||
// might look like this:
|
||||
//
|
||||
// postgres=arwdDxt/postgres
|
||||
//
|
||||
// Note, however, that because the user/role name part of an aclitem is
|
||||
// an identifier, it follows all the usual formatting rules for SQL
|
||||
// identifiers: if it contains spaces and other special characters,
|
||||
// it should appear in double-quotes:
|
||||
//
|
||||
// postgres=arwdDxt/"role with spaces"
|
||||
//
|
||||
type AclItem string
|
||||
|
||||
// NullAclItem represents a pgx.AclItem that may be null. NullAclItem implements the
|
||||
|
||||
@@ -600,6 +600,7 @@ func TestNullX(t *testing.T) {
|
||||
{"select $1::\"char\"", []interface{}{pgx.NullChar{Char: 255, Valid: true}}, []interface{}{&actual.c}, allTypes{c: pgx.NullChar{Char: 255, Valid: true}}},
|
||||
{"select $1::name", []interface{}{pgx.NullName{Name: "foo", Valid: true}}, []interface{}{&actual.n}, allTypes{n: pgx.NullName{Name: "foo", Valid: true}}},
|
||||
{"select $1::name", []interface{}{pgx.NullName{Name: "foo", Valid: false}}, []interface{}{&actual.n}, allTypes{n: pgx.NullName{Name: "", Valid: false}}},
|
||||
{"select $1::aclitem", []interface{}{pgx.NullAclItem{AclItem: `postgres=arwdDxt/" tricky, ' } "" \ test user "`, Valid: true}}, []interface{}{&actual.a}, allTypes{a: pgx.NullAclItem{AclItem: `postgres=arwdDxt/" tricky, ' } "" \ test user "`, Valid: true}}},
|
||||
{"select $1::aclitem", []interface{}{pgx.NullAclItem{AclItem: "postgres=arwdDxt/postgres", Valid: true}}, []interface{}{&actual.a}, allTypes{a: pgx.NullAclItem{AclItem: "postgres=arwdDxt/postgres", Valid: true}}},
|
||||
{"select $1::aclitem", []interface{}{pgx.NullAclItem{AclItem: "postgres=arwdDxt/postgres", Valid: false}}, []interface{}{&actual.a}, allTypes{a: pgx.NullAclItem{AclItem: "", Valid: false}}},
|
||||
{"select $1::cid", []interface{}{pgx.NullCid{Cid: 1, Valid: true}}, []interface{}{&actual.cid}, allTypes{cid: pgx.NullCid{Cid: 1, Valid: true}}},
|
||||
|
||||
Reference in New Issue
Block a user