feat: rename project revision columns · ory/hydra@af69132 · GitHub
Skip to content

Commit af69132

Browse files
hperlory-bot
authored andcommitted
feat: rename project revision columns
GitOrigin-RevId: b20a153d86d72c43f83f7107b4c3ed602bcb5009
1 parent 5364144 commit af69132

2 files changed

Lines changed: 17 additions & 2 deletions

File tree

oryx/sqlcon/error.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,12 @@ var (
4545
StatusField: http.StatusText(http.StatusInternalServerError),
4646
ErrorField: "Unable to locate the table",
4747
}
48+
ErrNoSuchColumn = &herodot.DefaultError{
49+
CodeField: http.StatusInternalServerError,
50+
GRPCCodeField: codes.Internal,
51+
StatusField: http.StatusText(http.StatusInternalServerError),
52+
ErrorField: "Unable to locate the column",
53+
}
4854
)
4955

5056
func handlePostgres(err error, sqlState string) error {
@@ -56,6 +62,8 @@ func handlePostgres(err error, sqlState string) error {
5662
return errors.WithStack(ErrConcurrentUpdate.WithWrap(err))
5763
case "42P01": // "no such table"
5864
return errors.WithStack(ErrNoSuchTable.WithWrap(err))
65+
case "42703": // "no such column"
66+
return errors.WithStack(ErrNoSuchColumn.WithWrap(err))
5967
}
6068
return errors.WithStack(err)
6169
}
@@ -81,10 +89,12 @@ func HandleError(err error) error {
8189
return errors.WithStack(handlePostgres(err, e.Code))
8290
} else if e := new(mysql.MySQLError); errors.As(err, &e) {
8391
switch e.Number {
84-
case 1062:
92+
case 1062: // https://dev.mysql.com/doc/mysql-errors/8.0/en/server-error-reference.html#error_er_dup_entry
8593
return errors.WithStack(ErrUniqueViolation.WithWrap(err))
86-
case 1146:
94+
case 1146: // https://dev.mysql.com/doc/mysql-errors/8.0/en/server-error-reference.html#error_er_no_such_table
8795
return errors.WithStack(ErrNoSuchTable.WithWrap(e))
96+
case 1054: // https://dev.mysql.com/doc/mysql-errors/8.0/en/server-error-reference.html#error_er_bad_field_error
97+
return errors.WithStack(ErrNoSuchColumn.WithWrap(e))
8898
}
8999
}
90100

oryx/sqlcon/error_sqlite.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ func handleSqlite(err error) error {
3333
return errors.WithStack(ErrConcurrentUpdate.WithWrap(err))
3434
}
3535

36+
if strings.HasPrefix(e.Error(), "no such column:") ||
37+
strings.Contains(e.Error(), "has no column named") {
38+
return errors.WithStack(ErrNoSuchColumn.WithWrap(err))
39+
}
40+
3641
return errors.WithStack(err)
3742
}
3843

0 commit comments

Comments
 (0)