Fixed bug returning metadata of SODA documents inserted into a

collection using saveAndGet().
This commit is contained in:
Anthony Tuininga 2022-09-16 20:19:29 -06:00
parent 92a486cd0d
commit a760c79076
3 changed files with 28 additions and 3 deletions

View File

@ -13,12 +13,15 @@ oracledb 1.2.0b1 (TBD)
Thin Mode Changes
+++++++++++++++++
#) Fixed bug that prevented binding data of types DB_TYPE_ROWID and
DB_TYPE_UROWID.
#) Fixed bug that prevented binding data of types DB_TYPE_ROWID and
DB_TYPE_UROWID.
Thick Mode Changes
++++++++++++++++++
#) Fixed bug returning metadata of SODA documents inserted into a collection
using :meth:`SodaCollection.saveAndGet()`.
Common Changes
++++++++++++++

View File

@ -318,7 +318,7 @@ class SodaCollection:
doc_impl = self._process_doc_arg(doc)
if hint is not None and not isinstance(hint, str):
raise TypeError("expecting a string")
return_doc_impl = self._impl.save(doc_impl, hint, return_doc=False)
return_doc_impl = self._impl.save(doc_impl, hint, return_doc=True)
return SodaDocument._from_impl(return_doc_impl)
def truncate(self) -> None:

View File

@ -446,5 +446,27 @@ class TestCase(test_env.BaseTestCase):
result, = cursor.fetchone()
self.assertTrue(hint in result.read())
def test_3420_save_and_get(self):
"3420 - test saveAndGet"
soda_db = self.get_soda_database(minclient=(19, 9))
coll = soda_db.createCollection("TestSodaSaveAndGet")
coll.find().remove()
values_to_save = [
dict(name="John", age=50),
soda_db.createDocument(dict(name="Mark", age=45)),
soda_db.createDocument(dict(name="Jill", age=32))
]
inserted_keys = []
for value in values_to_save:
doc = coll.saveAndGet(value)
inserted_keys.append(doc.key)
fetched_docs = coll.find().getDocuments()
self.connection.commit()
self.assertEqual(coll.find().count(), len(values_to_save))
for key, fetched_doc in zip(inserted_keys, fetched_docs):
doc = coll.find().key(key).getOne()
self.assertEqual(doc.getContent(), fetched_doc.getContent())
coll.drop()
if __name__ == "__main__":
test_env.run_test_cases()