2
0

Name PG types as words

Though this doesn't follow Go naming conventions exactly it makes names more
consistent with PostgreSQL and it is easier to read. For example, TIDOID becomes
TidOid. In addition this is one less breaking change in the move to V3.
This commit is contained in:
Jack Christensen
2017-03-11 17:03:23 -06:00
parent 44e206ab5b
commit 666af9ead5
35 changed files with 311 additions and 311 deletions
+37 -37
View File
@@ -7,40 +7,40 @@ import (
"github.com/jackc/pgx/pgtype"
)
func TestACLItemArrayTranscode(t *testing.T) {
func TestAclitemArrayTranscode(t *testing.T) {
testSuccessfulTranscode(t, "aclitem[]", []interface{}{
&pgtype.ACLItemArray{
&pgtype.AclitemArray{
Elements: nil,
Dimensions: nil,
Status: pgtype.Present,
},
&pgtype.ACLItemArray{
Elements: []pgtype.ACLItem{
pgtype.ACLItem{String: "=r/postgres", Status: pgtype.Present},
pgtype.ACLItem{Status: pgtype.Null},
&pgtype.AclitemArray{
Elements: []pgtype.Aclitem{
pgtype.Aclitem{String: "=r/postgres", Status: pgtype.Present},
pgtype.Aclitem{Status: pgtype.Null},
},
Dimensions: []pgtype.ArrayDimension{{Length: 2, LowerBound: 1}},
Status: pgtype.Present,
},
&pgtype.ACLItemArray{Status: pgtype.Null},
&pgtype.ACLItemArray{
Elements: []pgtype.ACLItem{
pgtype.ACLItem{String: "=r/postgres", Status: pgtype.Present},
pgtype.ACLItem{String: "postgres=arwdDxt/postgres", Status: pgtype.Present},
pgtype.ACLItem{String: `postgres=arwdDxt/" tricky, ' } "" \ test user "`, Status: pgtype.Present},
pgtype.ACLItem{String: "=r/postgres", Status: pgtype.Present},
pgtype.ACLItem{Status: pgtype.Null},
pgtype.ACLItem{String: "=r/postgres", Status: pgtype.Present},
&pgtype.AclitemArray{Status: pgtype.Null},
&pgtype.AclitemArray{
Elements: []pgtype.Aclitem{
pgtype.Aclitem{String: "=r/postgres", Status: pgtype.Present},
pgtype.Aclitem{String: "postgres=arwdDxt/postgres", Status: pgtype.Present},
pgtype.Aclitem{String: `postgres=arwdDxt/" tricky, ' } "" \ test user "`, Status: pgtype.Present},
pgtype.Aclitem{String: "=r/postgres", Status: pgtype.Present},
pgtype.Aclitem{Status: pgtype.Null},
pgtype.Aclitem{String: "=r/postgres", Status: pgtype.Present},
},
Dimensions: []pgtype.ArrayDimension{{Length: 3, LowerBound: 1}, {Length: 2, LowerBound: 1}},
Status: pgtype.Present,
},
&pgtype.ACLItemArray{
Elements: []pgtype.ACLItem{
pgtype.ACLItem{String: "=r/postgres", Status: pgtype.Present},
pgtype.ACLItem{String: "postgres=arwdDxt/postgres", Status: pgtype.Present},
pgtype.ACLItem{String: "=r/postgres", Status: pgtype.Present},
pgtype.ACLItem{String: "postgres=arwdDxt/postgres", Status: pgtype.Present},
&pgtype.AclitemArray{
Elements: []pgtype.Aclitem{
pgtype.Aclitem{String: "=r/postgres", Status: pgtype.Present},
pgtype.Aclitem{String: "postgres=arwdDxt/postgres", Status: pgtype.Present},
pgtype.Aclitem{String: "=r/postgres", Status: pgtype.Present},
pgtype.Aclitem{String: "postgres=arwdDxt/postgres", Status: pgtype.Present},
},
Dimensions: []pgtype.ArrayDimension{
{Length: 2, LowerBound: 4},
@@ -51,26 +51,26 @@ func TestACLItemArrayTranscode(t *testing.T) {
})
}
func TestACLItemArrayConvertFrom(t *testing.T) {
func TestAclitemArrayConvertFrom(t *testing.T) {
successfulTests := []struct {
source interface{}
result pgtype.ACLItemArray
result pgtype.AclitemArray
}{
{
source: []string{"=r/postgres"},
result: pgtype.ACLItemArray{
Elements: []pgtype.ACLItem{{String: "=r/postgres", Status: pgtype.Present}},
result: pgtype.AclitemArray{
Elements: []pgtype.Aclitem{{String: "=r/postgres", Status: pgtype.Present}},
Dimensions: []pgtype.ArrayDimension{{LowerBound: 1, Length: 1}},
Status: pgtype.Present},
},
{
source: (([]string)(nil)),
result: pgtype.ACLItemArray{Status: pgtype.Null},
result: pgtype.AclitemArray{Status: pgtype.Null},
},
}
for i, tt := range successfulTests {
var r pgtype.ACLItemArray
var r pgtype.AclitemArray
err := r.ConvertFrom(tt.source)
if err != nil {
t.Errorf("%d: %v", i, err)
@@ -82,19 +82,19 @@ func TestACLItemArrayConvertFrom(t *testing.T) {
}
}
func TestACLItemArrayAssignTo(t *testing.T) {
func TestAclitemArrayAssignTo(t *testing.T) {
var stringSlice []string
type _stringSlice []string
var namedStringSlice _stringSlice
simpleTests := []struct {
src pgtype.ACLItemArray
src pgtype.AclitemArray
dst interface{}
expected interface{}
}{
{
src: pgtype.ACLItemArray{
Elements: []pgtype.ACLItem{{String: "=r/postgres", Status: pgtype.Present}},
src: pgtype.AclitemArray{
Elements: []pgtype.Aclitem{{String: "=r/postgres", Status: pgtype.Present}},
Dimensions: []pgtype.ArrayDimension{{LowerBound: 1, Length: 1}},
Status: pgtype.Present,
},
@@ -102,8 +102,8 @@ func TestACLItemArrayAssignTo(t *testing.T) {
expected: []string{"=r/postgres"},
},
{
src: pgtype.ACLItemArray{
Elements: []pgtype.ACLItem{{String: "=r/postgres", Status: pgtype.Present}},
src: pgtype.AclitemArray{
Elements: []pgtype.Aclitem{{String: "=r/postgres", Status: pgtype.Present}},
Dimensions: []pgtype.ArrayDimension{{LowerBound: 1, Length: 1}},
Status: pgtype.Present,
},
@@ -111,7 +111,7 @@ func TestACLItemArrayAssignTo(t *testing.T) {
expected: _stringSlice{"=r/postgres"},
},
{
src: pgtype.ACLItemArray{Status: pgtype.Null},
src: pgtype.AclitemArray{Status: pgtype.Null},
dst: &stringSlice,
expected: (([]string)(nil)),
},
@@ -129,12 +129,12 @@ func TestACLItemArrayAssignTo(t *testing.T) {
}
errorTests := []struct {
src pgtype.ACLItemArray
src pgtype.AclitemArray
dst interface{}
}{
{
src: pgtype.ACLItemArray{
Elements: []pgtype.ACLItem{{Status: pgtype.Null}},
src: pgtype.AclitemArray{
Elements: []pgtype.Aclitem{{Status: pgtype.Null}},
Dimensions: []pgtype.ArrayDimension{{LowerBound: 1, Length: 1}},
Status: pgtype.Present,
},