Skip to content

Commit c467c31

Browse files
The error "DPY-2030: LOB offset must be greater than zero" is now raised
when the offset parameter to LOB.read() is zero or negative (#13).
1 parent 60d1bdd commit c467c31

File tree

4 files changed

+12
-0
lines changed

4 files changed

+12
-0
lines changed

doc/src/release_notes.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ Thin Mode Changes
1515

1616
#) Added support for getthing the LOB chunk size
1717
(`issue 14 <https://github.com/oracle/python-oracledb/issues/14>`__).
18+
#) The error `DPY-2030: LOB offset must be greater than zero` is now raised
19+
when the offset parameter to :func:`LOB.read()` is zero or negative
20+
(`issue 13 <https://github.com/oracle/python-oracledb/issues/13>`__).
1821
#) Internally make use of the `TCP_NODELAY` socket option to remove delays
1922
in socket reads.
2023

src/oracledb/errors.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ def _raise_from_string(exc_type: Exception, message: str) -> None:
153153
ERR_INVALID_POOL_PARAMS = 2027
154154
ERR_EXPECTING_LIST_FOR_ARRAY_VAR = 2028
155155
ERR_HTTPS_PROXY_REQUIRES_TCPS = 2029
156+
ERR_INVALID_LOB_OFFSET = 2030
156157

157158
# error numbers that result in NotSupportedError
158159
ERR_TIME_NOT_SUPPORTED = 3000
@@ -306,6 +307,8 @@ def _raise_from_string(exc_type: Exception, message: str) -> None:
306307
'invalid connect descriptor "{data}"',
307308
ERR_INVALID_CONNECT_PARAMS:
308309
'invalid connection params',
310+
ERR_INVALID_LOB_OFFSET:
311+
'LOB offset must be greater than zero',
309312
ERR_INVALID_MAKEDSN_ARG:
310313
'"{name}" argument contains invalid values',
311314
ERR_INVALID_NUMBER:

src/oracledb/lob.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,8 @@ def read(self, offset: int=1, amount: int=None) -> Union[str, bytes]:
113113
amount = amount - offset + 1
114114
else:
115115
amount = 1
116+
if offset <= 0:
117+
errors._raise_err(errors.ERR_INVALID_LOB_OFFSET)
116118
return self._impl.read(offset, amount)
117119

118120
def setfilename(self, dir_alias: str, name: str) -> None:

tests/test_1900_lob_var.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,10 @@ def __test_lob_operations(self, lob_type):
164164
self.assertEqual(lob.size(), 75000)
165165
lob.write(write_value, 75001)
166166
self.assertEqual(lob.size(), 75000 + len(write_value))
167+
self.assertRaisesRegex(oracledb.DatabaseError, "^DPY-2030:",
168+
lob.read, 0)
169+
self.assertRaisesRegex(oracledb.DatabaseError, "^DPY-2030:",
170+
lob.read, -25)
167171
self.assertEqual(lob.read(), long_string + write_value)
168172
lob.write(write_value, 1)
169173
self.assertEqual(lob.read(),

0 commit comments

Comments
 (0)