Commit 77c287e
authored
FIX: validate numeric data for range (upper and lower bound) (#77)
[AB#37475](https://sqlclientdrivers.visualstudio.com/c6d89619-62de-46a0-8b46-70b92a84d85e/_workitems/edit/37475)
This pull request enhances the `BindParameters` function in
`mssql_python/pybind/ddbc_bindings.cpp` by introducing range validation
for various parameter types to ensure data integrity and prevent
out-of-range errors. Below are the key changes grouped by parameter
type:
### Integer Parameter Validations
* **Signed 16-bit integer (`short`)**: Added range validation to ensure
the value is within the limits of a signed 16-bit integer. Throws an
exception if the value is out of range.
* **Unsigned 16-bit integer (`unsigned short`)**: Added validation to
check that the value does not exceed the maximum limit of an unsigned
16-bit integer.
* **Signed 64-bit integer (`int64_t`)**: Introduced range validation to
confirm the value is within the bounds of a signed 64-bit integer.
* **Unsigned 64-bit integer (`uint64_t`)**: Added a check to ensure the
value does not exceed the maximum limit for an unsigned 64-bit integer.
### Date Parameter Validation
* **SQL Server Date Range**: Implemented validation for `year`
attributes in date parameters to ensure they fall within the valid SQL
Server date range (1753-9999).
### Checklist
- [x] **Tests Passed** (if applicable) : All pytests passed.1 parent 05560ef commit 77c287e
1 file changed
+23
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
265 | 265 | | |
266 | 266 | | |
267 | 267 | | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
268 | 273 | | |
269 | 274 | | |
270 | 275 | | |
| |||
274 | 279 | | |
275 | 280 | | |
276 | 281 | | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
277 | 286 | | |
278 | 287 | | |
279 | 288 | | |
| |||
284 | 293 | | |
285 | 294 | | |
286 | 295 | | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
287 | 301 | | |
288 | 302 | | |
289 | 303 | | |
| |||
293 | 307 | | |
294 | 308 | | |
295 | 309 | | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
296 | 315 | | |
297 | 316 | | |
298 | 317 | | |
| |||
318 | 337 | | |
319 | 338 | | |
320 | 339 | | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
321 | 344 | | |
322 | 345 | | |
323 | 346 | | |
| |||
0 commit comments