Skip to content

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

fix: db insert query (#15173)

Danny Xu81617bb66b3c
diff --git a/backend/store/database.go b/backend/store/database.go
index a1ceb58658..2c6968399a 100644
--- a/backend/store/database.go
+++ b/backend/store/database.go
@@ -193,7 +193,7 @@ func (*Store) createDatabaseDefaultImpl(ctx context.Context, tx *Tx, projectUID,
datashare,
service_name
)
- VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)
+ VALUES ($1, $2, $3, $4, $5, $6, $7, $8)
ON CONFLICT (instance_id, name) DO UPDATE SET
project_id = EXCLUDED.project_id,
sync_status = EXCLUDED.sync_status,
@@ -206,7 +206,6 @@ func (*Store) createDatabaseDefaultImpl(ctx context.Context, tx *Tx, projectUID,
projectUID,
create.DatabaseName,
api.OK,
- nil, /* sync_at */
"", /* schema_version */
secretsString, /* secrets */
create.DataShare,
diff --git a/backend/store/issue_comment.go b/backend/store/issue_comment.go
index 830b347901..0d948b6348 100644
--- a/backend/store/issue_comment.go
+++ b/backend/store/issue_comment.go
@@ -168,7 +168,8 @@ func (s *Store) CreateIssueComment(ctx context.Context, create *IssueCommentMess
return nil, errors.Wrapf(err, "failed to insert")
}
- creator, err := s.GetUserByID(ctx, create.creatorUID)
+ create.creatorUID = creatorUID
+ creator, err := s.GetUserByID(ctx, creatorUID)
if err != nil {
return nil, errors.Wrapf(err, "failed to get creator")
}
@@ -178,7 +179,7 @@ func (s *Store) CreateIssueComment(ctx context.Context, create *IssueCommentMess
}
func (s *Store) UpdateIssueComment(ctx context.Context, patch *UpdateIssueCommentMessage) error {
- set, args := []string{"updated_at = $2"}, []any{time.Now()}
+ set, args := []string{"updated_at = $1"}, []any{time.Now()}
if v := patch.Comment; v != nil {
set, args = append(set, fmt.Sprintf("payload = payload || jsonb_build_object('comment',$%d::TEXT)", len(args)+1)), append(args, *v)
diff --git a/backend/store/task.go b/backend/store/task.go
index f418cb3fc1..f9d8d4a645 100644
--- a/backend/store/task.go
+++ b/backend/store/task.go
@@ -366,8 +366,12 @@ func (s *Store) UpdateTaskV2(ctx context.Context, patch *api.TaskPatch) (*TaskMe
}
set, args = append(set, fmt.Sprintf("payload = $%d", len(args)+1)), append(args, payload)
}
- if v := patch.EarliestAllowedTs; v != nil {
- set, args = append(set, fmt.Sprintf("earliest_allowed_at = $%d", len(args)+1)), append(args, *v)
+ if patch.UpdateEarliestAllowedTs {
+ if patch.EarliestAllowedTs == nil {
+ set = append(set, "earliest_allowed_at = null")
+ } else {
+ set, args = append(set, fmt.Sprintf("earliest_allowed_at = $%d", len(args)+1)), append(args, *patch.EarliestAllowedTs)
+ }
}
args = append(args, patch.ID)