diff --git a/database/datastore/get_object_info_by_data_id.go b/database/datastore/get_object_info_by_data_id.go index 8c5433e..a208330 100644 --- a/database/datastore/get_object_info_by_data_id.go +++ b/database/datastore/get_object_info_by_data_id.go @@ -26,6 +26,7 @@ func GetObjectInfoByDataID(dataID types.UInt64) (datastore_types.DataStoreMetaIn var createdDate time.Time var updatedDate time.Time + var tagArray []string err := database.Postgres.QueryRow(`SELECT data_id, @@ -58,7 +59,7 @@ func GetObjectInfoByDataID(dataID types.UInt64) (datastore_types.DataStoreMetaIn &metaInfo.Period, &metaInfo.ReferDataID, &metaInfo.Flag, - pq.Array(&metaInfo.Tags), + pq.Array(&tagArray), &createdDate, &updatedDate, ) @@ -79,6 +80,11 @@ func GetObjectInfoByDataID(dataID types.UInt64) (datastore_types.DataStoreMetaIn return datastore_types.NewDataStoreMetaInfo(), nexError } + metaInfo.Tags = make(types.List[types.String], 0, len(tagArray)) + for i := range tagArray { + metaInfo.Tags = append(metaInfo.Tags, types.String(tagArray[i])) + } + metaInfo.Ratings = ratings metaInfo.CreatedTime.FromTimestamp(createdDate) diff --git a/database/datastore/get_object_info_by_data_id_with_password.go b/database/datastore/get_object_info_by_data_id_with_password.go index d698f62..9e27d47 100644 --- a/database/datastore/get_object_info_by_data_id_with_password.go +++ b/database/datastore/get_object_info_by_data_id_with_password.go @@ -26,6 +26,7 @@ func GetObjectInfoByDataIDWithPassword(dataID, password types.UInt64) (datastore var createdDate time.Time var updatedDate time.Time + var tagArray []string err := database.Postgres.QueryRow(`SELECT data_id, @@ -58,7 +59,7 @@ func GetObjectInfoByDataIDWithPassword(dataID, password types.UInt64) (datastore &metaInfo.Period, &metaInfo.ReferDataID, &metaInfo.Flag, - pq.Array(&metaInfo.Tags), + pq.Array(&tagArray), &createdDate, &updatedDate, ) @@ -78,6 +79,11 @@ func GetObjectInfoByDataIDWithPassword(dataID, password types.UInt64) (datastore return datastore_types.NewDataStoreMetaInfo(), nexError } + metaInfo.Tags = make(types.List[types.String], 0, len(tagArray)) + for i := range tagArray { + metaInfo.Tags = append(metaInfo.Tags, types.String(tagArray[i])) + } + metaInfo.Ratings = ratings metaInfo.CreatedTime.FromTimestamp(createdDate) diff --git a/database/datastore/get_object_info_by_persistence_target_with_password.go b/database/datastore/get_object_info_by_persistence_target_with_password.go index 14cd87e..0721e8b 100644 --- a/database/datastore/get_object_info_by_persistence_target_with_password.go +++ b/database/datastore/get_object_info_by_persistence_target_with_password.go @@ -23,6 +23,7 @@ func GetObjectInfoByPersistenceTargetWithPassword(persistenceTarget datastore_ty var underReview bool var createdDate time.Time var updatedDate time.Time + var tagArray []string err := database.Postgres.QueryRow(`SELECT data_id, @@ -57,7 +58,7 @@ func GetObjectInfoByPersistenceTargetWithPassword(persistenceTarget datastore_ty &metaInfo.Period, &metaInfo.ReferDataID, &metaInfo.Flag, - pq.Array(&metaInfo.Tags), + pq.Array(&tagArray), &createdDate, &updatedDate, &accessPassword, @@ -89,6 +90,11 @@ func GetObjectInfoByPersistenceTargetWithPassword(persistenceTarget datastore_ty return datastore_types.NewDataStoreMetaInfo(), nexError } + metaInfo.Tags = make(types.List[types.String], 0, len(tagArray)) + for i := range tagArray { + metaInfo.Tags = append(metaInfo.Tags, types.String(tagArray[i])) + } + metaInfo.Ratings = ratings metaInfo.CreatedTime.FromTimestamp(createdDate) diff --git a/database/datastore/initialize_object_by_prepare_post_param.go b/database/datastore/initialize_object_by_prepare_post_param.go index 4890aa2..95bbbe3 100644 --- a/database/datastore/initialize_object_by_prepare_post_param.go +++ b/database/datastore/initialize_object_by_prepare_post_param.go @@ -14,6 +14,16 @@ import ( func InitializeObjectByPreparePostParam(ownerPID types.PID, param datastore_types.DataStorePreparePostParam) (uint64, *nex.Error) { var dataID uint64 + tagArray := make([]string, 0, len(param.Tags)) + for i := range param.Tags { + tagArray = append(tagArray, string(param.Tags[i])) + } + + extraDataArray := make([]string, 0, len(param.ExtraData)) + for i := range param.Tags { + extraDataArray = append(extraDataArray, string(param.ExtraData[i])) + } + now := time.Now() err := database.Postgres.QueryRow(`INSERT INTO datastore.objects ( owner, @@ -64,9 +74,9 @@ func InitializeObjectByPreparePostParam(ownerPID types.PID, param datastore_type param.Flag, param.Period, param.ReferDataID, - pq.Array(param.Tags), + pq.Array(tagArray), param.PersistenceInitParam.PersistenceSlotID, // TODO - Check param.PersistenceInitParam.DeleteLastObject? - pq.Array(param.ExtraData), + pq.Array(extraDataArray), now, now, ).Scan(&dataID) diff --git a/database/datastore/super-mario-maker/get_random_courses_with_limit.go b/database/datastore/super-mario-maker/get_random_courses_with_limit.go index e264076..103bd5a 100644 --- a/database/datastore/super-mario-maker/get_random_courses_with_limit.go +++ b/database/datastore/super-mario-maker/get_random_courses_with_limit.go @@ -71,6 +71,7 @@ func GetRandomCoursesWithLimit(limit int) (types.List[datastore_super_mario_make var createdDate time.Time var updatedDate time.Time + var tagArray []string err := rows.Scan( &course.MetaInfo.DataID, @@ -86,7 +87,7 @@ func GetRandomCoursesWithLimit(limit int) (types.List[datastore_super_mario_make &course.MetaInfo.Period, &course.MetaInfo.ReferDataID, &course.MetaInfo.Flag, - pq.Array(&course.MetaInfo.Tags), + pq.Array(&tagArray), &createdDate, &updatedDate, &course.Score, @@ -101,6 +102,11 @@ func GetRandomCoursesWithLimit(limit int) (types.List[datastore_super_mario_make return nil, nexError } + course.MetaInfo.Tags = make(types.List[types.String], 0, len(tagArray)) + for i := range tagArray { + course.MetaInfo.Tags = append(course.MetaInfo.Tags, types.String(tagArray[i])) + } + course.MetaInfo.Ratings = ratings course.MetaInfo.CreatedTime.FromTimestamp(createdDate) diff --git a/database/datastore/super-mario-maker/initialize_object_by_attach_file_param.go b/database/datastore/super-mario-maker/initialize_object_by_attach_file_param.go index 457e30d..502a650 100644 --- a/database/datastore/super-mario-maker/initialize_object_by_attach_file_param.go +++ b/database/datastore/super-mario-maker/initialize_object_by_attach_file_param.go @@ -15,6 +15,15 @@ func InitializeObjectByAttachFileParam(ownerPID types.PID, param datastore_smm_t now := time.Now() var dataID types.UInt64 + tagArray := make([]string, 0, len(param.PostParam.Tags)) + for i := range param.PostParam.Tags { + tagArray = append(tagArray, string(param.PostParam.Tags[i])) + } + + extraDataArray := make([]string, 0, len(param.PostParam.ExtraData)) + for i := range param.PostParam.Tags { + extraDataArray = append(extraDataArray, string(param.PostParam.ExtraData[i])) + } err := database.Postgres.QueryRow(`INSERT INTO datastore.objects ( owner, @@ -65,9 +74,9 @@ func InitializeObjectByAttachFileParam(ownerPID types.PID, param datastore_smm_t param.PostParam.Flag, param.PostParam.Period, param.ReferDataID, - pq.Array(param.PostParam.Tags), + pq.Array(tagArray), param.PostParam.PersistenceInitParam.PersistenceSlotID, // TODO - Check param.PersistenceInitParam.DeleteLastObject? - pq.Array(param.PostParam.ExtraData), + pq.Array(extraDataArray), now, now, ).Scan(&dataID)