Обсуждение: BUG #2418: number & date & time

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

BUG #2418: number & date & time

От
"James"
Дата:
The following bug has been logged online:

Bug reference:      2418
Logged by:          James
Email address:      james@mercstudio.com
PostgreSQL version: 8.1
Operating system:   Microsoft Windows XP Professional
Description:        number & date & time
Details:

hi,

we would like to have convinience data conversion from datatype number of
value '' as null and datatype date / timestamp / timestampz of value '' as
null...

so far, postgresql will reject those value for number and date / time field
when it's empty string '' (as invalid date value or invalid number value)

it would be nice to have it auto converted :)

Re: BUG #2418: number & date & time

От
Bruno Wolff III
Дата:
On Tue, May 02, 2006 at 10:36:52 +0000,
  James <james@mercstudio.com> wrote:
>
> we would like to have convinience data conversion from datatype number of
> value '' as null and datatype date / timestamp / timestampz of value '' as
> null...
>
> so far, postgresql will reject those value for number and date / time field
> when it's empty string '' (as invalid date value or invalid number value)
>
> it would be nice to have it auto converted :)

This isn't a bug and you should have asked this question on another list
(sql, general or novice would all be appropiate).
This isn't easy for you to do in Postgres as data validation is done before
before triggers activate.
I can think of a couple of things to do. One would be to change your app or
add a filter so that NULL is sent instead of ''. Another apporach would be
to read in the data as text with a function that converts the string to date
with the special feature of '' being converted to null. Your function should
be able to call the function used to input dates, so you don't need to do
a lot of hard work there. But depending on how you are inputting the data,
it may not be easy to make this fit an existing app.