Merge pull request #207 from ferhatelmas/simple-refactor-to-simplify-maps
Simplify map composite literals as gofmt -s handles
This commit is contained in:
@@ -427,7 +427,7 @@ func ParseURI(uri string) (ConnConfig, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ignoreKeys := map[string]struct{}{
|
ignoreKeys := map[string]struct{}{
|
||||||
"sslmode": struct{}{},
|
"sslmode": {},
|
||||||
}
|
}
|
||||||
|
|
||||||
cp.RuntimeParams = make(map[string]string)
|
cp.RuntimeParams = make(map[string]string)
|
||||||
|
|||||||
+13
-13
@@ -85,23 +85,23 @@ func TestNullHstoreTranscode(t *testing.T) {
|
|||||||
{pgx.NullHstore{}, "null"},
|
{pgx.NullHstore{}, "null"},
|
||||||
{pgx.NullHstore{Valid: true}, "empty"},
|
{pgx.NullHstore{Valid: true}, "empty"},
|
||||||
{pgx.NullHstore{
|
{pgx.NullHstore{
|
||||||
Hstore: map[string]pgx.NullString{"foo": pgx.NullString{String: "bar", Valid: true}},
|
Hstore: map[string]pgx.NullString{"foo": {String: "bar", Valid: true}},
|
||||||
Valid: true},
|
Valid: true},
|
||||||
"single key/value"},
|
"single key/value"},
|
||||||
{pgx.NullHstore{
|
{pgx.NullHstore{
|
||||||
Hstore: map[string]pgx.NullString{"foo": pgx.NullString{String: "bar", Valid: true}, "baz": pgx.NullString{String: "quz", Valid: true}},
|
Hstore: map[string]pgx.NullString{"foo": {String: "bar", Valid: true}, "baz": {String: "quz", Valid: true}},
|
||||||
Valid: true},
|
Valid: true},
|
||||||
"multiple key/values"},
|
"multiple key/values"},
|
||||||
{pgx.NullHstore{
|
{pgx.NullHstore{
|
||||||
Hstore: map[string]pgx.NullString{"NULL": pgx.NullString{String: "bar", Valid: true}},
|
Hstore: map[string]pgx.NullString{"NULL": {String: "bar", Valid: true}},
|
||||||
Valid: true},
|
Valid: true},
|
||||||
`string "NULL" key`},
|
`string "NULL" key`},
|
||||||
{pgx.NullHstore{
|
{pgx.NullHstore{
|
||||||
Hstore: map[string]pgx.NullString{"foo": pgx.NullString{String: "NULL", Valid: true}},
|
Hstore: map[string]pgx.NullString{"foo": {String: "NULL", Valid: true}},
|
||||||
Valid: true},
|
Valid: true},
|
||||||
`string "NULL" value`},
|
`string "NULL" value`},
|
||||||
{pgx.NullHstore{
|
{pgx.NullHstore{
|
||||||
Hstore: map[string]pgx.NullString{"foo": pgx.NullString{String: "", Valid: false}},
|
Hstore: map[string]pgx.NullString{"foo": {String: "", Valid: false}},
|
||||||
Valid: true},
|
Valid: true},
|
||||||
`NULL value`},
|
`NULL value`},
|
||||||
}
|
}
|
||||||
@@ -120,36 +120,36 @@ func TestNullHstoreTranscode(t *testing.T) {
|
|||||||
}
|
}
|
||||||
for _, sst := range specialStringTests {
|
for _, sst := range specialStringTests {
|
||||||
tests = append(tests, test{pgx.NullHstore{
|
tests = append(tests, test{pgx.NullHstore{
|
||||||
Hstore: map[string]pgx.NullString{sst.input + "foo": pgx.NullString{String: "bar", Valid: true}},
|
Hstore: map[string]pgx.NullString{sst.input + "foo": {String: "bar", Valid: true}},
|
||||||
Valid: true},
|
Valid: true},
|
||||||
"key with " + sst.description + " at beginning"})
|
"key with " + sst.description + " at beginning"})
|
||||||
tests = append(tests, test{pgx.NullHstore{
|
tests = append(tests, test{pgx.NullHstore{
|
||||||
Hstore: map[string]pgx.NullString{"foo" + sst.input + "foo": pgx.NullString{String: "bar", Valid: true}},
|
Hstore: map[string]pgx.NullString{"foo" + sst.input + "foo": {String: "bar", Valid: true}},
|
||||||
Valid: true},
|
Valid: true},
|
||||||
"key with " + sst.description + " in middle"})
|
"key with " + sst.description + " in middle"})
|
||||||
tests = append(tests, test{pgx.NullHstore{
|
tests = append(tests, test{pgx.NullHstore{
|
||||||
Hstore: map[string]pgx.NullString{"foo" + sst.input: pgx.NullString{String: "bar", Valid: true}},
|
Hstore: map[string]pgx.NullString{"foo" + sst.input: {String: "bar", Valid: true}},
|
||||||
Valid: true},
|
Valid: true},
|
||||||
"key with " + sst.description + " at end"})
|
"key with " + sst.description + " at end"})
|
||||||
tests = append(tests, test{pgx.NullHstore{
|
tests = append(tests, test{pgx.NullHstore{
|
||||||
Hstore: map[string]pgx.NullString{sst.input: pgx.NullString{String: "bar", Valid: true}},
|
Hstore: map[string]pgx.NullString{sst.input: {String: "bar", Valid: true}},
|
||||||
Valid: true},
|
Valid: true},
|
||||||
"key is " + sst.description})
|
"key is " + sst.description})
|
||||||
|
|
||||||
tests = append(tests, test{pgx.NullHstore{
|
tests = append(tests, test{pgx.NullHstore{
|
||||||
Hstore: map[string]pgx.NullString{"foo": pgx.NullString{String: sst.input + "bar", Valid: true}},
|
Hstore: map[string]pgx.NullString{"foo": {String: sst.input + "bar", Valid: true}},
|
||||||
Valid: true},
|
Valid: true},
|
||||||
"value with " + sst.description + " at beginning"})
|
"value with " + sst.description + " at beginning"})
|
||||||
tests = append(tests, test{pgx.NullHstore{
|
tests = append(tests, test{pgx.NullHstore{
|
||||||
Hstore: map[string]pgx.NullString{"foo": pgx.NullString{String: "bar" + sst.input + "bar", Valid: true}},
|
Hstore: map[string]pgx.NullString{"foo": {String: "bar" + sst.input + "bar", Valid: true}},
|
||||||
Valid: true},
|
Valid: true},
|
||||||
"value with " + sst.description + " in middle"})
|
"value with " + sst.description + " in middle"})
|
||||||
tests = append(tests, test{pgx.NullHstore{
|
tests = append(tests, test{pgx.NullHstore{
|
||||||
Hstore: map[string]pgx.NullString{"foo": pgx.NullString{String: "bar" + sst.input, Valid: true}},
|
Hstore: map[string]pgx.NullString{"foo": {String: "bar" + sst.input, Valid: true}},
|
||||||
Valid: true},
|
Valid: true},
|
||||||
"value with " + sst.description + " at end"})
|
"value with " + sst.description + " at end"})
|
||||||
tests = append(tests, test{pgx.NullHstore{
|
tests = append(tests, test{pgx.NullHstore{
|
||||||
Hstore: map[string]pgx.NullString{"foo": pgx.NullString{String: sst.input, Valid: true}},
|
Hstore: map[string]pgx.NullString{"foo": {String: sst.input, Valid: true}},
|
||||||
Valid: true},
|
Valid: true},
|
||||||
"value is " + sst.description})
|
"value is " + sst.description})
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -230,7 +230,7 @@ func (c *Conn) queryPrepared(name string, argsV []driver.Value) (driver.Rows, er
|
|||||||
// text format so that pgx.Rows.Values doesn't decode it into a native type
|
// text format so that pgx.Rows.Values doesn't decode it into a native type
|
||||||
// (e.g. []int32)
|
// (e.g. []int32)
|
||||||
func restrictBinaryToDatabaseSqlTypes(ps *pgx.PreparedStatement) {
|
func restrictBinaryToDatabaseSqlTypes(ps *pgx.PreparedStatement) {
|
||||||
for i, _ := range ps.FieldDescriptions {
|
for i := range ps.FieldDescriptions {
|
||||||
intrinsic, _ := databaseSqlOids[ps.FieldDescriptions[i].DataType]
|
intrinsic, _ := databaseSqlOids[ps.FieldDescriptions[i].DataType]
|
||||||
if !intrinsic {
|
if !intrinsic {
|
||||||
ps.FieldDescriptions[i].FormatCode = pgx.TextFormatCode
|
ps.FieldDescriptions[i].FormatCode = pgx.TextFormatCode
|
||||||
|
|||||||
Reference in New Issue
Block a user