@@ -3151,6 +3151,28 @@ def in_transaction(transaction):
31513151 assert inner_fn_ran is True
31523152
31533153
3154+ @pytest .mark .parametrize ("database" , [None , FIRESTORE_OTHER_DB ], indirect = True )
3155+ def test_transaction_w_uuid (client , cleanup , database ):
3156+ """
3157+ https://github.com/googleapis/python-firestore/issues/1012
3158+ """
3159+ collection_id = "uuid_collection" + UNIQUE_RESOURCE_ID
3160+ doc_ref = client .document (collection_id , "doc" )
3161+ cleanup (doc_ref .delete )
3162+ key = "b7992822-eacb-40be-8af6-559b9e2fb0b7"
3163+ doc_ref .create ({key : "I'm a UUID!" })
3164+
3165+ @firestore .transactional
3166+ def update_doc (tx , doc_ref , key , value ):
3167+ tx .update (doc_ref , {key : value })
3168+
3169+ expected = "UPDATED VALUE"
3170+ update_doc (client .transaction (), doc_ref , key , expected )
3171+ # read updated doc
3172+ snapshot = doc_ref .get ()
3173+ assert snapshot .to_dict ()[key ] == expected
3174+
3175+
31543176@pytest .mark .skipif (
31553177 FIRESTORE_EMULATOR , reason = "Query profile not supported in emulator."
31563178)
@@ -3206,6 +3228,24 @@ def in_transaction(transaction):
32063228 assert inner_fn_ran is True
32073229
32083230
3231+ @pytest .mark .parametrize ("database" , [None , FIRESTORE_OTHER_DB ], indirect = True )
3232+ def test_update_w_uuid (client , cleanup , database ):
3233+ """
3234+ https://github.com/googleapis/python-firestore/issues/1012
3235+ """
3236+ collection_id = "uuid_collection" + UNIQUE_RESOURCE_ID
3237+ doc_ref = client .document (collection_id , "doc" )
3238+ cleanup (doc_ref .delete )
3239+ key = "b7992822-eacb-40be-8af6-559b9e2fb0b7"
3240+ doc_ref .create ({key : "I'm a UUID!" })
3241+
3242+ expected = "UPDATED VALUE"
3243+ doc_ref .update ({key : expected })
3244+ # read updated doc
3245+ snapshot = doc_ref .get ()
3246+ assert snapshot .to_dict ()[key ] == expected
3247+
3248+
32093249@pytest .mark .parametrize ("with_rollback,expected" , [(True , 2 ), (False , 3 )])
32103250@pytest .mark .parametrize ("database" , [None , FIRESTORE_OTHER_DB ], indirect = True )
32113251def test_transaction_rollback (client , cleanup , database , with_rollback , expected ):
0 commit comments