Re: [SQLObject] Default Behaviour when notNull == False
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: Brad B. <br...@bb...> - 2003-05-01 12:40:34
|
On 04/30/03 15:54, Ian Bicking wrote: > On Wed, 2003-04-30 at 10:29, Nick wrote: > > On Wed, 2003-04-30 at 08:55, Brad Bollenbach wrote: > > > Can we change the behaviour of this to "feel" more like an SQL insert, > > > so that if a column's allowed to be null, I don't have to specify it > > > in the new()? > > > > This patch should do what you want. Note that I've changed notNull to > > default to True instead of False, because it seems to make more sense to > > do so. If you *don't' specify a keyword argument to new, I would think > > you would *want* to see an error there instead if you didn't > > specifically tell it to not expect one. > > I don't know... just because you don't give a default, you can still use > None for a value (assuming the column allows NULL). > > It was my intention to make the default explicit, even if it isn't > explicit in SQL, so default=None does what Brad wants. I can see why it > would be inconvenient, but only slightly, and I think that's countered > by it being a useful discipline (and more closely matching Python, which > doesn't use implicit defaults). To me: default=None reads essentially "if no value is specified, this column has no value", which is redundant. I think it would be reasonable for SQLObject to internalize the default=None when no default value is specified, in much the same way that I'm always writing functions like: def foo(bar, baz = None): x = bar if baz is not None: .... What do you guys think? -- Brad Bollenbach BBnet.ca |