pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Iain <iain@mst.co.jp>
To: Bruno Wolff III <bruno@wolff.to>
Cc: pgsql-admin@postgresql.org
Subject: Re: A quick question about domains
Date: Wed, 26 Nov 2003 14:41:15 +0900
Message-ID: <00a201c3b3df$e84b8c50$7201a8c0@mst1x5r347kymb> (raw)
References: <000901c3b315$47f41710$7201a8c0@mst1x5r347kymb>
	<20031125172606.GB25043@wolff.to>
	<001c01c3b3bb$63ebcd40$7201a8c0@mst1x5r347kymb>
	<20031126052313.GA2524@wolff.to>


 > > Also, this is a rework of an existing system and dates are stored as
> > strings. I don't like it but I'm stuck with it for now. I was hoping to
be
> > able to provide some DB level validation of the dates as 'YYYY-MM-DD'
but I
> > havn't come across a neat way to do it yet. I also hope that domains
might
> > facilitate a smooth change to date type dates someday in the future (in
my
> > dreams, i guess). In the mean time, if anyone knows a 'neat' way to
validate
> > the date strings I'd be happy to hear about it. I got bogged down in
very
> > much over involved (an probably slow) code that couldn't guarantee a
valid
> > date anyway. The date conversion function to_date is far too forgiving
to
> > fulfill this purpose, it seems.
>
> You can use a check constraint with a regular expression. It would look
> something like like:
> check (datecolumnname ~ '^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$')
> That just checks for digits in the right place, it doesn't tightly
> bound the range of the numbers.

Nice idea, I hadn't thought of that. It's somewhat tidier than my original
experiment. I think it's about time I learnt a little more about regular
expressions. I'll check it out.

Thanks for your input, I appreciate it.

Regards
iain




view thread (5+ messages)

Message-ID: <00a201c3b3df$e84b8c50$7201a8c0@mst1x5r347kymb>
Permalink:  ../00a201c3b3df$e84b8c50$7201a8c0@mst1x5r347kymb/
Also on:    postgresql.org/message-id/00a201c3b3df$e84b8c50$7201a8c0@mst1x5r347kymb

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-admin@postgresql.org
  Cc: iain@mst.co.jp, bruno@wolff.to
  Subject: Re: A quick question about domains
  In-Reply-To: <00a201c3b3df$e84b8c50$7201a8c0@mst1x5r347kymb>
  References: <000901c3b315$47f41710$7201a8c0@mst1x5r347kymb> <20031125172606.GB25043@wolff.to> <001c01c3b3bb$63ebcd40$7201a8c0@mst1x5r347kymb> <20031126052313.GA2524@wolff.to> <00a201c3b3df$e84b8c50$7201a8c0@mst1x5r347kymb>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox