#4139 Remove _singleRow and _multiRow import to kojihub
Merged 3 months ago by tkopecek. Opened 9 months ago by jcupova.
jcupova/koji issue-3590  into  master

file modified
+23 -15
@@ -90,8 +90,6 @@ 

      _applyQueryOpts,

      _dml,

      _fetchSingle,

-     _multiRow,  # needed for backward compatibility, will removed in Koji 1.36

-     _singleRow,  # needed for backward compatibility, will removed in Koji 1.36

      _singleValue,

      get_event,

      nextval,
@@ -8888,22 +8886,32 @@ 

  

      # find rpms whose buildroots we were in

      st_complete = koji.BUILD_STATES['COMPLETE']

-     fields = ('id', 'name', 'version', 'release', 'arch', 'build_id')

+     fields = [

+         ('rpminfo.id', 'id'),

+         ('rpminfo.name', 'name'),

+         ('rpminfo.version', 'version'),

+         ('rpminfo.release', 'release'),

+         ('rpminfo.arch', 'arch'),

+         ('rpminfo.build_id', 'build_id')

+     ]

+     columns, aliases = zip(*fields)

      idx = {}

-     q = """SELECT

-         rpminfo.id, rpminfo.name, rpminfo.version, rpminfo.release, rpminfo.arch, rpminfo.build_id

-     FROM rpminfo, build

-     WHERE

-         rpminfo.buildroot_id IN (

-             SELECT DISTINCT buildroot_id

-                 FROM buildroot_listing

-                 WHERE rpm_id = %(rpm_id)s)

-         AND rpminfo.build_id = build.id

-         AND build.state = %(st_complete)i"""

      if limit is not None:

-         q += "\nLIMIT %(limit)i"

+         queryOpts = {'limit': limit}

+     else:

+         queryOpts = {}

      for rpm_id in build_rpm_ids:

-         for row in _multiRow(q, locals(), fields):

+         query = QueryProcessor(tables=['rpminfo', 'build'],

+                                columns=columns,

+                                aliases=aliases,

+                                clauses=['rpminfo.buildroot_id IN (SELECT DISTINCT buildroot_id '

+                                         'FROM buildroot_listing WHERE rpm_id = %(rpm_id)s)',

+                                         'rpminfo.build_id = build.id',

+                                         'build.state = %(st_complete)i'],

+                                values={'rpm_id': rpm_id, 'st_complete': st_complete},

+                                opts=queryOpts

+                                )

+         for row in query.execute():

              idx.setdefault(row['id'], row)

          if limit is not None and len(idx) > limit:

              break

flake8: commands[0]> flake8
./kojihub/kojihub.py:8906:20: F821 undefined name '_multiRow'

It appears that build_references() still uses this function

Do we know why this query wasn't changed in #3589 ?

rebased onto d982b5a

8 months ago

It is maybe a good candidate for QueryView

rebased onto 0823802

8 months ago

1 new commit added

  • Remove _singleRow and _multiRow import to kojihub
8 months ago

rebased onto 007cfa0

8 months ago

Metadata Update from @jcupova:
- Pull-request tagged with: testing-ready

7 months ago

Metadata Update from @mfilip:
- Pull-request tagged with: testing-done

3 months ago

Can you please indent this line - failing flake8.

rebased onto b7d193c

3 months ago

Commit 559dae7 fixes this pull-request

Pull-Request has been merged by tkopecek

3 months ago

In the future, please only use %s for value substitutions in queries.

While we do have a workaround in place that will convert these, it is better to have the correct value in the first place.