Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

comparing uncomparable type pgtype.VarcharArray #105

Open
bweston92 opened this issue Oct 9, 2024 · 0 comments
Open

comparing uncomparable type pgtype.VarcharArray #105

bweston92 opened this issue Oct 9, 2024 · 0 comments

Comments

@bweston92
Copy link
Contributor

To Reproduce

Use a Postgres type varchar[]

Create a query that queries it:

select mytype from mytype;

You'll see something like this in the generated code

// ...

type MyType struct {
	ID                *int32              `json:"id"`
	RemoteIdentifiers pgtype.VarcharArray `json:"remote_identifiers"`
}

// ...
func (tr *typeResolver) newMyType() pgtype.ValueTranscoder {
	return tr.newCompositeValue(
		"mytype",
		compositeField{name: "id", typeName: "int4", defaultVal: &pgtype.Int4{}},
// ...
		compositeField{name: "remote_identifiers", typeName: "_varchar", defaultVal: &pgtype.VarcharArray{}},
// ...
	)
}

Expected behavior

res, err := queries.FindMyType(ctx, 1)
// ...
var ids []string
_ = res.RemoteIdentifiers.AssignTo(&ids)
fmt.Printf("%+v", ids)
// to output a slice of string

Actual behavior

panic: runtime error: comparing uncomparable type pgtype.VarcharArray

goroutine 1 [running]:
github.com/jackc/pgtype.(*VarcharArray).Set(0xc0004e0038, {0xd200a0, 0xc0003f0180})
        external/com_github_jackc_pgtype/varchar_array.go:29 +0x114
github.com/jackc/pgtype.assignToOrSet({0xeaffc0, 0xc0003f0140}, {0xd2b740, 0xc0004e0038})
        external/com_github_jackc_pgtype/composite_type.go:171 +0xa2
github.com/jackc/pgtype.CompositeType.assignToPtrStruct({0x2, {0xd8047e, 0x6}, {0xc00005c200, 0x5, 0x5}, {0xc00051e410, 0x5, 0x5}}, {0xbf5c80, ...})
        external/com_github_jackc_pgtype/composite_type.go:212 +0x3d7
github.com/jackc/pgtype.CompositeType.AssignTo({0x2, {0xd8047e, 0x6}, {0xc00005c200, 0x5, 0x5}, {0xc00051e410, 0x5, 0x5}}, {0xbf5c80, ...})
        external/com_github_jackc_pgtype/composite_type.go:150 +0x1fb

See also: jackc/pgtype#217

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant