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

Invalid Postgres Insert Syntax for Slices of String Pointers #877

Open
pc-bob opened this issue Aug 4, 2023 · 1 comment
Open

Invalid Postgres Insert Syntax for Slices of String Pointers #877

pc-bob opened this issue Aug 4, 2023 · 1 comment

Comments

@pc-bob
Copy link

pc-bob commented Aug 4, 2023

I have a struct defined like this:

type Location struct {
	ID string `bun:"type:uuid,pk"`

	MyStrings []string `bun:"type:text[],notnull"`

	MyOptionalStrings []*string `bun:"type:text[]"`

}

The postgres statement generated when trying to insert a value for this model does not correctly quote the string values within the array:

INSERT INTO "locations" AS "location" ("id", "my_strings", "my_optional_strings") VALUES ('C99C8B07-B153-4C1C-8CD9-907FC06FD46D', '{"foo","bar"}', '{'baz'}')

This results in an error from postgres:

*pq.Error: pq: syntax error at or near "baz"

The non-nullable string slice works correctly, but the slice of string pointers generates '{'baz'}' when it should generate {"baz"}' to be valid.

Copy link

This issue has been automatically marked as stale because it has not had activity in the last 30 days. If there is no update within the next 7 days, this issue will be closed.

@github-actions github-actions bot added the stale label Nov 11, 2024
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Nov 18, 2024
@j2gg0s j2gg0s removed the stale label Jan 23, 2025
@j2gg0s j2gg0s reopened this Jan 23, 2025
rfarrjr added a commit to rfarrjr/bun that referenced this issue Jan 27, 2025
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

2 participants