Re: BUG #3848: function pg_catalog.substring(date, integer, integer) does not exist

From: Sam Mason <sam(at)samason(dot)me(dot)uk>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #3848: function pg_catalog.substring(date, integer, integer) does not exist
Date: 2008-01-01 21:39:41
Message-ID: 20080101213941.GD11262@frubble.xen.chris-lamb.co.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Tue, Jan 01, 2008 at 04:29:47PM -0500, Tom Lane wrote:
> Sam Mason <sam(at)samason(dot)me(dot)uk> writes:
> > I've just downloaded the source of tinyerp and had a look though and
> > this practice seems pretty endemic. They should really be using
> > to_char(date_exp, 'YYYY-MM')
> > instead of
> > substring(date_exp FOR 7)
> > in all their queries.
>
> Or at least explicitly casting the date to text. But your way is
> better, since it won't break if the datestyle is something other
> than ISO.

It also improves code readability is is always a good thing.

I've just gone though the code and sent a patch to the tinyerp-devel
list with these fixes in. Lets see if it gets incorporated.

Sam

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Mark Reid 2008-01-01 23:42:26 Re: BUG #3847: plpython trigger caches table structure - doesn't see new / changed columns
Previous Message Tom Lane 2008-01-01 21:29:47 Re: BUG #3848: function pg_catalog.substring(date, integer, integer) does not exist