'Returns the internal query\'s SQL and parameters (as a tuple).'

def _as_sql(self, connection):

    obj = self.values('pk')
    if ((obj._db is None) or (connection == connections[obj._db])):
        return obj.query.get_compiler(connection=connection).as_nested_sql()
    raise ValueError("Can't    do    subqueries    with    queries    on    different    DBs.")
