Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update "table" with inverse (logic) doesn't work #833

Open
leichgardt opened this issue May 6, 2021 · 0 comments
Open

Update "table" with inverse (logic) doesn't work #833

leichgardt opened this issue May 6, 2021 · 0 comments

Comments

@leichgardt
Copy link

In aiopg, queries to update table fields doesn't work with self inversion.
I tried to inverse one field like that:

cmd = 'UPDATE schema.table SET field1 = NOT field1 WHERE field2 = %s'
await cur.execute(cmd, args)

It didn't work. instead of this way, I had to do this in two queries - select and update:

cmd = 'SELECT field1 FROM schema.table WHERE field2 = %s'
res = await cur.execute(cmd, args)
res = not res[0][0]

cmd = 'UPDATE schema.table SET field1 = %s WHERE field2 = %s'
await cur.execute(cmd, (res,) + args)

The syntax for SET field = NOT field is correct and it works in terminal, but I don't know why it doesn't work here.

System

system: ubuntu 20.04
python: 3.8
aiogp: 1.2.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant