Store: use "at" suffix for time base fields more consistently (#58486)

This commit is contained in:
Ryan McKinley
2022-11-08 17:42:32 -05:00
committed by GitHub
parent ad9ac85ee0
commit 238a3f820c
6 changed files with 275 additions and 256 deletions
@@ -72,8 +72,8 @@ func (s *sqlObjectServer) rowToReadObjectResponse(ctx context.Context, rows *sql
args := []interface{}{
&path, &raw.GRN.Kind, &raw.Version,
&raw.Size, &raw.ETag, &summaryjson.errors,
&raw.Created, &raw.CreatedBy,
&raw.Updated, &raw.UpdatedBy,
&raw.CreatedAt, &raw.CreatedBy,
&raw.UpdatedAt, &raw.UpdatedBy,
&syncSrc, &syncTime,
}
if r.WithBody {
@@ -193,12 +193,12 @@ func (s *sqlObjectServer) readFromHistory(ctx context.Context, r *object.ReadObj
rsp := &object.ReadObjectResponse{
Object: raw,
}
err = rows.Scan(&raw.Body, &raw.Size, &raw.ETag, &raw.Updated, &raw.UpdatedBy)
err = rows.Scan(&raw.Body, &raw.Size, &raw.ETag, &raw.UpdatedAt, &raw.UpdatedBy)
if err != nil {
return nil, err
}
// For versioned files, the created+updated are the same
raw.Created = raw.Updated
raw.CreatedAt = raw.UpdatedAt
raw.CreatedBy = raw.UpdatedBy
raw.Version = r.Version // from the query
@@ -357,7 +357,7 @@ func (s *sqlObjectServer) Write(ctx context.Context, r *object.WriteObjectReques
// 1. Add the `object_history` values
versionInfo.Size = int64(len(body))
versionInfo.ETag = etag
versionInfo.Updated = timestamp
versionInfo.UpdatedAt = timestamp
versionInfo.UpdatedBy = store.GetUserIDString(modifier)
_, err = tx.Exec(ctx, `INSERT INTO object_history (`+
"path, version, message, "+
@@ -454,7 +454,7 @@ func (s *sqlObjectServer) selectForUpdate(ctx context.Context, tx *session.Sessi
}
current := &object.ObjectVersionInfo{}
if rows.Next() {
err = rows.Scan(&current.ETag, &current.Version, &current.Updated, &current.Size)
err = rows.Scan(&current.ETag, &current.Version, &current.UpdatedAt, &current.Size)
}
if err == nil {
err = rows.Close()
@@ -541,7 +541,7 @@ func (s *sqlObjectServer) History(ctx context.Context, r *object.ObjectHistoryRe
}
for rows.Next() {
v := &object.ObjectVersionInfo{}
err := rows.Scan(&v.Version, &v.Size, &v.ETag, &v.Updated, &v.UpdatedBy, &v.Comment)
err := rows.Scan(&v.Version, &v.Size, &v.ETag, &v.UpdatedAt, &v.UpdatedBy, &v.Comment)
if err != nil {
return nil, err
}
@@ -558,7 +558,7 @@ func (s *sqlObjectServer) Search(ctx context.Context, r *object.ObjectSearchRequ
fields := []string{
"path", "kind", "version", "errors", // errors are always returned
"updated_at", "updated_by",
"size", "updated_at", "updated_by",
"name", "description", // basic summary
}
@@ -623,7 +623,7 @@ func (s *sqlObjectServer) Search(ctx context.Context, r *object.ObjectSearchRequ
args := []interface{}{
&key, &result.GRN.Kind, &result.Version, &summaryjson.errors,
&result.Updated, &result.UpdatedBy,
&result.Size, &result.UpdatedAt, &result.UpdatedBy,
&result.Name, &summaryjson.description,
}
if r.WithBody {