Login | Register
My pages Projects Community openCollabNet

Discussions > dev > default values behavior question

propel
Discussion topic

Back to topic list

default values behavior question

Reply

Author hlellelid
Full name Hans Lellelid
Date 2007-03-01 11:57:41 PST
Message Another question about default value behavior. As mentioned, I'm
looking into adding support for default value expressions.

I think that everyone of us have seen many users requesting this
feature. It's definitely not uncommon to want a default value that is
an expression (e.g. CURRENT_TIMESTAMP). The fundamental problem with
this, of course, is that these values aren't actually usable in the PHP OM.

So, my thought was ... maybe we simply don't need defaults in the OM.
We're not actually using them to determine whether columns are modified,
anymore, since users also want to be able to set default values on rows
& then save them (so obviously setting a column with a default value has
to still register it as modified).

The only "feature" that Propel would no longer support would be the
ability to use an accessor method to return a column's default value.

Specifically, this would no longer work:
  $o = new ObjectWithDefaultValues();
  $o->getColValWithDefault(); // currently returns the (non-null)
default value

Instead, calls to $o->getColValWithDefault() would now return NULL
(because it hasn't been set).

Obviously this is an API change. I think the question is: is this
change worth the gained benefit of being able to support a much fuller
range of default value options.

I should mention that part of the reason that this is coming up is due
to the incorporation of the DateTime object for internally storing dates
in Propel 1.3. The DateTime object gives us several huge advantages,
primarily that we don't need the BU_* constants anymore for non-epoch
dates. The problem, is that if we actually want the values represented
internally as DateTime objects (as opposed to having to constantly
convert back-and-forth from strings) we cannot support setting
date/time/timestamp default values on the class variables (columns).
... since this is now allowed in PHP:

private $col_with_default_value = new DateTime('string-from-schema')

So, there is a need to re-think how defaults are handled, which made me
look at whether we could move to a more flexible model (basically where
we don't care about defaults in the OM) that could support the
expressions that everyone wants.

Hans

« Previous message in topic | 1 of 15 | Next message in topic »

Messages

Show all messages in topic

default values behavior question hlellelid Hans Lellelid 2007-03-01 11:57:41 PST
     Re: [propel-dev] default values behavior question hlellelid Hans Lellelid 2007-03-01 11:59:15 PST
     Re: [propel-dev] default values behavior question hlellelid Hans Lellelid 2007-03-01 12:32:05 PST
         Re: [propel-dev] default values behavior question Cameron Brunner <cameron dot brunner at gmail dot com> Cameron Brunner <cameron dot brunner at gmail dot com> 2007-03-01 15:53:49 PST
             Re: [propel-dev] default values behavior question hlellelid Hans Lellelid 2007-03-01 19:42:41 PST
     Re: [propel-dev] default values behavior question Alan Pinstein <apinstein at mac dot com> Alan Pinstein <apinstein at mac dot com> 2007-03-09 06:58:18 PST
         Re: [propel-dev] default values behavior question hlellelid Hans Lellelid 2007-03-09 07:14:05 PST
             Re: [propel-dev] default values behavior question Alan Pinstein <apinstein at mac dot com> Alan Pinstein <apinstein at mac dot com> 2007-03-09 08:29:58 PST
                 Re: [propel-dev] default values behavior question hlellelid Hans Lellelid 2007-03-09 09:58:48 PST
                     Re: [propel-dev] default values behavior question Alan Pinstein <apinstein at mac dot com> Alan Pinstein <apinstein at mac dot com> 2007-03-09 11:38:14 PST
                         Re: [propel-dev] default values behavior question hlellelid Hans Lellelid 2007-03-11 09:13:14 PDT
                             Re: [propel-dev] default values behavior question Alan Pinstein <apinstein at mac dot com> Alan Pinstein <apinstein at mac dot com> 2007-03-11 09:24:00 PDT
                                 Re: [propel-dev] default values behavior question =?ISO-8859-1?Q?David_Z=FClke?= <dz at bitxtender dot com> =?ISO-8859-1?Q?David_Z=FClke?= <dz at bitxtender dot com> 2007-03-11 15:45:49 PDT
                                     Re: [propel-dev] default values behavior question Alan Pinstein <apinstein at mac dot com> Alan Pinstein <apinstein at mac dot com> 2007-03-11 17:54:05 PDT
                                         Re: [propel-dev] default values behavior question hlellelid Hans Lellelid 2007-03-11 18:18:22 PDT
Messages per page: