Skip to content

Commit 18331d8

Browse files
Fixed bug in calculating the connection "thin" attribute.
1 parent 1a00bc0 commit 18331d8

File tree

9 files changed

+32
-20
lines changed

9 files changed

+32
-20
lines changed

doc/src/api_manual/async_connection.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,12 @@ AsyncConnection Attributes
334334

335335
See :ref:`Statement Caching <stmtcache>` for more information.
336336

337+
.. attribute:: AsyncConnection.thin
338+
339+
This read-only attribute returns a boolean indicating if the connection was
340+
established with the python-oracledb Thin mode (True) or python-oracledb
341+
Thick mode (False).
342+
337343
.. attribute:: AsyncConnection.transaction_in_progress
338344

339345
This read-only attribute specifies whether a transaction is currently in

doc/src/api_manual/connection.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -865,8 +865,9 @@ Connection Attributes
865865

866866
.. attribute:: Connection.thin
867867

868-
This read-only attribute returns a boolean indicating if the connection was established
869-
with the python-oracledb Thin mode (True) or python-oracledb Thick mode (False).
868+
This read-only attribute returns a boolean indicating if the connection was
869+
established with the python-oracledb Thin mode (True) or python-oracledb
870+
Thick mode (False).
870871

871872
.. note::
872873

doc/src/release_notes.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ Thin Mode Changes
2929
#) Fixed bug in identifying bind variables in SQL statements containing a
3030
single line comment at the end of the statement.
3131
#) Fixed bug in determining the list of attributes for PL/SQL collections.
32+
#) Fixed bug in calculating the :data:`Connection.thin` attribute.
3233

3334
Thick Mode Changes
3435
++++++++++++++++++

src/oracledb/base_impl.pxd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,7 @@ cdef class PoolParamsImpl(ConnectParamsImpl):
444444

445445
cdef class BaseConnImpl:
446446
cdef:
447+
readonly bint thin
447448
readonly str username
448449
readonly str dsn
449450
readonly str proxy_user

src/oracledb/connection.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,15 @@ def stmtcachesize(self, value: int) -> None:
399399
self._verify_connected()
400400
self._impl.set_stmt_cache_size(value)
401401

402+
@property
403+
def thin(self) -> bool:
404+
"""
405+
Returns a boolean indicating if the connection was established in
406+
python-oracledb's thin mode (True) or thick mode (False).
407+
"""
408+
self._verify_connected()
409+
return self._impl.thin
410+
402411
@property
403412
def transaction_in_progress(self) -> bool:
404413
"""
@@ -998,15 +1007,6 @@ def tag(self, value: str) -> None:
9981007
self._verify_connected()
9991008
self._impl.tag = value
10001009

1001-
@property
1002-
def thin(self) -> bool:
1003-
"""
1004-
Returns a boolean indicating if the connection was established in
1005-
python-oracledb's thin mode (True) or thick mode (False).
1006-
"""
1007-
self._verify_connected()
1008-
return isinstance(self._impl, thin_impl.ThinConnImpl)
1009-
10101010
def tpc_begin(
10111011
self, xid: Xid, flags: int = constants.TPC_BEGIN_NEW, timeout: int = 0
10121012
) -> None:

src/oracledb/impl/thin/connection.pyx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ cdef class BaseThinConnImpl(BaseConnImpl):
7474
if not HAS_CRYPTOGRAPHY:
7575
errors._raise_err(errors.ERR_NO_CRYPTOGRAPHY_PACKAGE)
7676
BaseConnImpl.__init__(self, dsn, params)
77+
self.thin = True
7778

7879
cdef BaseThinLobImpl _create_lob_impl(self, DbType dbtype,
7980
bytes locator=None):

tests/test_1100_connection.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ def test_1100(self):
7373
self.assertEqual(
7474
conn.dsn, test_env.get_connect_string(), "dsn differs"
7575
)
76+
self.assertEqual(conn.thin, test_env.get_is_thin())
7677

7778
@unittest.skipIf(
7879
test_env.get_is_thin(),

tests/test_5300_connection_async.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ async def test_5300(self):
7777
self.assertEqual(
7878
conn.dsn, test_env.get_connect_string(), "dsn differs"
7979
)
80+
self.assertEqual(conn.thin, test_env.get_is_thin())
8081

8182
async def test_5303(self):
8283
"5303 - test connection end-to-end tracing attributes"

utils/templates/connection.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,15 @@ def stmtcachesize(self, value: int) -> None:
397397
self._verify_connected()
398398
self._impl.set_stmt_cache_size(value)
399399

400+
@property
401+
def thin(self) -> bool:
402+
"""
403+
Returns a boolean indicating if the connection was established in
404+
python-oracledb's thin mode (True) or thick mode (False).
405+
"""
406+
self._verify_connected()
407+
return self._impl.thin
408+
400409
@property
401410
def transaction_in_progress(self) -> bool:
402411
"""
@@ -996,15 +1005,6 @@ def tag(self, value: str) -> None:
9961005
self._verify_connected()
9971006
self._impl.tag = value
9981007

999-
@property
1000-
def thin(self) -> bool:
1001-
"""
1002-
Returns a boolean indicating if the connection was established in
1003-
python-oracledb's thin mode (True) or thick mode (False).
1004-
"""
1005-
self._verify_connected()
1006-
return isinstance(self._impl, thin_impl.ThinConnImpl)
1007-
10081008
def tpc_begin(
10091009
self, xid: Xid, flags: int = constants.TPC_BEGIN_NEW, timeout: int = 0
10101010
) -> None:

0 commit comments

Comments
 (0)