Re: The same result for with SPACE and without SPACE - Mailing list pgsql-admin

From David G. Johnston
Subject Re: The same result for with SPACE and without SPACE
Date
Msg-id CAKFQuwY=FN8HBqofgqOE6s1v_nh1QbszWre7_Ryi1qV=MEigJA@mail.gmail.com
Whole thread Raw
In response to The same result for with SPACE and without SPACE  ("Wetmore, Matthew (CTR)" <Matthew.Wetmore@express-scripts.com>)
List pgsql-admin


On Thu, Jun 15, 2023, 08:22 Wetmore, Matthew (CTR) <Matthew.Wetmore@express-scripts.com> wrote:

Before you kick me out of the group, can you please explain.

 

I thought the orig issue was that purposefully spaces/whitespace are being ignored (or not ignored.) in the select.  Maybe there was an email in the middle that I missed.

 

create table matt_test (c1 int)

 

insert into matt_test  values ('123')

 

insert into matt_test  values (' 123')

 

insert into matt_test values ('123 ')

 

select c1 from matt_test where c1 = '123'

-- all 3 rows returned.

 

Is it expected behavior that all 3 rows would be returned (because the space isn’t an INT?)

 

Works as I would expect with TEXT

 

create table matt_test2 (c2 text)

 

insert into matt_test2  values ('123')

 

insert into matt_test2  values (' 123')

 

insert into matt_test2  values ('123 ')

 

select c2 from matt_test2 where c2 = '123'

-- 1 rows returned.


If anything the inserts themselves should fail in trying to parse the string to integers.  But that works just fine so all three rows have the same integer output for the different inputs.

David J.

pgsql-admin by date:

Previous
From: Paul Smith*
Date:
Subject: Re: The same result for with SPACE and without SPACE
Next
From: Scott Ribe
Date:
Subject: Re: The same result for with SPACE and without SPACE