Skip to content

Commit 75edef3

Browse files
committed
db: fix auth_user table alias mismatch
Bun derives the SQL alias from the Go struct name, so the User struct gets aliased as "user" while the table is "auth_user". This causes queries with explicit JOIN references to auth_user.id to fail on PostgreSQL with "invalid reference to FROM-clause entry". Force the alias to match the table name, same approach already used for ci_check. Signed-off-by: Robin Jarry <robin@jarry.cc>
1 parent 02d03b1 commit 75edef3

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

‎pkg/db/models.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313
)
1414

1515
type User struct {
16-
bun.BaseModel `bun:"table:auth_user" json:"-"`
16+
bun.BaseModel `bun:"table:auth_user,alias:auth_user" json:"-"`
1717

1818
ID int `bun:"id,pk,autoincrement" json:"id"`
1919
Username string `bun:"username,notnull" json:"username"`

0 commit comments

Comments
 (0)