-
-
Notifications
You must be signed in to change notification settings - Fork 400
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
Table Alias Names Exceeds 63 Bytes #1367
Comments
For now your only option is to use shorter aliases and shorter column names. As a general fix we could use some hashing to shorter generated column names, but I don't know when I will have time to work on that. |
@l0gicgate, any luck figuring this out? We're running into the same thing. |
@CyborgMaster the only solution is to make the name of your entities less descriptive (shorter in length) and hope for the best unfortunately. This naming strategy was supposed to be fixed a while ago but doesn't seem like it has been. |
Thanks for the update. Much appreciated. Maybe I'll try to whip together a patch. |
same problem here 😞 |
Dear @vmihailenco ,
Is there a way to provide an alias to a example: type User struct {
ID int64 `pg:",pk"`
ProfileID int64 `pg:",fk:Profile"`
Profile *Profile `pg:"rel:has-one"`
}
type Profile struct {
ID int64 `pg:",pk"`
UserID int64 `pg:",fk:User"`
} In order to avoid long aliases while querying a Is my questions even clear? 😄 |
So there seems to be a problem with long column names when doing joins as the library aliases column names in this fashion:
I was getting the following error:
I realized that as you can see the column name gets cut off because Postgres's max identifier length is 63 bytes which the alias exceeds.
So when the results are returned, the library calls the function
ScanColumn
passing in a partial column name (cut off after 63 bytes):https://github.com/go-pg/pg/blob/master/messages.go#L798
That results in an error. The
discard_unknown_columns
flag seems like a hackish way to circumvent the problem. Is there not a different way to approach table name aliasing to ensure we don't exceed 63 byte identifiers?The text was updated successfully, but these errors were encountered: