Skip to content

Commit f072b8a

Browse files
Rename getIndexes() to listIndexes() to be consistent with the other
SODA implementations.
1 parent 1ffaa7f commit f072b8a

File tree

5 files changed

+33
-36
lines changed

5 files changed

+33
-36
lines changed

doc/src/api_manual/soda.rst

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -217,14 +217,6 @@ SodaCollection Methods
217217
index has been created with the 'dataguide' option enabled. If there are
218218
no documents in the collection, None is returned.
219219

220-
221-
.. method:: SodaCollection.getIndexes()
222-
223-
Returns a list of specifications for the indexes found on the collection.
224-
225-
.. versionadded:: 1.4.0
226-
227-
228220
.. method:: SodaCollection.insertMany(docs)
229221

230222
Inserts a list of documents into the collection at one time. Each of the
@@ -294,6 +286,11 @@ SodaCollection Methods
294286

295287
Use of the ``hint`` parameter requires Oracle Client 21.3 or higher (or Oracle Client 19 from 19.11).
296288

289+
.. method:: SodaCollection.listIndexes()
290+
291+
Returns a list of specifications for the indexes found on the collection.
292+
293+
.. versionadded:: 1.4.0
297294

298295
.. method:: SodaCollection.save(doc)
299296

src/oracledb/impl/thick/odpi.pxd

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1041,9 +1041,6 @@ cdef extern from "impl/thick/odpi/embed/dpi.c":
10411041
const dpiSodaOperOptions *options, uint32_t flags,
10421042
uint64_t *count) nogil
10431043

1044-
int dpiSodaColl_getIndexes(dpiSodaColl *coll, uint32_t flags,
1045-
dpiStringList *lst) nogil
1046-
10471044
int dpiSodaColl_getMetadata(dpiSodaColl *coll, const char **value,
10481045
uint32_t *valueLength) nogil
10491046

@@ -1058,6 +1055,9 @@ cdef extern from "impl/thick/odpi/embed/dpi.c":
10581055
dpiSodaOperOptions *options, uint32_t flags,
10591056
dpiSodaDoc **insertedDoc) nogil
10601057

1058+
int dpiSodaColl_listIndexes(dpiSodaColl *coll, uint32_t flags,
1059+
dpiStringList *lst) nogil
1060+
10611061
int dpiSodaColl_release(dpiSodaColl *coll) nogil
10621062

10631063
int dpiSodaColl_remove(dpiSodaColl *coll,

src/oracledb/impl/thick/soda.pyx

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -272,21 +272,6 @@ cdef class ThickSodaCollImpl(BaseSodaCollImpl):
272272
if doc_impl._handle != NULL:
273273
return doc_impl
274274

275-
def get_indexes(self):
276-
"""
277-
Internal method for getting the list of indexes on a collection.
278-
"""
279-
cdef:
280-
dpiStringList indexes
281-
uint32_t flags
282-
int status
283-
self._db_impl._get_flags(&flags)
284-
with nogil:
285-
status = dpiSodaColl_getIndexes(self._handle, flags, &indexes)
286-
if status < 0:
287-
_raise_from_odpi()
288-
return _string_list_to_python(&indexes)
289-
290275
def get_metadata(self):
291276
"""
292277
Internal method for getting the metadata for a collection.
@@ -389,6 +374,21 @@ cdef class ThickSodaCollImpl(BaseSodaCollImpl):
389374
if return_doc:
390375
return output_doc_impl
391376

377+
def list_indexes(self):
378+
"""
379+
Internal method for getting the list of indexes on a collection.
380+
"""
381+
cdef:
382+
dpiStringList indexes
383+
uint32_t flags
384+
int status
385+
self._db_impl._get_flags(&flags)
386+
with nogil:
387+
status = dpiSodaColl_listIndexes(self._handle, flags, &indexes)
388+
if status < 0:
389+
_raise_from_odpi()
390+
return _string_list_to_python(&indexes)
391+
392392
def remove(self, object op):
393393
"""
394394
Internal method for removing all of the documents matching the

src/oracledb/soda.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -214,12 +214,6 @@ def getDataGuide(self) -> "SodaDocument":
214214
if doc_impl is not None:
215215
return SodaDocument._from_impl(doc_impl)
216216

217-
def getIndexes(self) -> list:
218-
"""
219-
Return a list of indexes associated with the collection.
220-
"""
221-
return [json.loads(s) for s in self._impl.get_indexes()]
222-
223217
def insertMany(self, docs: list) -> None:
224218
"""
225219
Inserts a list of documents into the collection at one time. Each of
@@ -281,6 +275,12 @@ def insertOneAndGet(self, doc: Any, hint: str=None) -> "SodaDocument":
281275
return_doc=True)
282276
return SodaDocument._from_impl(return_doc_impl)
283277

278+
def listIndexes(self) -> list:
279+
"""
280+
Return a list of indexes associated with the collection.
281+
"""
282+
return [json.loads(s) for s in self._impl.list_indexes()]
283+
284284
@property
285285
def metadata(self) -> dict:
286286
"""

tests/test_3400_soda_collection.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -632,9 +632,9 @@ def test_3428_fetch_array_size(self):
632632
def test_3429_getting_indexes(self):
633633
"3429 - test getting indexes on a collection"
634634
soda_db = self.get_soda_database()
635-
coll = soda_db.createCollection("TestSodaGetIndexes")
635+
coll = soda_db.createCollection("TestSodaListIndexes")
636636
coll.drop()
637-
coll = soda_db.createCollection("TestSodaGetIndexes")
637+
coll = soda_db.createCollection("TestSodaListIndexes")
638638
index_1 = {
639639
'name': 'ix_3428-1',
640640
'fields': [
@@ -655,10 +655,10 @@ def test_3429_getting_indexes(self):
655655
}
656656
]
657657
}
658-
self.assertEqual(coll.getIndexes(), [])
658+
self.assertEqual(coll.listIndexes(), [])
659659
coll.createIndex(index_1)
660660
coll.createIndex(index_2)
661-
indexes = coll.getIndexes()
661+
indexes = coll.listIndexes()
662662
indexes.sort(key=lambda x: x["name"])
663663
self.assertEqual(indexes[0]["fields"][0]["path"], "address.city")
664664
self.assertEqual(indexes[1]["fields"][0]["path"], "address.postal_code")

0 commit comments

Comments
 (0)