Thread: ::date cast error

::date cast error

From
Jan Stavárek
Date:
<p>Hello,<p>I think I might have come accross a bug. <p><br /><p>Having following table:<p><br /><p>CREATE TABLE
general.materialtransaction<br/>(<br />  type integer NOT NULL,<br />  articleid integer NOT NULL,<br />  date
timestampwithout time zone NOT NULL,<br />  personid integer NOT NULL,<br />  note text,<br />  id serial NOT NULL,<br
/> CONSTRAINT materialtransaction_pkey PRIMARY KEY (id),<br />  CONSTRAINT fk_personid FOREIGN KEY (personid)<br
/>     REFERENCES general.person (id) MATCH SIMPLE<br />      ON UPDATE NO ACTION ON DELETE NO ACTION<br />)<br
/><p><br/>both queries<p><br /><p>SELECT Date FROM General.MaterialTransaction WHERE Date::date = '2014-03-30'<p><br
/><p>and<p><br /><p>SELECT Date FROM General.MaterialTransaction WHERE CAST(Date AS date) = '2014-03-30'<p><br
/><p>workwell in pgAdmin, but on only the second one works in my application (using C#, 4.0 .NET Framework and NpqSql).
Thefirst one emits a "syntax error at or near ":" error in the application. I'm using the latest versions of both
PostgreSQLand Npqsql.<p><br /><p>I will also let know the NpqSql team about this issue as I'm not really sure where the
rootcause might be. Maybe it is my fault, but the behaviour seems odd to me. At this moment it is not a critical issue
forme, since I can use the second approach, but I wanted you to know about it.<p><br /><p>Also, since this is my first
e-mailto you, I would like to thank you (the whole team) for all the efford you put into PostgreSQL. I'm happy that
somethinglike this exists!<p><br /><p>Best Regards,<p>Jan Stavarek 

Re: ::date cast error

From
Pavel Stehule
Date:
Hello


2014-03-31 14:15 GMT+02:00 Jan Stav=C3=A1rek <jan.stavarek@email.cz>:

> Hello,
>
> I think I might have come accross a bug.
>
>
> Having following table:
>
>
> CREATE TABLE general.materialtransaction
> (
>   type integer NOT NULL,
>   articleid integer NOT NULL,
>   date timestamp without time zone NOT NULL,
>   personid integer NOT NULL,
>   note text,
>   id serial NOT NULL,
>   CONSTRAINT materialtransaction_pkey PRIMARY KEY (id),
>   CONSTRAINT fk_personid FOREIGN KEY (personid)
>       REFERENCES general.person (id) MATCH SIMPLE
>       ON UPDATE NO ACTION ON DELETE NO ACTION
> )
>
>
> both queries
>
>
> SELECT Date FROM General.MaterialTransaction WHERE Date::date =3D
> '2014-03-30'
>
>
> and
>
>
> SELECT Date FROM General.MaterialTransaction WHERE CAST(Date AS date) =3D
> '2014-03-30'
>
>
> work well in pgAdmin, but on only the second one works in my application
> (using C#, 4.0 .NET Framework and NpqSql). The first one emits a "syntax
> error at or near ":" error in the application. I'm using the latest
> versions of both
>
PostgreSQL and Npqsql.
>
>
> It is looking like Npgsql issue related to unhappy named column "date" -
it is not keyword, but it is datatype name.


> I will also let know the NpqSql team about this issue as I'm not really
> sure where the root cause might be. Maybe it is my fault, but the behavio=
ur
> seems odd to me. At this moment it is not a critical issue for me, since =
I
> can use the second approach, but I wanted you to know about it.
>
>
>

if you can help - try to write some small test case and send it to Npgsql
team, please

Important info should be in your postgresql log. The broken query should be
logged there - and should be interesting what query was sent to server.
Please, attach related part of log to your test case.

Also, since this is my first e-mail to you, I would like to thank you (the
> whole team) for all the efford you put into PostgreSQL. I'm happy that
> something like this exists!
>

Thank you very much, we are proud so we have happy users.

Regards

Pavel Stehule


>
> Best Regards,
>
> Jan Stavarek
>