How to handle bogus nulls from ActiveRecord

Поиск
Список
Период
Сортировка
От James B. Byrne
Тема How to handle bogus nulls from ActiveRecord
Дата
Msg-id 34084.216.185.71.25.1305205928.squirrel@webmail.harte-lyne.ca
обсуждение исходный текст
Ответы Re: How to handle bogus nulls from ActiveRecord
Список pgsql-general
It is required for application data verification filters that
default values for table columns are known to ActiveRecord when
creating a new row. So ActiveRecord obtains the default values from
the tables dynamically and assigns them to their appropriate column
attributes.  The problem we encounter arises because ActiveRecord
then uses those column assignments when inserting a row even if the
column is not otherwise referenced.

I am developing a web application using the Ruby on Rails framework
with PostgreSQL as the back-end store.  In one of our tables we have
a column called expected_by which is a time-stamp. It is set to NOT
NULL DEFAULT 'INFINITY'.  However, Ruby has no concept of infinity
and whatever the PostgreSQL adapter is returning for it ActiveRecord
receives as nil which is converted to NULL.

So, the real fix to this is to alter the persistence class so that
columns with default values are not explicitly set to those values
on insert. This is unlikely to happen in the short term and will
take some time to be integrated into the framework even when it is
completed, if ever,

So solve this for the moment what I think I require is a trigger on
expected_at which tests for NULL on insert and converts it to
infinity.  The other alternative is to simply set the default to
some valid, but unreachable, date like 9999-12-31.

I would like other opinions about how to best handle this situation
and observations on what other significant concerns I may not be
aware of but should provide for.

--
***          E-Mail is NOT a SECURE channel          ***
James B. Byrne                mailto:ByrneJB@Harte-Lyne.ca
Harte & Lyne Limited          http://www.harte-lyne.ca
9 Brockley Drive              vox: +1 905 561 1241
Hamilton, Ontario             fax: +1 905 561 0757
Canada  L8E 3C3


В списке pgsql-general по дате отправления:

Предыдущее
От: hubert depesz lubaczewski
Дата:
Сообщение: Re: vacuumdb with cronjob needs password since 9.0?
Следующее
От: Marek Więckowski
Дата:
Сообщение: Re: auto-reconnect: temp schemas, sequences, transactions