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

chore(inserter): making the inserter package more efficient #122

Merged
merged 1 commit into from
Feb 17, 2025

Conversation

Jacobbrewer1
Copy link
Owner

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 the validateSQLGen and validateSQLInsert methods, the addition of new helper methods for field checks, and modifications to the genBatch and GenerateSQL methods.

Validation Improvements:

  • inserter/batch.go: Refactored the validateSQLGen and validateSQLInsert methods to use switch 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 the genBatch method and replaced it with calls to the new helper methods. [1] [2]
  • inserter/sql.go: Simplified the GenerateSQL method by optimizing the placeholder generation logic.

Import Adjustments:

  • inserter/batch.go and inserter/sql.go: Adjusted imports to include reflect, slices, and strings where necessary and removed unused imports. [1] [2]

@Jacobbrewer1 Jacobbrewer1 merged commit aefa83f into main Feb 17, 2025
6 checks passed
@Jacobbrewer1 Jacobbrewer1 deleted the chore/inserter-optimise branch February 17, 2025 08:38
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