feat(patch): defaulting to snake case naming of the resource object provided if no table name option has been provided #131
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.
Describe your changes
This pull request includes changes to improve the handling of SQL patch generation and testing, as well as updates to the CI workflow configuration. The most important changes include modifying the Go setup in the CI workflow, enhancing the SQL patch generation logic to handle cases where no table name is provided, and adding comprehensive tests for utility functions.
Enhancements to SQL patch generation:
sql.go
: Added logic to set the table name automatically if it is not provided in thepatchGen
method.sql_test.go
: Added new tests to verify the behavior when no table name is provided inTestNewSQLPatch_Success_NoTableProvided
,TestGenerateSQL_Success_NoTableProvided
, andTestNewDiffSQLPatch_Success_SqlGen_NoTableProvided
. [1] [2] [3]Utility function improvements:
utils.go
: EnhanceddereferenceIfPointer
andgetValue
functions to handle nil pointers safely. Added new functionsgetTableName
andtoSnakeCase
to derive table names from struct types. [1] [2] [3]utils_test.go
: Added comprehensive tests for utility functions includingisPointerToStruct
,dereferenceIfPointer
,ensureStruct
,getTag
,getValue
,IsValidType
,getTableName
, andtoSnakeCase
.CI workflow updates:
.github/workflows/ci-code-approval.yml
: Modified the Go setup steps to usego-version-file: 'go.mod'
instead of a hardcoded Go version. [1] [2] [3]