initial idea on a dbtool #185
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request introduces several enhancements and refactors to the SQL schema handling, debugging configuration, and type definitions in the codebase. The key changes include adding a new debugging configuration for
vimspector, refactoring schema-related functions to useSqlConnectionfor better encapsulation, introducing a utility function for mapping ODBC data types, and improving type safety in migration plans.Debugging Enhancements:
.vimspector.json: Added a new debugging configuration fordbtoolto enable launching and debugging thedbtoolprogram with predefined arguments and settings.Schema Handling Refactors:
src/Lightweight/SqlSchema.cpp: Refactored schema-related functions (ReadAllTables,AllTables, etc.) to useSqlConnectioninstead of raw database and schema strings for improved encapsulation and clarity. Added logging for SQL execution and ensured cursors are closed after use. [1] [2] [3]src/Lightweight/SqlSchema.hpp: Updated function signatures to reflect the use ofSqlConnectionin schema-related functions. [1] [2]Type Mapping Improvements:
src/Lightweight/SqlColumnTypeDefinitions.hpp: Introduced theMakeColumnTypeFromNativefunction to map ODBC data types toSqlColumnTypeDefinitionin a concise and reusable way. This replaces the previous implementation that was scattered across multiple files.src/Lightweight/SqlSchema.cpp: Replaced the oldFromNativeDataTypeimplementation with the newMakeColumnTypeFromNativeutility for better maintainability and consistency.Migration Plan Improvements:
src/Lightweight/SqlQuery/MigrationPlan.hpp: Changed thetableNamefield inSqlCreateTablePlanfromstd::string_viewtostd::stringto ensure better memory safety and ownership.src/Lightweight/SqlQuery/Migrate.cpp: Updated theCreateTablemethod to reflect the change intableNametype.Logging and Error Handling:
src/Lightweight/SqlConnection.cpp: Added a call toRequireSuccessfor better error handling when establishing a connection.src/Lightweight/SqlSchema.cpp: Added detailed logging for SQL commands and error handling for unsupported data types using the new utility function. [1] [2]These changes improve the maintainability, debugging capabilities, and robustness of the codebase, particularly in handling SQL schema operations and type mappings.