Обсуждение: Date = current_timestamp inconsistency?

Поиск
Список
Период
Сортировка

Date = current_timestamp inconsistency?

От
Jean-Christian Imbeault
Дата:
I've observed the following seeming inconsistency in postgres:

select ('2003-04-18'=current_timestamp::date)       --> True
select ('2003-04-18'::date=current_timestamp::date) --> True
select (d=current_timestamp) from t                 --> False
select (d=current_timestamp::date) from t           --> False
select (d::date=current_timestamp::date) from t     --> False


TEST=# select ('2003-04-18'=current_timestamp::date);
  ?column?
----------
  t
(1 row)

TEST=# select ('2003-04-18'::date=current_timestamp::date);
  ?column?
----------
  t
(1 row)

TEST=# create table t(d date);
CREATE TABLE
TEST=# insert into t values('2003-04-08');
INSERT 4475385 1
TEST=# select * from t;
      d
------------
  2003-04-08
(1 row)

TEST=# select (d=current_timestamp) from t;
  ?column?
----------
  f
(1 row)

TEST=# select (d=current_timestamp::date) from t;
  ?column?
----------
  f
(1 row)


TEST=# select (d::date=current_timestamp::date) from t;
  ?column?
----------
  f
(1 row)


Jean-Christian Imbeault


Re: Date = current_timestamp inconsistency?

От
"Peter Gibbs"
Дата:
Jean-Christian Imbeault wrote:

> TEST=# select ('2003-04-18'::date=current_timestamp::date);
>   t
> TEST=# insert into t values('2003-04-08');
> TEST=# select (d=current_timestamp::date) from t;
>   f

I'm not sure why you expect the 8th and 18th of April to be equal anyway??

--
Peter Gibbs
EmKel Systems