Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

fix: sheet `row_status` (#1113)

STEVENbdc3b0e6c7a6
diff --git a/api/sheet.go b/api/sheet.go
index 33822fd06e..a3f8ee63f5 100644
--- a/api/sheet.go
+++ b/api/sheet.go
@@ -87,6 +87,7 @@ type SheetRaw struct {
ID int
// Standard fields
+ RowStatus RowStatus
CreatorID int
CreatedTs int64
UpdaterID int
@@ -116,6 +117,7 @@ func (raw *SheetRaw) ToSheet() *Sheet {
ID: raw.ID,
// Standard fields
+ RowStatus: raw.RowStatus,
CreatorID: raw.CreatorID,
CreatedTs: raw.CreatedTs,
UpdaterID: raw.UpdaterID,
@@ -143,6 +145,7 @@ type Sheet struct {
ID int `jsonapi:"primary,sheet"`
// Standard fields
+ RowStatus RowStatus `jsonapi:"attr,rowStatus"`
CreatorID int
Creator *Principal `jsonapi:"relation,creator"`
CreatedTs int64 `jsonapi:"attr,createdTs"`
@@ -192,6 +195,7 @@ type SheetPatch struct {
ID int `jsonapi:"primary,sheetPatch"`
// Standard fields
+ RowStatus *string `jsonapi:"attr,rowStatus"`
// Value is assigned from the jwt subject field passed by the client.
UpdaterID int
@@ -207,8 +211,9 @@ type SheetPatch struct {
// SheetFind is the API message for finding sheets.
type SheetFind struct {
+ ID *int
+
// Standard fields
- ID *int
RowStatus *RowStatus
// Value is assigned from the jwt subject field passed by the client.
CreatorID *int
diff --git a/server/sheet.go b/server/sheet.go
index 2b12a91e6d..b082573ee2 100644
--- a/server/sheet.go
+++ b/server/sheet.go
@@ -289,7 +289,7 @@ func (s *Server) registerSheetRoutes(g *echo.Group) {
sheetFind.RowStatus = &rowStatus
}
- if projectIDStr := c.QueryParams().Get("projectId"); projectIDStr != "" {
+ if projectIDStr := c.QueryParam("projectId"); projectIDStr != "" {
projectID, err := strconv.Atoi(projectIDStr)
if err != nil {
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Project ID is not a number: %s", c.QueryParam("projectId"))).SetInternal(err)
@@ -297,7 +297,7 @@ func (s *Server) registerSheetRoutes(g *echo.Group) {
sheetFind.ProjectID = &projectID
}
- if databaseIDStr := c.QueryParams().Get("databaseId"); databaseIDStr != "" {
+ if databaseIDStr := c.QueryParam("databaseId"); databaseIDStr != "" {
databaseID, err := strconv.Atoi(databaseIDStr)
if err != nil {
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Database ID is not a number: %s", c.QueryParam("databaseId"))).SetInternal(err)
diff --git a/store/sheet.go b/store/sheet.go
index 4e0a5936b3..bfe230a5ae 100644
--- a/store/sheet.go
+++ b/store/sheet.go
@@ -142,7 +142,7 @@ func createSheet(ctx context.Context, tx *sql.Tx, create *api.SheetCreate, mode
payload
)
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)
- RETURNING id, creator_id, created_ts, updater_id, updated_ts, project_id, database_id, name, statement, visibility, source, type, payload
+ RETURNING id, row_status, creator_id, created_ts, updater_id, updated_ts, project_id, database_id, name, statement, visibility, source, type, payload
`,
create.CreatorID,
create.CreatorID,
@@ -166,6 +166,7 @@ func createSheet(ctx context.Context, tx *sql.Tx, create *api.SheetCreate, mode
databaseID := sql.NullInt32{}
if err := row.Scan(
&sheetRaw.ID,
+ &sheetRaw.RowStatus,
&sheetRaw.CreatorID,
&sheetRaw.CreatedTs,
&sheetRaw.UpdaterID,
@@ -200,7 +201,7 @@ func createSheet(ctx context.Context, tx *sql.Tx, create *api.SheetCreate, mode
visibility
)
VALUES ($1, $2, $3, $4, $5, $6, $7)
- RETURNING id, creator_id, created_ts, updater_id, updated_ts, project_id, database_id, name, statement, visibility
+ RETURNING id, row_status, creator_id, created_ts, updater_id, updated_ts, project_id, database_id, name, statement, visibility
`,
create.CreatorID,
create.CreatorID,
@@ -221,6 +222,7 @@ func createSheet(ctx context.Context, tx *sql.Tx, create *api.SheetCreate, mode
databaseID := sql.NullInt32{}
if err := row.Scan(
&sheetRaw.ID,
+ &sheetRaw.RowStatus,
&sheetRaw.CreatorID,
&sheetRaw.CreatedTs,
&sheetRaw.UpdaterID,
@@ -245,11 +247,14 @@ func createSheet(ctx context.Context, tx *sql.Tx, create *api.SheetCreate, mode
// patchSheet updates a sheet's name/statement/visibility.
func patchSheet(ctx context.Context, tx *sql.Tx, patch *api.SheetPatch, mode common.ReleaseMode) (*api.SheetRaw, error) {
set, args := []string{"updater_id = $1"}, []interface{}{patch.UpdaterID}
+ if v := patch.RowStatus; v != nil {
+ set, args = append(set, fmt.Sprintf("row_status = $%d", len(args)+1)), append(args, api.RowStatus(*v))
+ }
if v := patch.DatabaseID; v != nil {
set, args = append(set, fmt.Sprintf("database_id = $%d", len(args)+1)), append(args, *v)
}
if v := patch.Name; v != nil {
- set, args = append(set, fmt.Sprintf("name = $%d", len(args)+1)), append(args, api.RowStatus(*v))
+ set, args = append(set, fmt.Sprintf("name = $%d", len(args)+1)), append(args, *v)
}
if v := patch.Statement; v != nil {
set, args = append(set, fmt.Sprintf("statement = $%d", len(args)+1)), append(args, *v)
@@ -270,7 +275,7 @@ func patchSheet(ctx context.Context, tx *sql.Tx, patch *api.SheetPatch, mode com
UPDATE sheet
SET `+strings.Join(set, ", ")+`
WHERE id = $%d
- RETURNING id, creator_id, created_ts, updater_id, updated_ts, project_id, database_id, name, statement, visibility, source, type, payload
+ RETURNING id, row_status, creator_id, created_ts, updater_id, updated_ts, project_id, database_id, name, statement, visibility, source, type, payload
`, len(args)),
args...,
)
@@ -285,6 +290,7 @@ func patchSheet(ctx context.Context, tx *sql.Tx, patch *api.SheetPatch, mode com
databaseID := sql.NullInt32{}
if err := row.Scan(
&sheetRaw.ID,
+ &sheetRaw.RowStatus,
&sheetRaw.CreatorID,
&sheetRaw.CreatedTs,
&sheetRaw.UpdaterID,
@@ -315,7 +321,7 @@ func patchSheet(ctx context.Context, tx *sql.Tx, patch *api.SheetPatch, mode com
UPDATE sheet
SET `+strings.Join(set, ", ")+`
WHERE id = $%d
- RETURNING id, creator_id, created_ts, updater_id, updated_ts, project_id, database_id, name, statement, visibility
+ RETURNING id, row_status, creator_id, created_ts, updater_id, updated_ts, project_id, database_id, name, statement, visibility
`, len(args)),
args...,
)
@@ -330,6 +336,7 @@ func patchSheet(ctx context.Context, tx *sql.Tx, patch *api.SheetPatch, mode com
databaseID := sql.NullInt32{}
if err := row.Scan(
&sheetRaw.ID,
+ &sheetRaw.RowStatus,
&sheetRaw.CreatorID,
&sheetRaw.CreatedTs,
&sheetRaw.UpdaterID,
@@ -356,10 +363,12 @@ func patchSheet(ctx context.Context, tx *sql.Tx, patch *api.SheetPatch, mode com
func findSheetList(ctx context.Context, tx *sql.Tx, find *api.SheetFind, mode common.ReleaseMode) ([]*api.SheetRaw, error) {
where, args := []string{"1 = 1"}, []interface{}{}
- // Standard fields
+
if v := find.ID; v != nil {
where, args = append(where, fmt.Sprintf("id = $%d", len(args)+1)), append(args, *v)
}
+
+ // Standard fields
if v := find.RowStatus; v != nil {
where, args = append(where, fmt.Sprintf("row_status = $%d", len(args)+1)), append(args, *v)
}
@@ -389,6 +398,7 @@ func findSheetList(ctx context.Context, tx *sql.Tx, find *api.SheetFind, mode co
rows, err := tx.QueryContext(ctx, `
SELECT
id,
+ row_status,
creator_id,
created_ts,
updater_id,
@@ -416,6 +426,7 @@ func findSheetList(ctx context.Context, tx *sql.Tx, find *api.SheetFind, mode co
databaseID := sql.NullInt32{}
if err := rows.Scan(
&sheetRaw.ID,
+ &sheetRaw.RowStatus,
&sheetRaw.CreatorID,
&sheetRaw.CreatedTs,
&sheetRaw.UpdaterID,
@@ -449,6 +460,7 @@ func findSheetList(ctx context.Context, tx *sql.Tx, find *api.SheetFind, mode co
rows, err := tx.QueryContext(ctx, `
SELECT
id,
+ row_status,
creator_id,
created_ts,
updater_id,
@@ -473,6 +485,7 @@ func findSheetList(ctx context.Context, tx *sql.Tx, find *api.SheetFind, mode co
databaseID := sql.NullInt32{}
if err := rows.Scan(
&sheetRaw.ID,
+ &sheetRaw.RowStatus,
&sheetRaw.CreatorID,
&sheetRaw.CreatedTs,
&sheetRaw.UpdaterID,