File tree Expand file tree Collapse file tree 2 files changed +16
-6
lines changed
packages/google-cloud-ndb Expand file tree Collapse file tree 2 files changed +16
-6
lines changed Original file line number Diff line number Diff line change @@ -568,7 +568,7 @@ def _get_commit_batch(transaction, options):
568568 # call would all need to be identical. For now, no options are supported
569569 # here.
570570 for key , value in options .items ():
571- if value :
571+ if key != "transaction" and value :
572572 raise NotImplementedError ("Passed bad option: {!r}" .format (key ))
573573
574574 # Since we're in a transaction, we need to hang on to the batch until
Original file line number Diff line number Diff line change @@ -865,18 +865,28 @@ class SomeKind(ndb.Model):
865865
866866
867867@pytest .mark .usefixtures ("client_context" )
868- def test_get_or_insert_get_in_transaction (ds_entity ):
868+ def test_get_or_insert_in_transaction (dispose_of ):
869+ """Regression test for #433
870+
871+ https://github.com/googleapis/python-ndb/issues/433
872+ """
873+
869874 class SomeKind (ndb .Model ):
870875 foo = ndb .IntegerProperty ()
871876
872877 name = "Inigo Montoya"
873878 assert SomeKind .get_by_id (name ) is None
874879
875- def do_the_thing ():
876- ds_entity (KIND , name , foo = 42 )
877- return SomeKind .get_or_insert (name , foo = 21 )
880+ @ndb .transactional ()
881+ def do_the_thing (foo ):
882+ entity = SomeKind .get_or_insert (name , foo = foo )
883+ return entity
884+
885+ entity = do_the_thing (42 )
886+ dispose_of (entity ._key ._key )
887+ assert entity .foo == 42
878888
879- entity = ndb . transaction ( do_the_thing )
889+ entity = do_the_thing ( 21 )
880890 assert entity .foo == 42
881891
882892
You can’t perform that action at this time.
0 commit comments