-
Notifications
You must be signed in to change notification settings - Fork 8
FEAT: Bulk Copy Options #106
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR enhances bulk copy capabilities in the mssql_python
library by extending option classes, tightening validations, adding logging, and introducing comprehensive unit tests.
- Extended
BCPOptions
andColumnFormat
with new fields (query
,terminator_len
,user_data_type
,row_terminator
) and default values. - Added stricter validation with detailed log messages and extracted constants for allowed directions and modes.
- Introduced a new
BCPControlOptions
enum and a full test suite covering valid/invalid cases for bulk copy operations.
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
File | Description |
---|---|
tests/test_007_bulkOptions.py | New tests for BCPOptions and ColumnFormat , covering invalid and edge cases. |
mssql_python/constants.py | Added BCPControlOptions enum for BCP control string constants. |
mssql_python/bcp_options.py | Refactored classes with new fields, logging, validation logic, and constants. |
Comments suppressed due to low confidence (3)
mssql_python/bcp_options.py:14
- [nitpick] The constant name ALLOWED_FILE_MODES may be misleading since it controls bulk_mode. Consider renaming it to ALLOWED_BULK_MODES for clarity.
ALLOWED_FILE_MODES = ("native", "char", "unicode")
mssql_python/bcp_options.py:1
- The module and class docstrings should be updated to document the new fields (
terminator_len
,user_data_type
,query
,row_terminator
) and their purpose for better API clarity.
"""
tests/test_007_bulkOptions.py:297
- Add tests for the 'queryout' direction to verify that supplying a
query
is enforced and that other options behave correctly. Also consider tests forrow_terminator
behavior.
)
ADO Work Item Reference
Summary
This pull request introduces significant updates to the
mssql_python
library, focusing on enhancing theBCPOptions
andColumnFormat
classes, improving error handling, and adding comprehensive unit tests. The changes include refactoring the code for better maintainability, adding logging for debugging, and introducing new features and validations for bulk copy operations.Enhancements to
BCPOptions
andColumnFormat
:BCPOptions
(query
,row_terminator
,bulk_mode
) andColumnFormat
(user_data_type
,terminator_len
) to support additional BCP features. Updated default values for some fields. [1] [2] [3]columns
vs.format_file
). Logging has been added for detailed error messages. [1] [2]Refactoring and Code Simplification:
row_terminator
fromColumnFormat
andwrite_format_file
fromBCPOptions
) to streamline the codebase. [1] [2]direction
andbulk_mode
into constants for better maintainability. [1] [2]New Constants for BCP Options:
BCPControlOptions
enum inconstants.py
to define string representations of BCP control options, improving clarity and consistency.Unit Tests for Bulk Copy Operations:
tests/test_007_bulkOptions.py
) with unit tests forBCPOptions
andColumnFormat
. Tests cover valid instantiations, invalid values, and edge cases such as conflicts betweencolumns
andformat_file
.