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

Quotes in column names - postgresql #653

Open
trcorp1 opened this issue May 19, 2021 · 1 comment
Open

Quotes in column names - postgresql #653

trcorp1 opened this issue May 19, 2021 · 1 comment
Labels
s: triage Some tests need to be run to confirm the issue

Comments

@trcorp1
Copy link

trcorp1 commented May 19, 2021

Description

Quotes in column names seems to either be broken or not supported. I'm using an existing database and tables so I did not create the table though the interface

Steps to Reproduce the Problem

With the given table definition with quoted column

CREATE TABLE users (
    id integer NOT NULL,
    name text,
    "admin" boolean DEFAULT false
);

And the following model details

type User struct {
    ID int `json:"id" db:"id"`
	Name string `json:"name" db:"name"`
	Admin string `json:"admin" db:"admin"`
}

and alternatively with attempted quoted strings

type User struct {
    ID int `json:"id" db:"id"`
	Name string `json:"name" db:"name"`
	Admin string `json:"admin" db:"\"admin\""`
}

Expected Behavior

I expected to get the json results pulling from the table which I do receive if I quote out the admin field in the struct. The issue only appears with columns with quoted names

Actual Behavior

For the first model I get the following sql statement showing in buffalo dev

SELECT admin_users.admin, admin_users.name, admin_users.id FROM admin.users AS admin_users

which fails in pgadmin because the quotes are missing.
and then the following error:

{
    "error": "ERROR: column admin_users.admin does not exist (SQLSTATE 42703)"
}

With the alternative model the following sql statement is shown in buffalo dev

SELECT admin_users."admin", admin_users.name, admin_users.id FROM admin.users AS admin_users

which I can query successfully through pgadmin as the quotes are there.
But also generates the following error

{
    "error": "missing destination name admin in *[]models.User"
}

I of course may be trying to handle the quotes incorrectly so any guidance would be greatly appreciated. I was unable to locate any mention of how to handle this in the documentation. I also was not able to find any one else reporting the issue here or on slack channel suggest in the support section of the documentation

Info

rhel8, Pop 5.3.2 version through Buffalo v0.16.23

@trcorp1
Copy link
Author

trcorp1 commented May 19, 2021

updated to pop 5.3.4 through buffalo v0.16.23. No change.

@sio4 sio4 added the s: triage Some tests need to be run to confirm the issue label Sep 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
s: triage Some tests need to be run to confirm the issue
Projects
None yet
Development

No branches or pull requests

2 participants