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

Boolean type always show false in OpenGaussDB #1457

Open
2 tasks done
AndrewDi opened this issue Apr 8, 2024 · 9 comments
Open
2 tasks done

Boolean type always show false in OpenGaussDB #1457

AndrewDi opened this issue Apr 8, 2024 · 9 comments

Comments

@AndrewDi
Copy link

AndrewDi commented Apr 8, 2024

Description

Boolean type display error。

Your environment

When I use pgcli connect to OpenGaussDB,boolean type always show false。

create table t2(a int,b boolean);
insert into t2 values(1,false);
insert into t2 values(1,true);
select * from t2;
+---+-------+
| a | b     |
|---+-------|
| 1 | False |
| 1 | False |
+---+-------+
  • Please provide your OS and version information: MacOS 14.4.1
  • Please provide your CLI version. 4.0.1
@AndrewDi
Copy link
Author

AndrewDi commented Apr 8, 2024

But when I use 3.3.1 version pgcli, no such problem.

@dbaty
Copy link
Member

dbaty commented Apr 8, 2024

Thanks for the report. By any chance, could you try to reproduce with the following versions: 3.4.1 and 3.5.0? My guess is that it might work with pgcli 3.4.1, but fail with 3.5.0. The culprit could be the migration from psycopg2 to psycopg3 (a dependency of pgcli), which landed in pgcli 3.5.0. If you can then try to connect directly with pyscopg2 and psycopg3, that would help pinpoint the source of the issue (which could then be reported to the psycopg project itself).

@AndrewDi
Copy link
Author

AndrewDi commented Apr 8, 2024

I use mac brew,it‘s not easy to rollback pgcli version。

@AndrewDi
Copy link
Author

AndrewDi commented Apr 8, 2024

I have do some test,sample code will always show false with psycopy 3.1.18.

#!/bin/python
import psycopg

if __name__ == '__main__':
    with psycopg.connect("dbname=testdb user=test host=192.168.64.5 port=5432") as conn:
        with conn.cursor() as cur:
            cur.execute('select true')
            for record in cur.fetchall():
                print(record)

@dbaty

@AndrewDi
Copy link
Author

AndrewDi commented Apr 8, 2024

when I change version to psycopg2, new error rise.

Traceback (most recent call last):
  File "/Users/xxx/Developer/psycopytest/testpsycopg.py", line 8, in <module>
    for record in cur.fetchall():
psycopg2.InterfaceError: can't parse boolean: '1'

@j-bennet
Copy link
Contributor

Newer versions of pgcli switched from psycopg2 to psysopg (also known as psycopg3). Those two libraries are not. compatible.

@AndrewDi
Copy link
Author

It's weird, same version with same code, original pgsql display right result, opengauss display wrong result, but opengauss's client gsql do not have such problem. @j-bennet

@vimiix
Copy link

vimiix commented Jul 3, 2024

when I change version to psycopg2, new error rise.

Traceback (most recent call last):
  File "/Users/xxx/Developer/psycopytest/testpsycopg.py", line 8, in <module>
    for record in cur.fetchall():
psycopg2.InterfaceError: can't parse boolean: '1'

@AndrewDi Psycopg2 dose have this problem. If you use 'B' compatibility database in opengauss, the Boolean values will return 0 or 1 at the protocol layer, the pg driver is not supported. I once fixed this in this issue.

@j-bennet
Copy link
Contributor

j-bennet commented Jul 3, 2024

You do not want to switch to psycopg2, we switched to psycopg as of 3.5.0.

@dbaty dbaty changed the title Boolean type always show false Boolean type always show false in OpenGaussDB Oct 17, 2024
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

4 participants