SoFunction
Updated on 2025-04-08

Postgresql reported an error in mybatis: the operator does not exist: the problem of character variing == unknown

Error: The operator does not exist: character varying == unknown , Hint: There is no operator that matches the specified name and parameter type. You may need to add an explicit type conversion.

During Mybatis conditional query, there was not much written in SQL in SQL, so I didn't read it carefully, so I couldn't find the error, and I couldn't find similar errors on the Internet, and the result was a low-level error. . .

<div>
 <form:select path="finished" class="col-xs-12 form-control m-b">
 <form:option value="" label="Please select"/>
 <from:options items="${fns:getDictList('fin')}" itemLabel="label" 
  itemValue="value" htmlEscape="false"/>
 </form:select>
</div>

The dynamic SQL query below is used to judge the value of d_sign based on the value 0 or 1 or '' passed from the front desk dictionary to perform data filtering query. The default pass is "' (empty string) and will not enter the following judgment conditions, and it is 0 or 1.

①
<if test="dSign!=null and dSign =='0'.toString()">
	AND (b.d_sign is null or b.d_sign='')
</if>
②
<if test="dSign!=null and dSign =='1'.toString()">
	AND (b.d_sign is not null AND b.d_sign!='')
</if>

I wrote b.d_sign='' in the above ① to b.d_sign=='', thus reporting the above error.

In addition, I sort out some of the sql statements in postgresql that I have used:

My postgresql database version

select version(); //Query version statement

PostgreSQL 9.5.22, compiled by Visual C++ build 1800, 64-bit

Modify the table name

alter table table_name rename to table_name2;

Modify the default value of the field

ALTER TABLE Table name ALTER COLUMN List name SET DEFAULT default value; 

Set the value of a field to null

Correct demonstration:

update table_name set fin=null; //Complete the modification operation normally

Error demonstration:

update table_name set fin is null; // Report a syntax error!!!

Modify the data with null value in the table

Correct demonstration:

update table_name set fin='0' where fin is null ; //Complete the modification operation normally

Error demonstration:

update table_name set fin='0' where fin = null ; //No syntax error reported,But the number of modified characters is0,No modification

Modify the field type

alter table Table name alter COLUMN List name type varchar(255) ;

Add fields

ALTER TABLE Table name ADD Field name varchar(36);

Other tests:

//Total number of records in the tableselect count(1) from table_name 32
 
select count(1) from table_name where d_sign is null 9 //32=9+23
select count(1) from table_name where d_sign is not null 23 //23=5+18
select count(1) from table_name where d_sign= '' 5
select count(1) from table_name where d_sign!='' 18
 
select count(1) from table_name where d_sign is null or d_sign='' 14 //32=14+18
select count(1) from table_name where d_sign is not null AND d_sign!='' 18

This article about Postgresql reporting errors in mybatis: Operator does not exist: character varying == unknown is introduced here. For more related Postgresql reporting errors, please search for my previous articles or continue browsing the related articles below. I hope everyone will support me in the future!