Kent wrote:
>
>> None is going to "update to null". But this is not the same as
>> "empty",
>> i.e. the key isn't present in obj.__dict__ - that will amount to a skip.
>> When you first create the object, the __dict__ is blank as far as values
>> -
>> The "None" only appears there when you first access the scalar
>> attribute.
>>
>> If I were writing SQLA today, perhaps I'd have been a little more
>> draconian-yet-consistent and made non-present attributes raise
>> AttributeError, but this is what we have.
>>
>
> Well, as it is, that *does* allow for more flexibility, I suppose.
>
> As far as 0.5.7, I confirmed the same issue:
you need to flip around where you put the "delete-orphan" rule - see my
previous email on the subject.
>
>
> "AssertionError: Dependency rule tried to blank-out primary key column
> 'orderdetails.orderid' on instance '<OrderDetail at 0x1a757a90>'"
>
>
>
>>>> dbord = session.merge(ord)
> 2010-01-14 03:31:01,807 INFO sqlalchemy.engine.base.Engine.0x...00d0
> BEGIN
> 2010-01-14 03:31:01,808 INFO sqlalchemy.engine.base.Engine.0x...00d0
> SELECT orders.id AS orders_id, orders.customer AS orders_customer
> FROM orders
> WHERE orders.id = :param_1
> 2010-01-14 03:31:01,808 INFO sqlalchemy.engine.base.Engine.0x...00d0
> {'param_1': '55'}
> 2010-01-14 03:31:01,810 INFO sqlalchemy.engine.base.Engine.0x...00d0
> SELECT orderdetails.orderid AS orderdetails_orderid, orderdetails.line
> AS orderdetails_line, orderdetails.product AS orderdetails_product,
> orderdetails.qtyordered AS orderdetails_qtyordered
> FROM orderdetails
> WHERE orderdetails.orderid = :param_1 AND orderdetails.line = :param_2
> 2010-01-14 03:31:01,811 INFO sqlalchemy.engine.base.Engine.0x...00d0
> {'param_1': '55', 'param_2': 2}
> 2010-01-14 03:31:01,883 INFO sqlalchemy.engine.base.Engine.0x...00d0
> SELECT orderdetails.orderid AS orderdetails_orderid, orderdetails.line
> AS orderdetails_line, orderdetails.product AS orderdetails_product,
> orderdetails.qtyordered AS orderdetails_qtyordered
> FROM orderdetails
> WHERE orderdetails.orderid = :param_1 AND orderdetails.line = :param_2
> 2010-01-14 03:31:01,884 INFO sqlalchemy.engine.base.Engine.0x...00d0
> {'param_1': '55', 'param_2': 3}
> 2010-01-14 03:31:01,885 INFO sqlalchemy.engine.base.Engine.0x...00d0
> SELECT orderdetails.orderid AS orderdetails_orderid, orderdetails.line
> AS orderdetails_line, orderdetails.product AS orderdetails_product,
> orderdetails.qtyordered AS orderdetails_qtyordered
> FROM orderdetails
> WHERE :param_1 = orderdetails.orderid
> 2010-01-14 03:31:01,886 INFO sqlalchemy.engine.base.Engine.0x...00d0
> {'param_1': '55'}
>>>>
>>>>
>>>> session.commit()
> 2010-01-14 03:31:13,245 INFO sqlalchemy.engine.base.Engine.0x...00d0
> ROLLBACK
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> File "/home/rarch/trunk/sa057/lib/python2.6/site-packages/
> SQLAlchemy-0.5.7-py2.6.egg/sqlalchemy/orm/session.py", line 671, in
> commit
> self.transaction.commit()
> File "/home/rarch/trunk/sa057/lib/python2.6/site-packages/
> SQLAlchemy-0.5.7-py2.6.egg/sqlalchemy/orm/session.py", line 378, in
> commit
> self._prepare_impl()
> File "/home/rarch/trunk/sa057/lib/python2.6/site-packages/
> SQLAlchemy-0.5.7-py2.6.egg/sqlalchemy/orm/session.py", line 362, in
> _prepare_impl
> self.session.flush()
> File "/home/rarch/trunk/sa057/lib/python2.6/site-packages/
> SQLAlchemy-0.5.7-py2.6.egg/sqlalchemy/orm/session.py", line 1354, in
> flush
> self._flush(objects)
> File "/home/rarch/trunk/sa057/lib/python2.6/site-packages/
> SQLAlchemy-0.5.7-py2.6.egg/sqlalchemy/orm/session.py", line 1432, in
> _flush
> flush_context.execute()
> File "/home/rarch/trunk/sa057/lib/python2.6/site-packages/
> SQLAlchemy-0.5.7-py2.6.egg/sqlalchemy/orm/unitofwork.py", line 261, in
> execute
> UOWExecutor().execute(self, tasks)
> File "/home/rarch/trunk/sa057/lib/python2.6/site-packages/
> SQLAlchemy-0.5.7-py2.6.egg/sqlalchemy/orm/unitofwork.py", line 753, in
> execute
> self.execute_save_steps(trans, task)
> File "/home/rarch/trunk/sa057/lib/python2.6/site-packages/
> SQLAlchemy-0.5.7-py2.6.egg/sqlalchemy/orm/unitofwork.py", line 774, in
> execute_save_steps
> self.execute_dependencies(trans, task)
> File "/home/rarch/trunk/sa057/lib/python2.6/site-packages/
> SQLAlchemy-0.5.7-py2.6.egg/sqlalchemy/orm/unitofwork.py", line 783, in
> execute_dependencies
> self.execute_dependency(trans, dep, False)
> File "/home/rarch/trunk/sa057/lib/python2.6/site-packages/
> SQLAlchemy-0.5.7-py2.6.egg/sqlalchemy/orm/unitofwork.py", line 765, in
> execute_dependency
> dep.execute(trans, isdelete)
> File "/home/rarch/trunk/sa057/lib/python2.6/site-packages/
> SQLAlchemy-0.5.7-py2.6.egg/sqlalchemy/orm/unitofwork.py", line 732, in
> execute
> delete=delete)
> File "/home/rarch/trunk/sa057/lib/python2.6/site-packages/
> SQLAlchemy-0.5.7-py2.6.egg/sqlalchemy/orm/dependency.py", line 369, in
> process_dependencies
> self._synchronize(state, child, None, False, uowcommit)
> File "/home/rarch/trunk/sa057/lib/python2.6/site-packages/
> SQLAlchemy-0.5.7-py2.6.egg/sqlalchemy/orm/dependency.py", line 411, in
> _synchronize
> sync.clear(state, self.parent, self.prop.synchronize_pairs)
> File "/home/rarch/trunk/sa057/lib/python2.6/site-packages/
> SQLAlchemy-0.5.7-py2.6.egg/sqlalchemy/orm/sync.py", line 28, in clear
> raise AssertionError("Dependency rule tried to blank-out primary
> key column '%s' on instance '%s'" % (r, mapperutil.state_str(dest)))
> AssertionError: Dependency rule tried to blank-out primary key column
> 'orderdetails.orderid' on instance '<OrderDetail at 0x1a757a90>'
> --
> You received this message because you are subscribed to the Google Groups
> "sqlalchemy" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/sqlalchemy?hl=en.
>
>
>
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en.