Re: The same result for with SPACE and without SPACE

Поиск
Список
Период
Сортировка
От Scott Ribe
Тема Re: The same result for with SPACE and without SPACE
Дата
Msg-id BA739906-039B-409E-AD72-B7D1821D161D@elevated-dev.com
обсуждение исходный текст
Ответ на The same result for with SPACE and without SPACE  ("Wetmore, Matthew (CTR)" <Matthew.Wetmore@express-scripts.com>)
Ответы Re: The same result for with SPACE and without SPACE  (M Sarwar <sarwarmd02@outlook.com>)
Список pgsql-admin
Nobody's kicking you out of any group. Someone requested themselves to be removed, with a typo that made it ambiguous.

The original question had nothing to do with INT, it was behavior of CHAR and trailing spaces.

> 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?)


Yes. Or more precisely, it is because when a string is cast to an int, leading and trailing spaces are ignored. The
alternativewould be to raise an error, as 'an integer plus some spaces' is not an integer... 

> select c2 from matt_test2 where c2 = '123'
> -- 1 rows returned.


Yes, for TEXT column, which behaves the same as VARCHAR. Also 1 row for:

select c2 from matt_test2 where c2 = '123 '

But 2 rows returned for CHAR column, as inserting '123' and '123 ' into CHAR(n) results in the same value being
inserted.And also 2 rows returned for: 

select c2 from matt_test2 where c2 = '123 '

^^^ which was the original question


В списке pgsql-admin по дате отправления:

Предыдущее
От: "David G. Johnston"
Дата:
Сообщение: Re: The same result for with SPACE and without SPACE
Следующее
От: M Sarwar
Дата:
Сообщение: Re: The same result for with SPACE and without SPACE