~sircmpwn/sr.ht-dev

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
3 2

[PATCH hg.sr.ht] Upgrade hgsrht-shell to sqlalchemy 2.0 API usage

Details
Message ID
<429f5c2a99742fdc2fd0.1684262303@devahi>
DKIM signature
pass
Download raw message
Patch: +20 -17
# HG changeset patch
# User Ludovic Chabant <ludovic@chabant.com>
# Date 1684262080 0
#      Tue May 16 18:34:40 2023 +0000
# Node ID 429f5c2a99742fdc2fd0c7bbbbcc7461f5b5610f
# Parent  2240911d9025c8a5b874085917cd13166e80e6ab
Upgrade hgsrht-shell to sqlalchemy 2.0 API usage

diff --git a/hgsrht-shell b/hgsrht-shell
--- a/hgsrht-shell
+++ b/hgsrht-shell
@@ -7,6 +7,7 @@
import sys
from datetime import datetime
from sqlalchemy import create_engine
from sqlalchemy.sql.expression import text
from srht.config import cfg, get_origin
from srht.graphql import exec_gql
# HACK ???
@@ -141,7 +142,7 @@

def _do_get_or_create_repo(path, user_id, username, con):
    # Find a normal repository.
    query = con.execute("""
    t = text("""
    SELECT
        repo.id,
        repo.name,
@@ -153,24 +154,25 @@
        access.mode
    FROM repository repo
    JOIN "user" owner  ON owner.id = repo.owner_id
    JOIN "user" pusher ON pusher.id = %(user_id)s
    JOIN "user" pusher ON pusher.id = :user_id
    LEFT JOIN access
        ON (access.repo_id = repo.id AND access.user_id = %(user_id)s)
        ON (access.repo_id = repo.id AND access.user_id = :user_id)
    WHERE
        repo.path = %(path)s;""", user_id=user_id, path=path)
        repo.path = :path;""").bindparams(user_id=user_id, path=path)
    query = con.execute(t)
    row = query.fetchone()
    if row is not None:
        repo_info = _RepoInfo(row['id'], row['name'],
                row['owner_id'], row['username'])
        repo_info = _RepoInfo(row.id, row.name,
                row.owner_id, row.username)
        repo_info.path = path
        repo_info.visibility = row['visibility']
        repo_info.pusher_type = row['user_type']
        repo_info.pusher_suspend_notice = row['suspension_notice']
        repo_info.access_grant = row['mode']
        repo_info.visibility = row.visibility
        repo_info.pusher_type = row.user_type
        repo_info.pusher_suspend_notice = row.suspension_notice
        repo_info.access_grant = row.mode
        return repo_info

    # Not found... see if there's a redirect.
    query = con.execute("""
    t = text("""
    SELECT
        repo.id,
        repo.name,
@@ -182,16 +184,17 @@
        access.mode
    FROM repository repo
    JOIN "user" owner  ON owner.id = repo.owner_id
    JOIN "user" pusher ON pusher.id = %(user_id)s
    JOIN "user" pusher ON pusher.id = :user_id
    JOIN redirect      ON redirect.new_repo_id = repo.id
    LEFT JOIN "access"
        ON (access.repo_id = repo.id AND access.user_id = %(user_id)s)
    wHERE
        redirect.path = %(path)s;""", user_id=user_id, path=path)
        ON (access.repo_id = repo.id AND access.user_id = :user_id)
    WHERE
        redirect.path = :path;""").bindparams(user_id=user_id, path=path)
    query = con.execute(t)
    row = query.fetchone()
    if row is not None:
        owner_name = row['username']
        repo_name = row['name']
        owner_name = row.username
        repo_name = row.name
        raise _FoundRedirectRepo(
            f"{origin}/~{owner_name}/{repo_name}")
Details
Message ID
<d27b33b7-ab5e-4673-b165-6960c6720460@app.fastmail.com>
In-Reply-To
<429f5c2a99742fdc2fd0.1684262303@devahi> (view parent)
DKIM signature
pass
Download raw message
It looks like sqlalchemy completely changed their API with version 2.0...

I'm not sure however how package installs specify which version of sqlalchemy to install on Alpine? So I don't know if this patch would be premature. All I know is that with setup.py, my latest upgrade grabbed sqlalchemy 2+.
Details
Message ID
<CT18YNI5TZKL.1S320IZV6J0OM@taiga>
In-Reply-To
<d27b33b7-ab5e-4673-b165-6960c6720460@app.fastmail.com> (view parent)
DKIM signature
pass
Download raw message
Next alpine stable release will upgrade to 2.x, will hold this until
then.
Details
Message ID
<8ce50ef0-dc86-4888-93bf-4b14e8fe562a@app.fastmail.com>
In-Reply-To
<CT18YNI5TZKL.1S320IZV6J0OM@taiga> (view parent)
DKIM signature
pass
Download raw message
Sounds good, thanks.
Reply to thread Export thread (mbox)