chore(inserter): making the inserter package more efficient #122
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 several changes to the
inserter
package, focusing on improving the validation logic and refactoring the code for better readability and maintainability. The most important changes include updates to thevalidateSQLGen
andvalidateSQLInsert
methods, the addition of new helper methods for field checks, and modifications to thegenBatch
andGenerateSQL
methods.Validation Improvements:
inserter/batch.go
: Refactored thevalidateSQLGen
andvalidateSQLInsert
methods to useswitch
statements for better readability and maintainability.Helper Methods for Field Checks:
inserter/batch.go
: Added new helper methods (checkSkipField
,checkSkipTag
,checkPrimaryKey
,ignoredFieldsCheck
,checkIgnoreFunc
,checkIgnoredFields
) to centralize and simplify field validation logic.Refactoring and Code Simplification:
inserter/sql.go
: Removed redundant field validation logic from thegenBatch
method and replaced it with calls to the new helper methods. [1] [2]inserter/sql.go
: Simplified theGenerateSQL
method by optimizing the placeholder generation logic.Import Adjustments:
inserter/batch.go
andinserter/sql.go
: Adjusted imports to includereflect
,slices
, andstrings
where necessary and removed unused imports. [1] [2]