Merge pull request #11339 from ywk253100/200328_limit_offset

Add "order by" clause to avoid the duplicat rows
This commit is contained in:
Wenkai Yin(尹文开) 2020-03-30 17:14:44 +08:00 committed by GitHub
commit 4faff18b2d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 5 additions and 2 deletions

View File

@ -97,6 +97,7 @@ func (d *dao) List(ctx context.Context, query *q.Query) ([]*Artifact, error) {
if err != nil {
return nil, err
}
qs = qs.OrderBy("-PushTime", "ID")
if _, err = qs.All(&artifacts); err != nil {
return nil, err
}

View File

@ -68,6 +68,7 @@ func (d *dao) List(ctx context.Context, query *q.Query) ([]*models.RepoRecord, e
if err != nil {
return nil, err
}
qs = qs.OrderBy("-CreationTime", "RepositoryID")
if _, err = qs.All(&repositories); err != nil {
return nil, err
}

View File

@ -71,6 +71,7 @@ func (d *dao) List(ctx context.Context, query *q.Query) ([]*tag.Tag, error) {
if err != nil {
return nil, err
}
qs = qs.OrderBy("-PushTime", "ID")
if _, err = qs.All(&tags); err != nil {
return nil, err
}

View File

@ -80,8 +80,8 @@ class TestProjects(unittest.TestCase):
artifact = self.artifact.get_reference_info(TestProjects.project_name, self.repo_name, tag, **TestProjects.USER_CLIENT)
#6. Verify the image(IA) contains tag named 1.0;
self.assertEqual(artifact[0].tags[0].name, tag)
self.assertEqual(artifact[0].tags[1].name, "1.0")
self.assertEqual(artifact[0].tags[0].name, "1.0")
self.assertEqual(artifact[0].tags[1].name, tag)
#7. Delete the tag(1.0) from image(IA);
self.artifact.delete_tag(TestProjects.project_name, self.repo_name, tag, "1.0",**TestProjects.USER_CLIENT)