# Upgrade to python-sql 1.4.1 breaks tryton-worker in Trytond 5.0.38

**URL:** https://discuss.tryton.org/t/upgrade-to-python-sql-1-4-1-breaks-tryton-worker-in-trytond-5-0-38/6275
**Category:** System Administrator
**Tags:** python-sql
**Created:** [June 17, 2023, 4:33pm UTC](https://discuss.tryton.org/t/upgrade-to-python-sql-1-4-1-breaks-tryton-worker-in-trytond-5-0-38/6275 "2023-06-17T16:33:50Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![jonl](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/jonl/32/1126_2.png) [@jonl](https://discuss.tryton.org/u/jonl)
#### Post date: [June 17, 2023, 4:33pm UTC](https://discuss.tryton.org/t/upgrade-to-python-sql-1-4-1-breaks-tryton-worker-in-trytond-5-0-38/6275/1 "2023-06-17T16:33:50Z")

</div>

The upgrade of `python-sql` from 1.4.0 to 1.4.1 causes the `trytond-worker` command to fail with the error:

```auto
Traceback (most recent call last):
  File "/usr/local/bin/trytond-worker", line 26, in <module>
    worker.work(options)
  File "/usr/local/lib/python3.8/site-packages/trytond/worker.py", line 68, in work
    task_id, next_ = queue.pull(options.name)
  File "/usr/local/lib/python3.8/site-packages/trytond/worker.py", line 33, in pull
    return Queue.pull(self.database, self.connection, name=name)
  File "/usr/local/lib/python3.8/site-packages/trytond/ir/queue.py", line 118, in pull
    cursor.execute(*query)
  File "/usr/local/lib/python3.8/site-packages/trytond/backend/postgresql/database.py", line 66, in execute
    cursor.execute(self, sql, args)
psycopg2.errors.UndefinedTable: relation "a" does not exist
LINE 1: ... "b")) RETURNING "id", (SELECT "a"."seconds" FROM "a" AS "a"...

```

The failing DB query is:

```auto
WITH "c" ("id", "scheduled_at", "expected_at") AS (SELECT "a"."id", "a"."scheduled_at", "a"."expected_at" FROM "ir_queue" AS "a" WHERE (true AND ("a"."dequeued_at" IS NULL)) ORDER BY "a"."scheduled_at" NULLS FIRST, "a"."expected_at" NULLS FIRST), "b" ("id") AS (SELECT "c"."id" FROM "c" AS "c" WHERE ((("c"."scheduled_at" <= CURRENT_TIMESTAMP) OR ("c"."scheduled_at" IS NULL)) AND pg_try_advisory_xact_lock("c"."id")) ORDER BY "c"."scheduled_at" NULLS FIRST, "c"."expected_at" NULLS FIRST LIMIT 1), "d" ("seconds") AS (SELECT MIN(EXTRACT(\'EPOCH\' FROM ("c"."scheduled_at" - CURRENT_TIMESTAMP))) FROM "c" AS "c" WHERE ("c"."scheduled_at" >= CURRENT_TIMESTAMP)) UPDATE "ir_queue" AS "a" SET "dequeued_at" = CURRENT_TIMESTAMP WHERE ("a"."id" = (SELECT "b"."id" FROM "b" AS "b")) RETURNING "id", (SELECT "a"."seconds" FROM "a" AS "a")

```

Rollback to `python-sql` version 1.4.0 fixes the issue.

This is happening with a Trytond instance pinned to version 5.0.38. Please advise if the recommended fix is to upgrade Trytond.

Thanks, in advance, for your attention.

---

<div class="post-metadata">

### Author: ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)
#### Post date: [June 17, 2023, 9:04pm UTC](https://discuss.tryton.org/t/upgrade-to-python-sql-1-4-1-breaks-tryton-worker-in-trytond-5-0-38/6275/2 "2023-06-17T21:04:09Z")

</div>

Please report a bug.

---

<div class="post-metadata">

### Author: ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)
#### Post date: [June 18, 2023, 8:19am UTC](https://discuss.tryton.org/t/upgrade-to-python-sql-1-4-1-breaks-tryton-worker-in-trytond-5-0-38/6275/3 "2023-06-18T08:19:22Z")

</div>

I reopened [Do not use alias in returning expression (#86) · Issues · Tryton / python-sql · GitLab](https://foss.heptapod.net/tryton/python-sql/-/issues/86)

---

<div class="post-metadata">

### Author: ![jonl](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/jonl/32/1126_2.png) [@jonl](https://discuss.tryton.org/u/jonl)
#### Post date: [June 19, 2023, 2:04pm UTC](https://discuss.tryton.org/t/upgrade-to-python-sql-1-4-1-breaks-tryton-worker-in-trytond-5-0-38/6275/4 "2023-06-19T14:04:38Z")

</div>

I created this issue report, [Upgrade to python-sql 1.4.1 breaks tryton-worker in Trytond 5.0.38 (#12334) · Issues · Tryton / Tryton · GitLab](https://foss.heptapod.net/tryton/tryton/-/issues/12334). (Hopefully, this was the right place. I couldn’t find where to report `python-sql` issues, rather than `tryton` issues.)
