Merge "Add a note about sqlalchemy metadata"

This commit is contained in:
Zuul 2019-02-12 01:18:43 +00:00 committed by Gerrit Code Review
commit 3eb23d2276
2 changed files with 9 additions and 2 deletions

View File

@ -733,11 +733,13 @@ class TestArtifacts(ZuulDBTestCase, BaseTestWeb, AnsibleZuulTestCase):
"job_name=project-test1").json()
self.assertEqual(len(build_query), 1)
self.assertEqual(len(build_query[0]['artifacts']), 3)
arts = build_query[0]['artifacts']
arts.sort(key=lambda x: x['name'])
self.assertEqual(build_query[0]['artifacts'], [
{'url': 'http://example.com/tarball',
'name': 'tarball'},
{'url': 'http://example.com/docs',
'name': 'docs'},
{'url': 'http://logs.example.com/build/relative/docs',
'name': 'relative'},
{'url': 'http://example.com/tarball',
'name': 'tarball'},
])

View File

@ -223,6 +223,11 @@ class SQLConnection(BaseConnection):
def createArtifact(self, *args, **kw):
session = orm.session.Session.object_session(self)
# SQLAlchemy reserves the 'metadata' attribute on
# object models, so our model and table names use
# 'meta', but here we accept data directly from
# zuul_return where it's called 'metadata'. Transform
# the attribute name.
if 'metadata' in kw:
kw['meta'] = kw['metadata']
del kw['metadata']