>In rest/tests/test_users.py you have used
>config.db.store.query(Preferences) inside with. But there is another
>usage of it in line 221 and also in the file model/tests/test_user.py
>which are not inside with block. Any specific reason for the
>difference..?
>
>230 with transaction():
>231 preferences = config.db.store.query(Preferences).filter_by(
>232 id=anne.preferences.id)
>233 self.assertEqual(preferences.count(), 0)
Yes. The ids don't get assigned until after the commit, so they have to be
within the with-statement in order for the subsequent query to work. But
after that, the delete does not require a commit for the query to succeed.
I don't think this was the case with Storm, but it appears to be so with
SQLAlchemy.
On Mar 20, 2015, at 05:41 PM, Abhishek wrote:
>In rest/tests/ test_users. py you have used db.store. query(Preferenc es) inside with. But there is another test_user. py db.store. query(Preferenc es).filter_ by( preferences. id) l(preferences. count() , 0)
>config.
>usage of it in line 221 and also in the file model/tests/
>which are not inside with block. Any specific reason for the
>difference..?
>
>230 with transaction():
>231 preferences = config.
>232 id=anne.
>233 self.assertEqua
Yes. The ids don't get assigned until after the commit, so they have to be
within the with-statement in order for the subsequent query to work. But
after that, the delete does not require a commit for the query to succeed.
I don't think this was the case with Storm, but it appears to be so with
SQLAlchemy.