Skip to content

loader: custom delimiter for SQL Server #66

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

Merged
merged 1 commit into from
May 21, 2025
Merged

Conversation

giautm
Copy link
Member

@giautm giautm commented May 21, 2025

No description provided.

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds support for custom SQL statement delimiters (notably “GO” for SQL Server) in the loader and updates related tests and templates.

  • Introduce WithStmtDelimiter option and integrate delimiter handling in Loader.Load
  • Update loader.tmpl to pass the custom delimiter for SQL Server
  • Adjust tests and test data (*.sql files) to cover SQL Server delimiter behavior

Reviewed Changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
main.go Added delimiter field, WithStmtDelimiter option, and updated Load logic to append delimiters
main_test.go Extended tests for SQL Server, sanitized working directory paths, and updated file extensions
loader.tmpl Conditional template injection of WithStmtDelimiter("\nGO") for SQL Server
gormschema/gorm.go Implemented delimiter support in loader and refactored view creation
gormschema/gorm_test.go Updated expected test file names to include .sql suffix
gormschema/testdata/*.sql Updated SQL Server test data to include GO delimiters
Comments suppressed due to low confidence (2)

main.go:103

  • Using a fixed directory .gormschema can cause collisions or leftover state during concurrent runs. Consider using os.MkdirTemp to create an isolated temporary directory and clean it up afterwards.
defer os.RemoveAll(".gormschema")

main_test.go:35

  • [nitpick] The working-directory lookup and error check are repeated in multiple tests. Extract this into a helper function or test setup to reduce duplication.
cwd, err := os.Getwd()

@giautm giautm force-pushed the g/sql-server-delimiter branch from 8717278 to 9c30061 Compare May 21, 2025 12:06
@giautm giautm force-pushed the g/sql-server-delimiter branch from 1e8a31f to a2d9d3b Compare May 21, 2025 12:08
@giautm giautm requested a review from a8m May 21, 2025 12:41
@giautm giautm merged commit 818eb3a into master May 21, 2025
10 checks passed
@giautm giautm deleted the g/sql-server-delimiter branch May 21, 2025 13:07
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.

2 participants