Re: [sqlalchemy] possible bug in InstrumentedAttribute.__delete__?

2013-07-14 Thread Wichert Akkerman
On Jul 13, 2013, at 22:59, Michael Bayer mike...@zzzcomputing.com wrote: The original intent of default for Column is that it acts exactly like server_default, except it runs on the Python side for the case that your schema wasn't created with this default, or the functionality of your

Re: [sqlalchemy] possible bug in InstrumentedAttribute.__delete__?

2013-07-14 Thread lars van gemerden
Now i was doing both, but you're right, i can remove the default from the column definition, and just initialise the object with the default in __init__ (from metadata i created elsewhere, but will remain available). Setting the default ASAP (on object creation) seems like the way of least

Re: [sqlalchemy] possible bug in InstrumentedAttribute.__delete__?

2013-07-13 Thread Lars van Gemerden
I think i didn't explain the error enough; just calling del user.name in the example below causes an exception (except when i already accessed (say print user.name) the attribute, which seemed odd to me). This is independent of whether the attr becomes None. Otherwise it isn't a real problem

Re: [sqlalchemy] possible bug in InstrumentedAttribute.__delete__?

2013-07-13 Thread Michael Bayer
On Jul 13, 2013, at 10:24 AM, Lars van Gemerden l...@rational-it.com wrote: I think i didn't explain the error enough; just calling del user.name in the example below causes an exception (except when i already accessed (say print user.name) the attribute, which seemed odd to me). This is

Re: [sqlalchemy] possible bug in InstrumentedAttribute.__delete__?

2013-07-13 Thread Lars van Gemerden
Just trying to help; i am not sure, but what you might also consider is to initialise attributes (or on first access) with a default if a default value as Column argument is given (i am already doing this in my own code) and also reset to this default in case of del, but maybe there are

Re: [sqlalchemy] possible bug in InstrumentedAttribute.__delete__?

2013-07-13 Thread Michael Bayer
On Jul 13, 2013, at 3:21 PM, Lars van Gemerden l...@rational-it.com wrote: Just trying to help; i am not sure, but what you might also consider is to initialise attributes (or on first access) with a default if a default value as Column argument is given (i am already doing this in my own

[sqlalchemy] possible bug in InstrumentedAttribute.__delete__?

2013-07-12 Thread lars van gemerden
Hi all, I had an arror in my code and i think i have reconstructed it as follows: --- from sqlalchemy import Column, Integer, String from sqlalchemy import create_engine from

Re: [sqlalchemy] possible bug in InstrumentedAttribute.__delete__?

2013-07-12 Thread Michael Bayer
We've never supported del obj.attrname as a means of setting an attribute to None (which translates to NULL in SQL). Setting the value to None explicitly is preferred. On Jul 12, 2013, at 12:16 PM, lars van gemerden l...@rational-it.com wrote: Hi all, I had an arror in my code and i

Re: [sqlalchemy] possible bug in InstrumentedAttribute.__delete__?

2013-07-12 Thread Lars van Gemerden
Can i just override __delattr__ in a subclass of a declarative base to achieve this anyway? Cheers, Lars Lars van Gemerden l...@rational-it.com +31 6 26 88 55 39 On 12 jul. 2013, at 18:28, Michael Bayer

Re: [sqlalchemy] possible bug in InstrumentedAttribute.__delete__?

2013-07-12 Thread Lars van Gemerden
After thinking on it some more, should InstrumentedAttribute.__delete__ even exist then, or maybe raise a NotImplementedError? CL Lars van Gemerden l...@rational-it.com +31 6 26 88 55 39 On 12 jul. 2013, at 18:28,

Re: [sqlalchemy] possible bug in InstrumentedAttribute.__delete__?

2013-07-12 Thread Michael Bayer
There's all kinds of things that __delete__ should possibly do, most likely just do what you expect, i.e. set the value to NULL, but this would be changing its behavior in a very backwards-incompatible way; such a change could only be considered for 0.9. Whats not clear is how exactly an