[cx-oracle-users] Filtering on char/nchar
Brought to you by:
atuining
From: kotofos <ib...@gm...> - 2019-09-30 09:39:55
|
Hello, I have a question about char/nchar and binding parameters type. We have tables which have char and nchar PK columns. When filtering with bound parameters on these columns, it is required to put in exact value with padding in where clause. Though, when the same is done as text, without params filtering works as expected. Examples: CREATE TABLE DBTESTING.nchartable ( id NCHAR(4) PRIMARY KEY NOT NULL ); insert into nchartable values ('1'); cur.execute("select * from nchartable where id = '1'") found cur.execute("select * from nchartable where id = :id", ['1 ']) found cur.execute("select * from nchartable where id = :id", ['1']) not found After debugging I found, that where clause fails because the parameter is nvarchar2. When I manually set the type to nchar all cases above works. See attached code. Is this behavior intended or it is a bug? How to correctly search on nchar column without adding padding in a query and preferably without specifying type manually? Checked on cx_oracle 7.2.2 |