# Path: pushmanager/core/db.py
# def UnsignedInteger():
# def init_db():
# def finalize_db():
# def execute_cb(query, callback_fn):
# def execute_transaction_cb(queries, callback_fn, condition=None):
# def prefix_insert_ignore(insert_ignore, compiler, **kw):
# def prefix_insert_ignore_sqlite(insert_ignore, compiler, **kw):
# class DatabaseError(Exception):
# class PushCheckList(Base):
# class PushPlans(Base):
# class PushPushContents(Base):
# class PushPushes(Base):
# class PushRemovals(Base):
# class PushRequests(Base):
# class InsertIgnore(Insert):


import json
import sqlalchemy as SA
from pushmanager.core import db
from pushmanager.core import util
from pushmanager.core.requesthandler import RequestHandler

        # Repository constraint
        repos = self.request.arguments.get('repo', [])
        if repos:
            filters.append(db.push_requests.c.repo.in_(repos))

        # Branch constraint
        branches = self.request.arguments.get('branch', [])
        if branches:
            filters.append(db.push_requests.c.branch.in_(branches))

        # Revision constraint
        revisions = self.request.arguments.get('rev', [])
        if revisions:
            filters.append(db.push_requests.c.revision.in_(revisions))

        # Review constraint
        reviews = self.request.arguments.get('review', [])
        if reviews:
            filters.append(db.push_requests.c.reviewid.in_(reviews))

        # Title constraint
        for title in self.request.arguments.get('title', []):
            filters.append(db.push_requests.c.title.like('%' + title + '%'))

        # Only allow searches with at least one constraint (to avoid
        # accidental dumps of the entire table)
        if not filters:
            return self.send_error(409)


# Path: pushmanager/core/db.py
# def UnsignedInteger():
# def init_db():
# def finalize_db():
# def execute_cb(query, callback_fn):
# def execute_transaction_cb(queries, callback_fn, condition=None):
# def prefix_insert_ignore(insert_ignore, compiler, **kw):
# def prefix_insert_ignore_sqlite(insert_ignore, compiler, **kw):
# class DatabaseError(Exception):
# class PushCheckList(Base):
# class PushPlans(Base):
# class PushPushContents(Base):
# class PushPushes(Base):
# class PushRemovals(Base):
# class PushRequests(Base):
# class InsertIgnore(Insert):


# Path: pushmanager/servlets/api.py
import json
import sqlalchemy as SA
from pushmanager.core import db
from pushmanager.core import util
from pushmanager.core.requesthandler import RequestHandler


        # Repository constraint
        repos = self.request.arguments.get('repo', [])
        if repos:
            filters.append(db.push_requests.c.repo.in_(repos))

        # Branch constraint
        branches = self.request.arguments.get('branch', [])
        if branches:
            filters.append(db.push_requests.c.branch.in_(branches))

        # Revision constraint
        revisions = self.request.arguments.get('rev', [])
        if revisions:
            filters.append(db.push_requests.c.revision.in_(revisions))

        # Review constraint
        reviews = self.request.arguments.get('review', [])
        if reviews:
            filters.append(db.push_requests.c.reviewid.in_(reviews))

        # Title constraint
        for title in self.request.arguments.get('title', []):
            filters.append(db.push_requests.c.title.like('%' + title + '%'))

        # Only allow searches with at least one constraint (to avoid
        # accidental dumps of the entire table)
        if not filters:
            return self.send_error(409)


        query = db.push_requests.select(SA.and_(*filters))