hgourvest / node-firebird

Pure javascript and asynchronous Firebird client for Node.js.
Mozilla Public License 2.0
256 stars 128 forks source link

Error when using the LIKE clause in a SELECT #332

Open alanccezar opened 3 months ago

alanccezar commented 3 months ago

I found a BUG when executing a SELECT with the LIKE clause every time the STRING is greater than the field size.

Below I will try to exemplify the incident so that it is possible to correct the BUG correctly:

create table actors (
    intid,
    name varchar(10)
);

insert into actors
(id, name)
values
(1, 'James Wick');

1 examples of error-free execution

select * from actors
where name like 'James%';

STRING 'James%' with 6 characters runs without problems as the maximum field size is 10 characters

2 examples of error-free execution

select * from actors
where name like 'James%';

STRING '%Wick%' with 6 characters runs without problems as the maximum field size is 10 characters

3 examples of execution with error

select * from actors
where name like 'James Wick%';

STRING 'James Wick%' with 11 characters exceeds the 10 character size of the name field and causes a gdscode error: 335544569

4 examples of execution with error

select * from actors
where name like '%James Wick%';

STRING '%James Wick%' with 12 characters exceeds the 10 character length of the name field and causes a gdscode error: 335544569

Solution

In my understanding, queries with the LIKE clause should not carry out any type of treatment related to the size of the searched field, returning records when the query condition is met.