Upgrade Peewee to latest 3.x
This requires a number of small changes in the data model code, as well as additional testing.
This commit is contained in:
parent
70b7ee4654
commit
d3d9cca182
26 changed files with 220 additions and 193 deletions
|
@ -4,7 +4,7 @@ import time
|
|||
from calendar import timegm
|
||||
from uuid import uuid4
|
||||
|
||||
from peewee import IntegrityError, JOIN_LEFT_OUTER, fn
|
||||
from peewee import IntegrityError, JOIN, fn
|
||||
from data.model import (image, db_transaction, DataModelException, _basequery,
|
||||
InvalidManifestException, TagAlreadyCreatedException, StaleTagException,
|
||||
config)
|
||||
|
@ -44,8 +44,8 @@ def get_tags_images_eligible_for_scan(clair_version):
|
|||
.join(Image, on=(RepositoryTag.image == Image.id))
|
||||
.join(ImageStorage, on=(Image.storage == ImageStorage.id))
|
||||
.switch(Image)
|
||||
.join(Parent, JOIN_LEFT_OUTER, on=(Image.parent == Parent.id))
|
||||
.join(ParentImageStorage, JOIN_LEFT_OUTER, on=(ParentImageStorage.id == Parent.storage))
|
||||
.join(Parent, JOIN.LEFT_OUTER, on=(Image.parent == Parent.id))
|
||||
.join(ParentImageStorage, JOIN.LEFT_OUTER, on=(ParentImageStorage.id == Parent.storage))
|
||||
.where(RepositoryTag.hidden == False)
|
||||
.where(Image.security_indexed_engine < clair_version))
|
||||
|
||||
|
@ -71,7 +71,7 @@ def filter_tags_have_repository_event(query, event):
|
|||
lifetime_start_ts.
|
||||
"""
|
||||
query = filter_has_repository_event(query, event)
|
||||
query = query.switch(Image).join(ImageStorage)
|
||||
query = query.switch(RepositoryTag).join(Image).join(ImageStorage)
|
||||
query = query.switch(RepositoryTag).order_by(RepositoryTag.lifetime_start_ts.desc())
|
||||
return query
|
||||
|
||||
|
@ -146,12 +146,13 @@ def get_matching_tags_for_images(image_pairs, filter_images=None, filter_tags=No
|
|||
# Collect IDs of the tags found for each query.
|
||||
tags = {}
|
||||
for query in sharded_queries:
|
||||
ImageAlias = Image.alias()
|
||||
tag_query = (_tag_alive(RepositoryTag
|
||||
.select(*(selections or []))
|
||||
.distinct()
|
||||
.join(Image)
|
||||
.join(ImageAlias)
|
||||
.where(RepositoryTag.hidden == False)
|
||||
.where(Image.id << query)
|
||||
.where(ImageAlias.id << query)
|
||||
.switch(RepositoryTag)))
|
||||
|
||||
if filter_tags is not None:
|
||||
|
@ -210,7 +211,7 @@ def list_active_repo_tags(repo):
|
|||
.join(Image)
|
||||
.where(RepositoryTag.repository == repo, RepositoryTag.hidden == False)
|
||||
.switch(RepositoryTag)
|
||||
.join(TagManifest, JOIN_LEFT_OUTER))
|
||||
.join(TagManifest, JOIN.LEFT_OUTER))
|
||||
|
||||
return query
|
||||
|
||||
|
|
Reference in a new issue