Skip to content
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

conditional quoting for database name and bypass syb_db_use() #59

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

LaXKo
Copy link

@LaXKo LaXKo commented Dec 2, 2024

  • Updated database name assignment to add quotes if the name contains a hyphen (-), underscore (_) or dot (.), improving compatibility with database names requiring special handling.
  • Addressed an issue with syb_db_use() truncating database names after 32 characters in ct_command by bypassing the DSN "database" parameter entirely.
  • Added an explicit "USE " statement post-connection to set the database context directly, avoiding truncation issues in Sybase or FreeTDS configurations.

These changes enhance connection stability and ensure proper handling of database names with special characters or length limitations.

- Addressed an issue with syb_db_use() truncating database names after 32chars  in ct_command by bypassing the DSN "database" parameter entirely.
- Instead, added an explicit "USE <database>" statement post-connection, ensuring the correct database context without triggering truncation behavior.

This update improves connection stability and prevents issues with database names exceeding length limits, as encountered in some Sybase or FreeTDS configurations.
…ith length of database-names

Updated database name assignment to add quotes if the name contains a hyphen (-), underscore (_) or dot (.), improving compatibility with database names requiring special handling.
Addressed an issue with syb_db_use() truncating database names after 32 characters in ct_command by bypassing the DSN "database" parameter entirely.
Added an explicit "USE " statement post-connection to set the database context directly, avoiding truncation issues in Sybase or FreeTDS configurations.
These changes enhance connection stability and ensure proper handling of database names with special characters or length limitations.
Copy link

codeautopilot bot commented Dec 2, 2024

PR summary

This Pull Request addresses issues related to database name handling in the Sybase DBI plugin. It introduces conditional quoting for database names containing special characters such as hyphens, underscores, dots, and spaces, ensuring compatibility and stability during connection setup. Additionally, it resolves a problem with the syb_db_use() function truncating database names longer than 32 characters by bypassing the DSN "database" parameter and using an explicit "USE " statement post-connection. These changes enhance the robustness of database connections, particularly in Sybase or FreeTDS configurations, by ensuring proper handling of complex database names and avoiding truncation issues.

Suggestion

Consider adding unit tests to verify the correct handling of database names with various special characters and lengths. This would ensure that the changes work as expected across different scenarios and configurations. Additionally, updating the documentation to reflect these changes would help users understand the new behavior and its benefits.

Disclaimer: This comment was entirely generated using AI. Be aware that the information provided may be incorrect.

Current plan usage: 0.91%

Have feedback or need help?
Discord
Documentation
support@codeautopilot.com

Copy link
Author

@LaXKo LaXKo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wrong parenthesis, it should look like this in line 21:

if (index($self->opts->currentdb, "-") != -1 || index($self->opts->currentdb, ".") != -1 || index($self->opts->currentdb, "_") != -1)

sorry!

LaXKo added 2 commits January 9, 2025 11:58
… handling

- Extended logic for handling database names to include spaces (" ") in the conditional quoting process.
- Updated the condition to account for special characters, including hyphens (-), dots (.), underscores (_), and spaces.
- Database names containing any of these characters are now enclosed in quotes to ensure proper handling during connection setup and queries.
- Names without special characters continue to be passed directly without quotes.

This update ensures robust handling of database names with complex characters, improving compatibility and stability across configurations.
@LaXKo
Copy link
Author

LaXKo commented Jan 9, 2025

Enhance database name handling and fix edge cases in DSN construction: This update is aimed at ensuring flexibility, stability, and correctness in database connections, particularly when dealing with diverse naming conventions.

This update improves the handling of database names in the DSN construction and ensures compatibility with various edge cases. The following enhancements are included:

Support for Special Characters: Database names containing hyphens (-), dots (.), underscores (_), or spaces ( ) are now automatically wrapped in double quotes (") to ensure proper handling during connection setup.

Simplified Logic: The logic for determining when to add quotes around the database name has been streamlined, ensuring it covers all relevant cases while maintaining readability and maintainability.
Robust Edge Case Handling:

Names without special characters are passed as-is, avoiding unnecessary modifications and improving performance for common cases.

Improved Stability: The changes ensure that database names with complex characters or whitespace do not cause connection errors or unexpected behavior, particularly in environments with stricter character handling.

Example Cases Addressed:
"test-database" -> Wrapped in quotes
"test.database" -> Wrapped in quotes
"test_database" -> Wrapped in quotes
"test database" -> Wrapped in quotes
"testDatabase" -> Passed as-is without quotes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant