Compare commits
17 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5fb09b78c3 | ||
| 5d9770b430 | |||
| f2d500f98d | |||
| 2ec9991324 | |||
| a3e45c206d | |||
| 165623bb1d | |||
| 3c20c3c5d9 | |||
| a54594e49b | |||
| cafe6a461f | |||
| abdb9b4c78 | |||
| e7a15c8e4f | |||
| c36b5ede2b | |||
| 51ab29f8e3 | |||
| f532fc110c | |||
| 92dff99725 | |||
| 283b568adb | |||
| 122743ee43 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -47,3 +47,4 @@ dist/
|
|||||||
build/
|
build/
|
||||||
bin/
|
bin/
|
||||||
tests/integration/failed_statements_example.txt
|
tests/integration/failed_statements_example.txt
|
||||||
|
test_output.log
|
||||||
|
|||||||
@@ -38,13 +38,14 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
convertSourceType string
|
convertSourceType string
|
||||||
convertSourcePath string
|
convertSourcePath string
|
||||||
convertSourceConn string
|
convertSourceConn string
|
||||||
convertTargetType string
|
convertTargetType string
|
||||||
convertTargetPath string
|
convertTargetPath string
|
||||||
convertPackageName string
|
convertPackageName string
|
||||||
convertSchemaFilter string
|
convertSchemaFilter string
|
||||||
|
convertFlattenSchema bool
|
||||||
)
|
)
|
||||||
|
|
||||||
var convertCmd = &cobra.Command{
|
var convertCmd = &cobra.Command{
|
||||||
@@ -148,6 +149,7 @@ func init() {
|
|||||||
convertCmd.Flags().StringVar(&convertTargetPath, "to-path", "", "Target output path (file or directory)")
|
convertCmd.Flags().StringVar(&convertTargetPath, "to-path", "", "Target output path (file or directory)")
|
||||||
convertCmd.Flags().StringVar(&convertPackageName, "package", "", "Package name (for code generation formats like gorm/bun)")
|
convertCmd.Flags().StringVar(&convertPackageName, "package", "", "Package name (for code generation formats like gorm/bun)")
|
||||||
convertCmd.Flags().StringVar(&convertSchemaFilter, "schema", "", "Filter to a specific schema by name (required for formats like dctx that only support single schemas)")
|
convertCmd.Flags().StringVar(&convertSchemaFilter, "schema", "", "Filter to a specific schema by name (required for formats like dctx that only support single schemas)")
|
||||||
|
convertCmd.Flags().BoolVar(&convertFlattenSchema, "flatten-schema", false, "Flatten schema.table names to schema_table (useful for databases like SQLite that do not support schemas)")
|
||||||
|
|
||||||
err := convertCmd.MarkFlagRequired("from")
|
err := convertCmd.MarkFlagRequired("from")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -202,7 +204,7 @@ func runConvert(cmd *cobra.Command, args []string) error {
|
|||||||
fmt.Fprintf(os.Stderr, " Schema: %s\n", convertSchemaFilter)
|
fmt.Fprintf(os.Stderr, " Schema: %s\n", convertSchemaFilter)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := writeDatabase(db, convertTargetType, convertTargetPath, convertPackageName, convertSchemaFilter); err != nil {
|
if err := writeDatabase(db, convertTargetType, convertTargetPath, convertPackageName, convertSchemaFilter, convertFlattenSchema); err != nil {
|
||||||
return fmt.Errorf("failed to write target: %w", err)
|
return fmt.Errorf("failed to write target: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -301,12 +303,13 @@ func readDatabaseForConvert(dbType, filePath, connString string) (*models.Databa
|
|||||||
return db, nil
|
return db, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func writeDatabase(db *models.Database, dbType, outputPath, packageName, schemaFilter string) error {
|
func writeDatabase(db *models.Database, dbType, outputPath, packageName, schemaFilter string, flattenSchema bool) error {
|
||||||
var writer writers.Writer
|
var writer writers.Writer
|
||||||
|
|
||||||
writerOpts := &writers.WriterOptions{
|
writerOpts := &writers.WriterOptions{
|
||||||
OutputPath: outputPath,
|
OutputPath: outputPath,
|
||||||
PackageName: packageName,
|
PackageName: packageName,
|
||||||
|
FlattenSchema: flattenSchema,
|
||||||
}
|
}
|
||||||
|
|
||||||
switch strings.ToLower(dbType) {
|
switch strings.ToLower(dbType) {
|
||||||
|
|||||||
@@ -55,6 +55,8 @@ var (
|
|||||||
mergeSkipSequences bool
|
mergeSkipSequences bool
|
||||||
mergeSkipTables string // Comma-separated table names to skip
|
mergeSkipTables string // Comma-separated table names to skip
|
||||||
mergeVerbose bool
|
mergeVerbose bool
|
||||||
|
mergeReportPath string // Path to write merge report
|
||||||
|
mergeFlattenSchema bool
|
||||||
)
|
)
|
||||||
|
|
||||||
var mergeCmd = &cobra.Command{
|
var mergeCmd = &cobra.Command{
|
||||||
@@ -78,6 +80,12 @@ Examples:
|
|||||||
--source pgsql --source-conn "postgres://user:pass@localhost/source_db" \
|
--source pgsql --source-conn "postgres://user:pass@localhost/source_db" \
|
||||||
--output json --output-path combined.json
|
--output json --output-path combined.json
|
||||||
|
|
||||||
|
# Merge and execute on PostgreSQL database with report
|
||||||
|
relspec merge --target json --target-path base.json \
|
||||||
|
--source json --source-path additional.json \
|
||||||
|
--output pgsql --output-conn "postgres://user:pass@localhost/target_db" \
|
||||||
|
--merge-report merge-report.json
|
||||||
|
|
||||||
# Merge DBML and YAML, skip relations
|
# Merge DBML and YAML, skip relations
|
||||||
relspec merge --target dbml --target-path schema.dbml \
|
relspec merge --target dbml --target-path schema.dbml \
|
||||||
--source yaml --source-path tables.yaml \
|
--source yaml --source-path tables.yaml \
|
||||||
@@ -115,6 +123,8 @@ func init() {
|
|||||||
mergeCmd.Flags().BoolVar(&mergeSkipSequences, "skip-sequences", false, "Skip sequences during merge")
|
mergeCmd.Flags().BoolVar(&mergeSkipSequences, "skip-sequences", false, "Skip sequences during merge")
|
||||||
mergeCmd.Flags().StringVar(&mergeSkipTables, "skip-tables", "", "Comma-separated list of table names to skip during merge")
|
mergeCmd.Flags().StringVar(&mergeSkipTables, "skip-tables", "", "Comma-separated list of table names to skip during merge")
|
||||||
mergeCmd.Flags().BoolVar(&mergeVerbose, "verbose", false, "Show verbose output")
|
mergeCmd.Flags().BoolVar(&mergeVerbose, "verbose", false, "Show verbose output")
|
||||||
|
mergeCmd.Flags().StringVar(&mergeReportPath, "merge-report", "", "Path to write merge report (JSON format)")
|
||||||
|
mergeCmd.Flags().BoolVar(&mergeFlattenSchema, "flatten-schema", false, "Flatten schema.table names to schema_table (useful for databases like SQLite that do not support schemas)")
|
||||||
}
|
}
|
||||||
|
|
||||||
func runMerge(cmd *cobra.Command, args []string) error {
|
func runMerge(cmd *cobra.Command, args []string) error {
|
||||||
@@ -229,7 +239,7 @@ func runMerge(cmd *cobra.Command, args []string) error {
|
|||||||
fmt.Fprintf(os.Stderr, " Path: %s\n", mergeOutputPath)
|
fmt.Fprintf(os.Stderr, " Path: %s\n", mergeOutputPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
err = writeDatabaseForMerge(mergeOutputType, mergeOutputPath, "", targetDB, "Output")
|
err = writeDatabaseForMerge(mergeOutputType, mergeOutputPath, mergeOutputConn, targetDB, "Output", mergeFlattenSchema)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to write output: %w", err)
|
return fmt.Errorf("failed to write output: %w", err)
|
||||||
}
|
}
|
||||||
@@ -316,7 +326,7 @@ func readDatabaseForMerge(dbType, filePath, connString, label string) (*models.D
|
|||||||
return db, nil
|
return db, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func writeDatabaseForMerge(dbType, filePath, connString string, db *models.Database, label string) error {
|
func writeDatabaseForMerge(dbType, filePath, connString string, db *models.Database, label string, flattenSchema bool) error {
|
||||||
var writer writers.Writer
|
var writer writers.Writer
|
||||||
|
|
||||||
switch strings.ToLower(dbType) {
|
switch strings.ToLower(dbType) {
|
||||||
@@ -324,59 +334,69 @@ func writeDatabaseForMerge(dbType, filePath, connString string, db *models.Datab
|
|||||||
if filePath == "" {
|
if filePath == "" {
|
||||||
return fmt.Errorf("%s: file path is required for DBML format", label)
|
return fmt.Errorf("%s: file path is required for DBML format", label)
|
||||||
}
|
}
|
||||||
writer = wdbml.NewWriter(&writers.WriterOptions{OutputPath: filePath})
|
writer = wdbml.NewWriter(&writers.WriterOptions{OutputPath: filePath, FlattenSchema: flattenSchema})
|
||||||
case "dctx":
|
case "dctx":
|
||||||
if filePath == "" {
|
if filePath == "" {
|
||||||
return fmt.Errorf("%s: file path is required for DCTX format", label)
|
return fmt.Errorf("%s: file path is required for DCTX format", label)
|
||||||
}
|
}
|
||||||
writer = wdctx.NewWriter(&writers.WriterOptions{OutputPath: filePath})
|
writer = wdctx.NewWriter(&writers.WriterOptions{OutputPath: filePath, FlattenSchema: flattenSchema})
|
||||||
case "drawdb":
|
case "drawdb":
|
||||||
if filePath == "" {
|
if filePath == "" {
|
||||||
return fmt.Errorf("%s: file path is required for DrawDB format", label)
|
return fmt.Errorf("%s: file path is required for DrawDB format", label)
|
||||||
}
|
}
|
||||||
writer = wdrawdb.NewWriter(&writers.WriterOptions{OutputPath: filePath})
|
writer = wdrawdb.NewWriter(&writers.WriterOptions{OutputPath: filePath, FlattenSchema: flattenSchema})
|
||||||
case "graphql":
|
case "graphql":
|
||||||
if filePath == "" {
|
if filePath == "" {
|
||||||
return fmt.Errorf("%s: file path is required for GraphQL format", label)
|
return fmt.Errorf("%s: file path is required for GraphQL format", label)
|
||||||
}
|
}
|
||||||
writer = wgraphql.NewWriter(&writers.WriterOptions{OutputPath: filePath})
|
writer = wgraphql.NewWriter(&writers.WriterOptions{OutputPath: filePath, FlattenSchema: flattenSchema})
|
||||||
case "json":
|
case "json":
|
||||||
if filePath == "" {
|
if filePath == "" {
|
||||||
return fmt.Errorf("%s: file path is required for JSON format", label)
|
return fmt.Errorf("%s: file path is required for JSON format", label)
|
||||||
}
|
}
|
||||||
writer = wjson.NewWriter(&writers.WriterOptions{OutputPath: filePath})
|
writer = wjson.NewWriter(&writers.WriterOptions{OutputPath: filePath, FlattenSchema: flattenSchema})
|
||||||
case "yaml":
|
case "yaml":
|
||||||
if filePath == "" {
|
if filePath == "" {
|
||||||
return fmt.Errorf("%s: file path is required for YAML format", label)
|
return fmt.Errorf("%s: file path is required for YAML format", label)
|
||||||
}
|
}
|
||||||
writer = wyaml.NewWriter(&writers.WriterOptions{OutputPath: filePath})
|
writer = wyaml.NewWriter(&writers.WriterOptions{OutputPath: filePath, FlattenSchema: flattenSchema})
|
||||||
case "gorm":
|
case "gorm":
|
||||||
if filePath == "" {
|
if filePath == "" {
|
||||||
return fmt.Errorf("%s: file path is required for GORM format", label)
|
return fmt.Errorf("%s: file path is required for GORM format", label)
|
||||||
}
|
}
|
||||||
writer = wgorm.NewWriter(&writers.WriterOptions{OutputPath: filePath})
|
writer = wgorm.NewWriter(&writers.WriterOptions{OutputPath: filePath, FlattenSchema: flattenSchema})
|
||||||
case "bun":
|
case "bun":
|
||||||
if filePath == "" {
|
if filePath == "" {
|
||||||
return fmt.Errorf("%s: file path is required for Bun format", label)
|
return fmt.Errorf("%s: file path is required for Bun format", label)
|
||||||
}
|
}
|
||||||
writer = wbun.NewWriter(&writers.WriterOptions{OutputPath: filePath})
|
writer = wbun.NewWriter(&writers.WriterOptions{OutputPath: filePath, FlattenSchema: flattenSchema})
|
||||||
case "drizzle":
|
case "drizzle":
|
||||||
if filePath == "" {
|
if filePath == "" {
|
||||||
return fmt.Errorf("%s: file path is required for Drizzle format", label)
|
return fmt.Errorf("%s: file path is required for Drizzle format", label)
|
||||||
}
|
}
|
||||||
writer = wdrizzle.NewWriter(&writers.WriterOptions{OutputPath: filePath})
|
writer = wdrizzle.NewWriter(&writers.WriterOptions{OutputPath: filePath, FlattenSchema: flattenSchema})
|
||||||
case "prisma":
|
case "prisma":
|
||||||
if filePath == "" {
|
if filePath == "" {
|
||||||
return fmt.Errorf("%s: file path is required for Prisma format", label)
|
return fmt.Errorf("%s: file path is required for Prisma format", label)
|
||||||
}
|
}
|
||||||
writer = wprisma.NewWriter(&writers.WriterOptions{OutputPath: filePath})
|
writer = wprisma.NewWriter(&writers.WriterOptions{OutputPath: filePath, FlattenSchema: flattenSchema})
|
||||||
case "typeorm":
|
case "typeorm":
|
||||||
if filePath == "" {
|
if filePath == "" {
|
||||||
return fmt.Errorf("%s: file path is required for TypeORM format", label)
|
return fmt.Errorf("%s: file path is required for TypeORM format", label)
|
||||||
}
|
}
|
||||||
writer = wtypeorm.NewWriter(&writers.WriterOptions{OutputPath: filePath})
|
writer = wtypeorm.NewWriter(&writers.WriterOptions{OutputPath: filePath, FlattenSchema: flattenSchema})
|
||||||
case "pgsql":
|
case "pgsql":
|
||||||
writer = wpgsql.NewWriter(&writers.WriterOptions{OutputPath: filePath})
|
writerOpts := &writers.WriterOptions{OutputPath: filePath, FlattenSchema: flattenSchema}
|
||||||
|
if connString != "" {
|
||||||
|
writerOpts.Metadata = map[string]interface{}{
|
||||||
|
"connection_string": connString,
|
||||||
|
}
|
||||||
|
// Add report path if merge report is enabled
|
||||||
|
if mergeReportPath != "" {
|
||||||
|
writerOpts.Metadata["report_path"] = mergeReportPath
|
||||||
|
}
|
||||||
|
}
|
||||||
|
writer = wpgsql.NewWriter(writerOpts)
|
||||||
default:
|
default:
|
||||||
return fmt.Errorf("%s: unsupported format '%s'", label, dbType)
|
return fmt.Errorf("%s: unsupported format '%s'", label, dbType)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,10 +14,11 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
scriptsDir string
|
scriptsDir string
|
||||||
scriptsConn string
|
scriptsConn string
|
||||||
scriptsSchemaName string
|
scriptsSchemaName string
|
||||||
scriptsDBName string
|
scriptsDBName string
|
||||||
|
scriptsIgnoreErrors bool
|
||||||
)
|
)
|
||||||
|
|
||||||
var scriptsCmd = &cobra.Command{
|
var scriptsCmd = &cobra.Command{
|
||||||
@@ -39,8 +40,8 @@ Example filenames (hyphen format):
|
|||||||
1-002-create-posts.sql # Priority 1, Sequence 2
|
1-002-create-posts.sql # Priority 1, Sequence 2
|
||||||
10-10-create-newid.pgsql # Priority 10, Sequence 10
|
10-10-create-newid.pgsql # Priority 10, Sequence 10
|
||||||
|
|
||||||
Both formats can be mixed in the same directory.
|
Both formats can be mixed in the same directory and subdirectories.
|
||||||
Scripts are executed in order: Priority (ascending), then Sequence (ascending).`,
|
Scripts are executed in order: Priority (ascending), Sequence (ascending), Name (alphabetical).`,
|
||||||
}
|
}
|
||||||
|
|
||||||
var scriptsListCmd = &cobra.Command{
|
var scriptsListCmd = &cobra.Command{
|
||||||
@@ -48,8 +49,8 @@ var scriptsListCmd = &cobra.Command{
|
|||||||
Short: "List SQL scripts from a directory",
|
Short: "List SQL scripts from a directory",
|
||||||
Long: `List SQL scripts from a directory and show their execution order.
|
Long: `List SQL scripts from a directory and show their execution order.
|
||||||
|
|
||||||
The scripts are read from the specified directory and displayed in the order
|
The scripts are read recursively from the specified directory and displayed in the order
|
||||||
they would be executed (Priority ascending, then Sequence ascending).
|
they would be executed: Priority (ascending), then Sequence (ascending), then Name (alphabetical).
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
relspec scripts list --dir ./migrations`,
|
relspec scripts list --dir ./migrations`,
|
||||||
@@ -61,10 +62,10 @@ var scriptsExecuteCmd = &cobra.Command{
|
|||||||
Short: "Execute SQL scripts against a database",
|
Short: "Execute SQL scripts against a database",
|
||||||
Long: `Execute SQL scripts from a directory against a PostgreSQL database.
|
Long: `Execute SQL scripts from a directory against a PostgreSQL database.
|
||||||
|
|
||||||
Scripts are executed in order: Priority (ascending), then Sequence (ascending).
|
Scripts are executed in order: Priority (ascending), Sequence (ascending), Name (alphabetical).
|
||||||
Execution stops immediately on the first error.
|
By default, execution stops immediately on the first error. Use --ignore-errors to continue execution.
|
||||||
|
|
||||||
The directory is scanned recursively for files matching the patterns:
|
The directory is scanned recursively for all subdirectories and files matching the patterns:
|
||||||
{priority}_{sequence}_{name}.sql or .pgsql (underscore format)
|
{priority}_{sequence}_{name}.sql or .pgsql (underscore format)
|
||||||
{priority}-{sequence}-{name}.sql or .pgsql (hyphen format)
|
{priority}-{sequence}-{name}.sql or .pgsql (hyphen format)
|
||||||
|
|
||||||
@@ -75,7 +76,7 @@ PostgreSQL Connection String Examples:
|
|||||||
postgresql://user:pass@host/dbname?sslmode=require
|
postgresql://user:pass@host/dbname?sslmode=require
|
||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
# Execute migration scripts
|
# Execute migration scripts from a directory (including subdirectories)
|
||||||
relspec scripts execute --dir ./migrations \
|
relspec scripts execute --dir ./migrations \
|
||||||
--conn "postgres://user:pass@localhost:5432/mydb"
|
--conn "postgres://user:pass@localhost:5432/mydb"
|
||||||
|
|
||||||
@@ -86,7 +87,12 @@ Examples:
|
|||||||
|
|
||||||
# Execute with SSL disabled
|
# Execute with SSL disabled
|
||||||
relspec scripts execute --dir ./sql \
|
relspec scripts execute --dir ./sql \
|
||||||
--conn "postgres://user:pass@localhost/db?sslmode=disable"`,
|
--conn "postgres://user:pass@localhost/db?sslmode=disable"
|
||||||
|
|
||||||
|
# Continue executing even if errors occur
|
||||||
|
relspec scripts execute --dir ./migrations \
|
||||||
|
--conn "postgres://localhost/mydb" \
|
||||||
|
--ignore-errors`,
|
||||||
RunE: runScriptsExecute,
|
RunE: runScriptsExecute,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -105,6 +111,7 @@ func init() {
|
|||||||
scriptsExecuteCmd.Flags().StringVar(&scriptsConn, "conn", "", "PostgreSQL connection string (required)")
|
scriptsExecuteCmd.Flags().StringVar(&scriptsConn, "conn", "", "PostgreSQL connection string (required)")
|
||||||
scriptsExecuteCmd.Flags().StringVar(&scriptsSchemaName, "schema", "public", "Schema name (optional, default: public)")
|
scriptsExecuteCmd.Flags().StringVar(&scriptsSchemaName, "schema", "public", "Schema name (optional, default: public)")
|
||||||
scriptsExecuteCmd.Flags().StringVar(&scriptsDBName, "database", "database", "Database name (optional, default: database)")
|
scriptsExecuteCmd.Flags().StringVar(&scriptsDBName, "database", "database", "Database name (optional, default: database)")
|
||||||
|
scriptsExecuteCmd.Flags().BoolVar(&scriptsIgnoreErrors, "ignore-errors", false, "Continue executing scripts even if errors occur")
|
||||||
|
|
||||||
err = scriptsExecuteCmd.MarkFlagRequired("dir")
|
err = scriptsExecuteCmd.MarkFlagRequired("dir")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -149,7 +156,7 @@ func runScriptsList(cmd *cobra.Command, args []string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sort scripts by Priority then Sequence
|
// Sort scripts by Priority, Sequence, then Name
|
||||||
sortedScripts := make([]*struct {
|
sortedScripts := make([]*struct {
|
||||||
name string
|
name string
|
||||||
priority int
|
priority int
|
||||||
@@ -186,7 +193,10 @@ func runScriptsList(cmd *cobra.Command, args []string) error {
|
|||||||
if sortedScripts[i].priority != sortedScripts[j].priority {
|
if sortedScripts[i].priority != sortedScripts[j].priority {
|
||||||
return sortedScripts[i].priority < sortedScripts[j].priority
|
return sortedScripts[i].priority < sortedScripts[j].priority
|
||||||
}
|
}
|
||||||
return sortedScripts[i].sequence < sortedScripts[j].sequence
|
if sortedScripts[i].sequence != sortedScripts[j].sequence {
|
||||||
|
return sortedScripts[i].sequence < sortedScripts[j].sequence
|
||||||
|
}
|
||||||
|
return sortedScripts[i].name < sortedScripts[j].name
|
||||||
})
|
})
|
||||||
|
|
||||||
fmt.Fprintf(os.Stderr, "Found %d script(s) in execution order:\n\n", len(sortedScripts))
|
fmt.Fprintf(os.Stderr, "Found %d script(s) in execution order:\n\n", len(sortedScripts))
|
||||||
@@ -242,22 +252,44 @@ func runScriptsExecute(cmd *cobra.Command, args []string) error {
|
|||||||
fmt.Fprintf(os.Stderr, " ✓ Found %d script(s)\n\n", len(schema.Scripts))
|
fmt.Fprintf(os.Stderr, " ✓ Found %d script(s)\n\n", len(schema.Scripts))
|
||||||
|
|
||||||
// Step 2: Execute scripts
|
// Step 2: Execute scripts
|
||||||
fmt.Fprintf(os.Stderr, "[2/2] Executing scripts in order (Priority → Sequence)...\n\n")
|
fmt.Fprintf(os.Stderr, "[2/2] Executing scripts in order (Priority → Sequence → Name)...\n\n")
|
||||||
|
|
||||||
writer := sqlexec.NewWriter(&writers.WriterOptions{
|
writer := sqlexec.NewWriter(&writers.WriterOptions{
|
||||||
Metadata: map[string]any{
|
Metadata: map[string]any{
|
||||||
"connection_string": scriptsConn,
|
"connection_string": scriptsConn,
|
||||||
|
"ignore_errors": scriptsIgnoreErrors,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
if err := writer.WriteSchema(schema); err != nil {
|
if err := writer.WriteSchema(schema); err != nil {
|
||||||
fmt.Fprintf(os.Stderr, "\n")
|
fmt.Fprintf(os.Stderr, "\n")
|
||||||
return fmt.Errorf("execution failed: %w", err)
|
return fmt.Errorf("script execution failed: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get execution results from writer metadata
|
||||||
|
totalCount := len(schema.Scripts)
|
||||||
|
successCount := totalCount
|
||||||
|
failedCount := 0
|
||||||
|
|
||||||
|
opts := writer.Options()
|
||||||
|
if total, exists := opts.Metadata["execution_total"].(int); exists {
|
||||||
|
totalCount = total
|
||||||
|
}
|
||||||
|
if success, exists := opts.Metadata["execution_success"].(int); exists {
|
||||||
|
successCount = success
|
||||||
|
}
|
||||||
|
if failed, exists := opts.Metadata["execution_failed"].(int); exists {
|
||||||
|
failedCount = failed
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Fprintf(os.Stderr, "\n=== Execution Complete ===\n")
|
fmt.Fprintf(os.Stderr, "\n=== Execution Complete ===\n")
|
||||||
fmt.Fprintf(os.Stderr, "Completed at: %s\n", getCurrentTimestamp())
|
fmt.Fprintf(os.Stderr, "Completed at: %s\n", getCurrentTimestamp())
|
||||||
fmt.Fprintf(os.Stderr, "Successfully executed %d script(s)\n\n", len(schema.Scripts))
|
fmt.Fprintf(os.Stderr, "Total scripts: %d\n", totalCount)
|
||||||
|
fmt.Fprintf(os.Stderr, "Successful: %d\n", successCount)
|
||||||
|
if failedCount > 0 {
|
||||||
|
fmt.Fprintf(os.Stderr, "Failed: %d\n", failedCount)
|
||||||
|
}
|
||||||
|
fmt.Fprintf(os.Stderr, "\n")
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -183,7 +183,8 @@ func runSplit(cmd *cobra.Command, args []string) error {
|
|||||||
splitTargetType,
|
splitTargetType,
|
||||||
splitTargetPath,
|
splitTargetPath,
|
||||||
splitPackageName,
|
splitPackageName,
|
||||||
"", // no schema filter for split
|
"", // no schema filter for split
|
||||||
|
false, // no flatten-schema for split
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to write output: %w", err)
|
return fmt.Errorf("failed to write output: %w", err)
|
||||||
|
|||||||
173
go.mod
173
go.mod
@@ -15,197 +15,24 @@ require (
|
|||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
4d63.com/gocheckcompilerdirectives v1.3.0 // indirect
|
|
||||||
4d63.com/gochecknoglobals v0.2.2 // indirect
|
|
||||||
github.com/4meepo/tagalign v1.4.2 // indirect
|
|
||||||
github.com/Abirdcfly/dupword v0.1.3 // indirect
|
|
||||||
github.com/Antonboom/errname v1.0.0 // indirect
|
|
||||||
github.com/Antonboom/nilnil v1.0.1 // indirect
|
|
||||||
github.com/Antonboom/testifylint v1.5.2 // indirect
|
|
||||||
github.com/BurntSushi/toml v1.4.1-0.20240526193622-a339e1f7089c // indirect
|
|
||||||
github.com/Crocmagnon/fatcontext v0.7.1 // indirect
|
|
||||||
github.com/Djarvur/go-err113 v0.0.0-20210108212216-aea10b59be24 // indirect
|
|
||||||
github.com/GaijinEntertainment/go-exhaustruct/v3 v3.3.1 // indirect
|
|
||||||
github.com/Masterminds/semver/v3 v3.3.0 // indirect
|
|
||||||
github.com/OpenPeeDeeP/depguard/v2 v2.2.1 // indirect
|
|
||||||
github.com/alecthomas/go-check-sumtype v0.3.1 // indirect
|
|
||||||
github.com/alexkohler/nakedret/v2 v2.0.5 // indirect
|
|
||||||
github.com/alexkohler/prealloc v1.0.0 // indirect
|
|
||||||
github.com/alingse/asasalint v0.0.11 // indirect
|
|
||||||
github.com/alingse/nilnesserr v0.1.2 // indirect
|
|
||||||
github.com/ashanbrown/forbidigo v1.6.0 // indirect
|
|
||||||
github.com/ashanbrown/makezero v1.2.0 // indirect
|
|
||||||
github.com/beorn7/perks v1.0.1 // indirect
|
|
||||||
github.com/bkielbasa/cyclop v1.2.3 // indirect
|
|
||||||
github.com/blizzy78/varnamelen v0.8.0 // indirect
|
|
||||||
github.com/bombsimon/wsl/v4 v4.5.0 // indirect
|
|
||||||
github.com/breml/bidichk v0.3.2 // indirect
|
|
||||||
github.com/breml/errchkjson v0.4.0 // indirect
|
|
||||||
github.com/butuzov/ireturn v0.3.1 // indirect
|
|
||||||
github.com/butuzov/mirror v1.3.0 // indirect
|
|
||||||
github.com/catenacyber/perfsprint v0.8.2 // indirect
|
|
||||||
github.com/ccojocar/zxcvbn-go v1.0.2 // indirect
|
|
||||||
github.com/cespare/xxhash/v2 v2.3.0 // indirect
|
|
||||||
github.com/charithe/durationcheck v0.0.10 // indirect
|
|
||||||
github.com/chavacava/garif v0.1.0 // indirect
|
|
||||||
github.com/ckaznocha/intrange v0.3.0 // indirect
|
|
||||||
github.com/curioswitch/go-reassign v0.3.0 // indirect
|
|
||||||
github.com/daixiang0/gci v0.13.5 // indirect
|
|
||||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||||
github.com/denis-tingaikin/go-header v0.5.0 // indirect
|
|
||||||
github.com/ettle/strcase v0.2.0 // indirect
|
|
||||||
github.com/fatih/color v1.18.0 // indirect
|
|
||||||
github.com/fatih/structtag v1.2.0 // indirect
|
|
||||||
github.com/firefart/nonamedreturns v1.0.5 // indirect
|
|
||||||
github.com/fsnotify/fsnotify v1.5.4 // indirect
|
|
||||||
github.com/fzipp/gocyclo v0.6.0 // indirect
|
|
||||||
github.com/gdamore/encoding v1.0.1 // indirect
|
github.com/gdamore/encoding v1.0.1 // indirect
|
||||||
github.com/ghostiam/protogetter v0.3.9 // indirect
|
|
||||||
github.com/go-critic/go-critic v0.12.0 // indirect
|
|
||||||
github.com/go-toolsmith/astcast v1.1.0 // indirect
|
|
||||||
github.com/go-toolsmith/astcopy v1.1.0 // indirect
|
|
||||||
github.com/go-toolsmith/astequal v1.2.0 // indirect
|
|
||||||
github.com/go-toolsmith/astfmt v1.1.0 // indirect
|
|
||||||
github.com/go-toolsmith/astp v1.1.0 // indirect
|
|
||||||
github.com/go-toolsmith/strparse v1.1.0 // indirect
|
|
||||||
github.com/go-toolsmith/typep v1.1.0 // indirect
|
|
||||||
github.com/go-viper/mapstructure/v2 v2.2.1 // indirect
|
|
||||||
github.com/go-xmlfmt/xmlfmt v1.1.3 // indirect
|
|
||||||
github.com/gobwas/glob v0.2.3 // indirect
|
|
||||||
github.com/gofrs/flock v0.12.1 // indirect
|
|
||||||
github.com/golang/protobuf v1.5.3 // indirect
|
|
||||||
github.com/golangci/dupl v0.0.0-20250308024227-f665c8d69b32 // indirect
|
|
||||||
github.com/golangci/go-printf-func-name v0.1.0 // indirect
|
|
||||||
github.com/golangci/gofmt v0.0.0-20250106114630-d62b90e6713d // indirect
|
|
||||||
github.com/golangci/golangci-lint v1.64.8 // indirect
|
|
||||||
github.com/golangci/misspell v0.6.0 // indirect
|
|
||||||
github.com/golangci/plugin-module-register v0.1.1 // indirect
|
|
||||||
github.com/golangci/revgrep v0.8.0 // indirect
|
|
||||||
github.com/golangci/unconvert v0.0.0-20240309020433-c5143eacb3ed // indirect
|
|
||||||
github.com/google/go-cmp v0.7.0 // indirect
|
|
||||||
github.com/gordonklaus/ineffassign v0.1.0 // indirect
|
|
||||||
github.com/gostaticanalysis/analysisutil v0.7.1 // indirect
|
|
||||||
github.com/gostaticanalysis/comment v1.5.0 // indirect
|
|
||||||
github.com/gostaticanalysis/forcetypeassert v0.2.0 // indirect
|
|
||||||
github.com/gostaticanalysis/nilerr v0.1.1 // indirect
|
|
||||||
github.com/hashicorp/go-immutable-radix/v2 v2.1.0 // indirect
|
|
||||||
github.com/hashicorp/go-version v1.7.0 // indirect
|
|
||||||
github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect
|
|
||||||
github.com/hashicorp/hcl v1.0.0 // indirect
|
|
||||||
github.com/hexops/gotextdiff v1.0.3 // indirect
|
|
||||||
github.com/inconshreveable/mousetrap v1.1.0 // indirect
|
github.com/inconshreveable/mousetrap v1.1.0 // indirect
|
||||||
github.com/jackc/pgpassfile v1.0.0 // indirect
|
github.com/jackc/pgpassfile v1.0.0 // indirect
|
||||||
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect
|
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect
|
||||||
github.com/jgautheron/goconst v1.7.1 // indirect
|
|
||||||
github.com/jingyugao/rowserrcheck v1.1.1 // indirect
|
|
||||||
github.com/jinzhu/inflection v1.0.0 // indirect
|
github.com/jinzhu/inflection v1.0.0 // indirect
|
||||||
github.com/jjti/go-spancheck v0.6.4 // indirect
|
|
||||||
github.com/julz/importas v0.2.0 // indirect
|
|
||||||
github.com/karamaru-alpha/copyloopvar v1.2.1 // indirect
|
|
||||||
github.com/kisielk/errcheck v1.9.0 // indirect
|
|
||||||
github.com/kkHAIKE/contextcheck v1.1.6 // indirect
|
|
||||||
github.com/kr/pretty v0.3.1 // indirect
|
github.com/kr/pretty v0.3.1 // indirect
|
||||||
github.com/kulti/thelper v0.6.3 // indirect
|
|
||||||
github.com/kunwardeep/paralleltest v1.0.10 // indirect
|
|
||||||
github.com/lasiar/canonicalheader v1.1.2 // indirect
|
|
||||||
github.com/ldez/exptostd v0.4.2 // indirect
|
|
||||||
github.com/ldez/gomoddirectives v0.6.1 // indirect
|
|
||||||
github.com/ldez/grignotin v0.9.0 // indirect
|
|
||||||
github.com/ldez/tagliatelle v0.7.1 // indirect
|
|
||||||
github.com/ldez/usetesting v0.4.2 // indirect
|
|
||||||
github.com/leonklingele/grouper v1.1.2 // indirect
|
|
||||||
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
|
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
|
||||||
github.com/macabu/inamedparam v0.1.3 // indirect
|
|
||||||
github.com/magiconair/properties v1.8.6 // indirect
|
|
||||||
github.com/maratori/testableexamples v1.0.0 // indirect
|
|
||||||
github.com/maratori/testpackage v1.1.1 // indirect
|
|
||||||
github.com/matoous/godox v1.1.0 // indirect
|
|
||||||
github.com/mattn/go-colorable v0.1.14 // indirect
|
|
||||||
github.com/mattn/go-isatty v0.0.20 // indirect
|
|
||||||
github.com/mattn/go-runewidth v0.0.16 // indirect
|
github.com/mattn/go-runewidth v0.0.16 // indirect
|
||||||
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
|
|
||||||
github.com/mgechev/revive v1.7.0 // indirect
|
|
||||||
github.com/mitchellh/go-homedir v1.1.0 // indirect
|
|
||||||
github.com/mitchellh/mapstructure v1.5.0 // indirect
|
|
||||||
github.com/moricho/tparallel v0.3.2 // indirect
|
|
||||||
github.com/nakabonne/nestif v0.3.1 // indirect
|
|
||||||
github.com/nishanths/exhaustive v0.12.0 // indirect
|
|
||||||
github.com/nishanths/predeclared v0.2.2 // indirect
|
|
||||||
github.com/nunnatsa/ginkgolinter v0.19.1 // indirect
|
|
||||||
github.com/olekukonko/tablewriter v0.0.5 // indirect
|
|
||||||
github.com/pelletier/go-toml v1.9.5 // indirect
|
|
||||||
github.com/pelletier/go-toml/v2 v2.2.3 // indirect
|
|
||||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||||
github.com/polyfloyd/go-errorlint v1.7.1 // indirect
|
|
||||||
github.com/prometheus/client_golang v1.12.1 // indirect
|
|
||||||
github.com/prometheus/client_model v0.2.0 // indirect
|
|
||||||
github.com/prometheus/common v0.32.1 // indirect
|
|
||||||
github.com/prometheus/procfs v0.7.3 // indirect
|
|
||||||
github.com/puzpuzpuz/xsync/v3 v3.5.1 // indirect
|
github.com/puzpuzpuz/xsync/v3 v3.5.1 // indirect
|
||||||
github.com/quasilyte/go-ruleguard v0.4.3-0.20240823090925-0fe6f58b47b1 // indirect
|
|
||||||
github.com/quasilyte/go-ruleguard/dsl v0.3.22 // indirect
|
|
||||||
github.com/quasilyte/gogrep v0.5.0 // indirect
|
|
||||||
github.com/quasilyte/regex/syntax v0.0.0-20210819130434-b3f0c404a727 // indirect
|
|
||||||
github.com/quasilyte/stdinfo v0.0.0-20220114132959-f7386bf02567 // indirect
|
|
||||||
github.com/raeperd/recvcheck v0.2.0 // indirect
|
|
||||||
github.com/rivo/uniseg v0.4.7 // indirect
|
github.com/rivo/uniseg v0.4.7 // indirect
|
||||||
github.com/rogpeppe/go-internal v1.14.1 // indirect
|
github.com/rogpeppe/go-internal v1.14.1 // indirect
|
||||||
github.com/ryancurrah/gomodguard v1.3.5 // indirect
|
|
||||||
github.com/ryanrolds/sqlclosecheck v0.5.1 // indirect
|
|
||||||
github.com/sanposhiho/wastedassign/v2 v2.1.0 // indirect
|
|
||||||
github.com/santhosh-tekuri/jsonschema/v6 v6.0.1 // indirect
|
|
||||||
github.com/sashamelentyev/interfacebloat v1.1.0 // indirect
|
|
||||||
github.com/sashamelentyev/usestdlibvars v1.28.0 // indirect
|
|
||||||
github.com/securego/gosec/v2 v2.22.2 // indirect
|
|
||||||
github.com/sirupsen/logrus v1.9.3 // indirect
|
|
||||||
github.com/sivchari/containedctx v1.0.3 // indirect
|
|
||||||
github.com/sivchari/tenv v1.12.1 // indirect
|
|
||||||
github.com/sonatard/noctx v0.1.0 // indirect
|
|
||||||
github.com/sourcegraph/go-diff v0.7.0 // indirect
|
|
||||||
github.com/spf13/afero v1.12.0 // indirect
|
|
||||||
github.com/spf13/cast v1.5.0 // indirect
|
|
||||||
github.com/spf13/jwalterweatherman v1.1.0 // indirect
|
|
||||||
github.com/spf13/pflag v1.0.10 // indirect
|
github.com/spf13/pflag v1.0.10 // indirect
|
||||||
github.com/spf13/viper v1.12.0 // indirect
|
|
||||||
github.com/ssgreg/nlreturn/v2 v2.2.1 // indirect
|
|
||||||
github.com/stbenjam/no-sprintf-host-port v0.2.0 // indirect
|
|
||||||
github.com/stretchr/objx v0.5.2 // indirect
|
|
||||||
github.com/subosito/gotenv v1.4.1 // indirect
|
|
||||||
github.com/tdakkota/asciicheck v0.4.1 // indirect
|
|
||||||
github.com/tetafro/godot v1.5.0 // indirect
|
|
||||||
github.com/timakin/bodyclose v0.0.0-20241017074812-ed6a65f985e3 // indirect
|
|
||||||
github.com/timonwong/loggercheck v0.10.1 // indirect
|
|
||||||
github.com/tmthrgd/go-hex v0.0.0-20190904060850-447a3041c3bc // indirect
|
github.com/tmthrgd/go-hex v0.0.0-20190904060850-447a3041c3bc // indirect
|
||||||
github.com/tomarrell/wrapcheck/v2 v2.10.0 // indirect
|
|
||||||
github.com/tommy-muehle/go-mnd/v2 v2.5.1 // indirect
|
|
||||||
github.com/ultraware/funlen v0.2.0 // indirect
|
|
||||||
github.com/ultraware/whitespace v0.2.0 // indirect
|
|
||||||
github.com/uudashr/gocognit v1.2.0 // indirect
|
|
||||||
github.com/uudashr/iface v1.3.1 // indirect
|
|
||||||
github.com/vmihailenco/msgpack/v5 v5.4.1 // indirect
|
github.com/vmihailenco/msgpack/v5 v5.4.1 // indirect
|
||||||
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
|
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
|
||||||
github.com/xen0n/gosmopolitan v1.2.2 // indirect
|
|
||||||
github.com/yagipy/maintidx v1.0.0 // indirect
|
|
||||||
github.com/yeya24/promlinter v0.3.0 // indirect
|
|
||||||
github.com/ykadowak/zerologlint v0.1.5 // indirect
|
|
||||||
gitlab.com/bosi/decorder v0.4.2 // indirect
|
|
||||||
go-simpler.org/musttag v0.13.0 // indirect
|
|
||||||
go-simpler.org/sloglint v0.9.0 // indirect
|
|
||||||
go.uber.org/atomic v1.7.0 // indirect
|
|
||||||
go.uber.org/automaxprocs v1.6.0 // indirect
|
|
||||||
go.uber.org/multierr v1.6.0 // indirect
|
|
||||||
go.uber.org/zap v1.24.0 // indirect
|
|
||||||
golang.org/x/crypto v0.41.0 // indirect
|
golang.org/x/crypto v0.41.0 // indirect
|
||||||
golang.org/x/exp/typeparams v0.0.0-20250210185358-939b2ce775ac // indirect
|
|
||||||
golang.org/x/mod v0.26.0 // indirect
|
|
||||||
golang.org/x/sync v0.16.0 // indirect
|
|
||||||
golang.org/x/sys v0.38.0 // indirect
|
golang.org/x/sys v0.38.0 // indirect
|
||||||
golang.org/x/term v0.34.0 // indirect
|
golang.org/x/term v0.34.0 // indirect
|
||||||
golang.org/x/tools v0.35.0 // indirect
|
|
||||||
google.golang.org/protobuf v1.36.5 // indirect
|
|
||||||
gopkg.in/ini.v1 v1.67.0 // indirect
|
|
||||||
gopkg.in/yaml.v2 v2.4.0 // indirect
|
|
||||||
honnef.co/go/tools v0.6.1 // indirect
|
|
||||||
mvdan.cc/gofumpt v0.7.0 // indirect
|
|
||||||
mvdan.cc/unparam v0.0.0-20240528143540-8a5130ca722f // indirect
|
|
||||||
)
|
)
|
||||||
|
|||||||
849
go.sum
849
go.sum
@@ -1,296 +1,15 @@
|
|||||||
4d63.com/gocheckcompilerdirectives v1.3.0 h1:Ew5y5CtcAAQeTVKUVFrE7EwHMrTO6BggtEj8BZSjZ3A=
|
|
||||||
4d63.com/gocheckcompilerdirectives v1.3.0/go.mod h1:ofsJ4zx2QAuIP/NO/NAh1ig6R1Fb18/GI7RVMwz7kAY=
|
|
||||||
4d63.com/gochecknoglobals v0.2.2 h1:H1vdnwnMaZdQW/N+NrkT1SZMTBmcwHe9Vq8lJcYYTtU=
|
|
||||||
4d63.com/gochecknoglobals v0.2.2/go.mod h1:lLxwTQjL5eIesRbvnzIP3jZtG140FnTdz+AlMa+ogt0=
|
|
||||||
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
|
||||||
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
|
||||||
cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU=
|
|
||||||
cloud.google.com/go v0.44.1/go.mod h1:iSa0KzasP4Uvy3f1mN/7PiObzGgflwredwwASm/v6AU=
|
|
||||||
cloud.google.com/go v0.44.2/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY=
|
|
||||||
cloud.google.com/go v0.45.1/go.mod h1:RpBamKRgapWJb87xiFSdk4g1CME7QZg3uwTez+TSTjc=
|
|
||||||
cloud.google.com/go v0.46.3/go.mod h1:a6bKKbmY7er1mI7TEI4lsAkts/mkhTSZK8w33B4RAg0=
|
|
||||||
cloud.google.com/go v0.50.0/go.mod h1:r9sluTvynVuxRIOHXQEHMFffphuXHOMZMycpNR5e6To=
|
|
||||||
cloud.google.com/go v0.52.0/go.mod h1:pXajvRH/6o3+F9jDHZWQ5PbGhn+o8w9qiu/CffaVdO4=
|
|
||||||
cloud.google.com/go v0.53.0/go.mod h1:fp/UouUEsRkN6ryDKNW/Upv/JBKnv6WDthjR6+vze6M=
|
|
||||||
cloud.google.com/go v0.54.0/go.mod h1:1rq2OEkV3YMf6n/9ZvGWI3GWw0VoqH/1x2nd8Is/bPc=
|
|
||||||
cloud.google.com/go v0.56.0/go.mod h1:jr7tqZxxKOVYizybht9+26Z/gUq7tiRzu+ACVAMbKVk=
|
|
||||||
cloud.google.com/go v0.57.0/go.mod h1:oXiQ6Rzq3RAkkY7N6t3TcE6jE+CIBBbA36lwQ1JyzZs=
|
|
||||||
cloud.google.com/go v0.62.0/go.mod h1:jmCYTdRCQuc1PHIIJ/maLInMho30T/Y0M4hTdTShOYc=
|
|
||||||
cloud.google.com/go v0.65.0/go.mod h1:O5N8zS7uWy9vkA9vayVHs65eM1ubvY4h553ofrNHObY=
|
|
||||||
cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o=
|
|
||||||
cloud.google.com/go/bigquery v1.3.0/go.mod h1:PjpwJnslEMmckchkHFfq+HTD2DmtT67aNFKH1/VBDHE=
|
|
||||||
cloud.google.com/go/bigquery v1.4.0/go.mod h1:S8dzgnTigyfTmLBfrtrhyYhwRxG72rYxvftPBK2Dvzc=
|
|
||||||
cloud.google.com/go/bigquery v1.5.0/go.mod h1:snEHRnqQbz117VIFhE8bmtwIDY80NLUZUMb4Nv6dBIg=
|
|
||||||
cloud.google.com/go/bigquery v1.7.0/go.mod h1://okPTzCYNXSlb24MZs83e2Do+h+VXtc4gLoIoXIAPc=
|
|
||||||
cloud.google.com/go/bigquery v1.8.0/go.mod h1:J5hqkt3O0uAFnINi6JXValWIb1v0goeZM77hZzJN/fQ=
|
|
||||||
cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE=
|
|
||||||
cloud.google.com/go/datastore v1.1.0/go.mod h1:umbIZjpQpHh4hmRpGhH4tLFup+FVzqBi1b3c64qFpCk=
|
|
||||||
cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I=
|
|
||||||
cloud.google.com/go/pubsub v1.1.0/go.mod h1:EwwdRX2sKPjnvnqCa270oGRyludottCI76h+R3AArQw=
|
|
||||||
cloud.google.com/go/pubsub v1.2.0/go.mod h1:jhfEVHT8odbXTkndysNHCcx0awwzvfOlguIAii9o8iA=
|
|
||||||
cloud.google.com/go/pubsub v1.3.1/go.mod h1:i+ucay31+CNRpDW4Lu78I4xXG+O1r/MAHgjpRVR+TSU=
|
|
||||||
cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiyrjsg+URw=
|
|
||||||
cloud.google.com/go/storage v1.5.0/go.mod h1:tpKbwo567HUNpVclU5sGELwQWBDZ8gh0ZeosJ0Rtdos=
|
|
||||||
cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohlUTyfDhBk=
|
|
||||||
cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs=
|
|
||||||
cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0=
|
|
||||||
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
|
|
||||||
github.com/4meepo/tagalign v1.4.2 h1:0hcLHPGMjDyM1gHG58cS73aQF8J4TdVR96TZViorO9E=
|
|
||||||
github.com/4meepo/tagalign v1.4.2/go.mod h1:+p4aMyFM+ra7nb41CnFG6aSDXqRxU/w1VQqScKqDARI=
|
|
||||||
github.com/Abirdcfly/dupword v0.1.3 h1:9Pa1NuAsZvpFPi9Pqkd93I7LIYRURj+A//dFd5tgBeE=
|
|
||||||
github.com/Abirdcfly/dupword v0.1.3/go.mod h1:8VbB2t7e10KRNdwTVoxdBaxla6avbhGzb8sCTygUMhw=
|
|
||||||
github.com/Antonboom/errname v1.0.0 h1:oJOOWR07vS1kRusl6YRSlat7HFnb3mSfMl6sDMRoTBA=
|
|
||||||
github.com/Antonboom/errname v1.0.0/go.mod h1:gMOBFzK/vrTiXN9Oh+HFs+e6Ndl0eTFbtsRTSRdXyGI=
|
|
||||||
github.com/Antonboom/nilnil v1.0.1 h1:C3Tkm0KUxgfO4Duk3PM+ztPncTFlOf0b2qadmS0s4xs=
|
|
||||||
github.com/Antonboom/nilnil v1.0.1/go.mod h1:CH7pW2JsRNFgEh8B2UaPZTEPhCMuFowP/e8Udp9Nnb0=
|
|
||||||
github.com/Antonboom/testifylint v1.5.2 h1:4s3Xhuv5AvdIgbd8wOOEeo0uZG7PbDKQyKY5lGoQazk=
|
|
||||||
github.com/Antonboom/testifylint v1.5.2/go.mod h1:vxy8VJ0bc6NavlYqjZfmp6EfqXMtBgQ4+mhCojwC1P8=
|
|
||||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
|
||||||
github.com/BurntSushi/toml v1.4.1-0.20240526193622-a339e1f7089c h1:pxW6RcqyfI9/kWtOwnv/G+AzdKuy2ZrqINhenH4HyNs=
|
|
||||||
github.com/BurntSushi/toml v1.4.1-0.20240526193622-a339e1f7089c/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho=
|
|
||||||
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
|
|
||||||
github.com/Crocmagnon/fatcontext v0.7.1 h1:SC/VIbRRZQeQWj/TcQBS6JmrXcfA+BU4OGSVUt54PjM=
|
|
||||||
github.com/Crocmagnon/fatcontext v0.7.1/go.mod h1:1wMvv3NXEBJucFGfwOJBxSVWcoIO6emV215SMkW9MFU=
|
|
||||||
github.com/Djarvur/go-err113 v0.0.0-20210108212216-aea10b59be24 h1:sHglBQTwgx+rWPdisA5ynNEsoARbiCBOyGcJM4/OzsM=
|
|
||||||
github.com/Djarvur/go-err113 v0.0.0-20210108212216-aea10b59be24/go.mod h1:4UJr5HIiMZrwgkSPdsjy2uOQExX/WEILpIrO9UPGuXs=
|
|
||||||
github.com/GaijinEntertainment/go-exhaustruct/v3 v3.3.1 h1:Sz1JIXEcSfhz7fUi7xHnhpIE0thVASYjvosApmHuD2k=
|
|
||||||
github.com/GaijinEntertainment/go-exhaustruct/v3 v3.3.1/go.mod h1:n/LSCXNuIYqVfBlVXyHfMQkZDdp1/mmxfSjADd3z1Zg=
|
|
||||||
github.com/Masterminds/semver/v3 v3.3.0 h1:B8LGeaivUe71a5qox1ICM/JLl0NqZSW5CHyL+hmvYS0=
|
|
||||||
github.com/Masterminds/semver/v3 v3.3.0/go.mod h1:4V+yj/TJE1HU9XfppCwVMZq3I84lprf4nC11bSS5beM=
|
|
||||||
github.com/OpenPeeDeeP/depguard/v2 v2.2.1 h1:vckeWVESWp6Qog7UZSARNqfu/cZqvki8zsuj3piCMx4=
|
|
||||||
github.com/OpenPeeDeeP/depguard/v2 v2.2.1/go.mod h1:q4DKzC4UcVaAvcfd41CZh0PWpGgzrVxUYBlgKNGquUo=
|
|
||||||
github.com/alecthomas/go-check-sumtype v0.3.1 h1:u9aUvbGINJxLVXiFvHUlPEaD7VDULsrxJb4Aq31NLkU=
|
|
||||||
github.com/alecthomas/go-check-sumtype v0.3.1/go.mod h1:A8TSiN3UPRw3laIgWEUOHHLPa6/r9MtoigdlP5h3K/E=
|
|
||||||
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
|
|
||||||
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
|
|
||||||
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
|
|
||||||
github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
|
|
||||||
github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho=
|
|
||||||
github.com/alexkohler/nakedret/v2 v2.0.5 h1:fP5qLgtwbx9EJE8dGEERT02YwS8En4r9nnZ71RK+EVU=
|
|
||||||
github.com/alexkohler/nakedret/v2 v2.0.5/go.mod h1:bF5i0zF2Wo2o4X4USt9ntUWve6JbFv02Ff4vlkmS/VU=
|
|
||||||
github.com/alexkohler/prealloc v1.0.0 h1:Hbq0/3fJPQhNkN0dR95AVrr6R7tou91y0uHG5pOcUuw=
|
|
||||||
github.com/alexkohler/prealloc v1.0.0/go.mod h1:VetnK3dIgFBBKmg0YnD9F9x6Icjd+9cvfHR56wJVlKE=
|
|
||||||
github.com/alingse/asasalint v0.0.11 h1:SFwnQXJ49Kx/1GghOFz1XGqHYKp21Kq1nHad/0WQRnw=
|
|
||||||
github.com/alingse/asasalint v0.0.11/go.mod h1:nCaoMhw7a9kSJObvQyVzNTPBDbNpdocqrSP7t/cW5+I=
|
|
||||||
github.com/alingse/nilnesserr v0.1.2 h1:Yf8Iwm3z2hUUrP4muWfW83DF4nE3r1xZ26fGWUKCZlo=
|
|
||||||
github.com/alingse/nilnesserr v0.1.2/go.mod h1:1xJPrXonEtX7wyTq8Dytns5P2hNzoWymVUIaKm4HNFg=
|
|
||||||
github.com/ashanbrown/forbidigo v1.6.0 h1:D3aewfM37Yb3pxHujIPSpTf6oQk9sc9WZi8gerOIVIY=
|
|
||||||
github.com/ashanbrown/forbidigo v1.6.0/go.mod h1:Y8j9jy9ZYAEHXdu723cUlraTqbzjKF1MUyfOKL+AjcU=
|
|
||||||
github.com/ashanbrown/makezero v1.2.0 h1:/2Lp1bypdmK9wDIq7uWBlDF1iMUpIIS4A+pF6C9IEUU=
|
|
||||||
github.com/ashanbrown/makezero v1.2.0/go.mod h1:dxlPhHbDMC6N6xICzFBSK+4njQDdK8euNO0qjQMtGY4=
|
|
||||||
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
|
|
||||||
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
|
|
||||||
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
|
|
||||||
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
|
|
||||||
github.com/bkielbasa/cyclop v1.2.3 h1:faIVMIGDIANuGPWH031CZJTi2ymOQBULs9H21HSMa5w=
|
|
||||||
github.com/bkielbasa/cyclop v1.2.3/go.mod h1:kHTwA9Q0uZqOADdupvcFJQtp/ksSnytRMe8ztxG8Fuo=
|
|
||||||
github.com/blizzy78/varnamelen v0.8.0 h1:oqSblyuQvFsW1hbBHh1zfwrKe3kcSj0rnXkKzsQ089M=
|
|
||||||
github.com/blizzy78/varnamelen v0.8.0/go.mod h1:V9TzQZ4fLJ1DSrjVDfl89H7aMnTvKkApdHeyESmyR7k=
|
|
||||||
github.com/bombsimon/wsl/v4 v4.5.0 h1:iZRsEvDdyhd2La0FVi5k6tYehpOR/R7qIUjmKk7N74A=
|
|
||||||
github.com/bombsimon/wsl/v4 v4.5.0/go.mod h1:NOQ3aLF4nD7N5YPXMruR6ZXDOAqLoM0GEpLwTdvmOSc=
|
|
||||||
github.com/breml/bidichk v0.3.2 h1:xV4flJ9V5xWTqxL+/PMFF6dtJPvZLPsyixAoPe8BGJs=
|
|
||||||
github.com/breml/bidichk v0.3.2/go.mod h1:VzFLBxuYtT23z5+iVkamXO386OB+/sVwZOpIj6zXGos=
|
|
||||||
github.com/breml/errchkjson v0.4.0 h1:gftf6uWZMtIa/Is3XJgibewBm2ksAQSY/kABDNFTAdk=
|
|
||||||
github.com/breml/errchkjson v0.4.0/go.mod h1:AuBOSTHyLSaaAFlWsRSuRBIroCh3eh7ZHh5YeelDIk8=
|
|
||||||
github.com/butuzov/ireturn v0.3.1 h1:mFgbEI6m+9W8oP/oDdfA34dLisRFCj2G6o/yiI1yZrY=
|
|
||||||
github.com/butuzov/ireturn v0.3.1/go.mod h1:ZfRp+E7eJLC0NQmk1Nrm1LOrn/gQlOykv+cVPdiXH5M=
|
|
||||||
github.com/butuzov/mirror v1.3.0 h1:HdWCXzmwlQHdVhwvsfBb2Au0r3HyINry3bDWLYXiKoc=
|
|
||||||
github.com/butuzov/mirror v1.3.0/go.mod h1:AEij0Z8YMALaq4yQj9CPPVYOyJQyiexpQEQgihajRfI=
|
|
||||||
github.com/catenacyber/perfsprint v0.8.2 h1:+o9zVmCSVa7M4MvabsWvESEhpsMkhfE7k0sHNGL95yw=
|
|
||||||
github.com/catenacyber/perfsprint v0.8.2/go.mod h1:q//VWC2fWbcdSLEY1R3l8n0zQCDPdE4IjZwyY1HMunM=
|
|
||||||
github.com/ccojocar/zxcvbn-go v1.0.2 h1:na/czXU8RrhXO4EZme6eQJLR4PzcGsahsBOAwU6I3Vg=
|
|
||||||
github.com/ccojocar/zxcvbn-go v1.0.2/go.mod h1:g1qkXtUSvHP8lhHp5GrSmTz6uWALGRMQdw6Qnz/hi60=
|
|
||||||
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
|
|
||||||
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
|
||||||
github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
|
||||||
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
|
|
||||||
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
|
||||||
github.com/charithe/durationcheck v0.0.10 h1:wgw73BiocdBDQPik+zcEoBG/ob8uyBHf2iyoHGPf5w4=
|
|
||||||
github.com/charithe/durationcheck v0.0.10/go.mod h1:bCWXb7gYRysD1CU3C+u4ceO49LoGOY1C1L6uouGNreQ=
|
|
||||||
github.com/chavacava/garif v0.1.0 h1:2JHa3hbYf5D9dsgseMKAmc/MZ109otzgNFk5s87H9Pc=
|
|
||||||
github.com/chavacava/garif v0.1.0/go.mod h1:XMyYCkEL58DF0oyW4qDjjnPWONs2HBqYKI+UIPD+Gww=
|
|
||||||
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
|
|
||||||
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
|
|
||||||
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
|
|
||||||
github.com/ckaznocha/intrange v0.3.0 h1:VqnxtK32pxgkhJgYQEeOArVidIPg+ahLP7WBOXZd5ZY=
|
|
||||||
github.com/ckaznocha/intrange v0.3.0/go.mod h1:+I/o2d2A1FBHgGELbGxzIcyd3/9l9DuwjM8FsbSS3Lo=
|
|
||||||
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
|
|
||||||
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
|
|
||||||
github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g=
|
github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g=
|
||||||
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
|
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
|
||||||
github.com/curioswitch/go-reassign v0.3.0 h1:dh3kpQHuADL3cobV/sSGETA8DOv457dwl+fbBAhrQPs=
|
|
||||||
github.com/curioswitch/go-reassign v0.3.0/go.mod h1:nApPCCTtqLJN/s8HfItCcKV0jIPwluBOvZP+dsJGA88=
|
|
||||||
github.com/daixiang0/gci v0.13.5 h1:kThgmH1yBmZSBCh1EJVxQ7JsHpm5Oms0AMed/0LaH4c=
|
|
||||||
github.com/daixiang0/gci v0.13.5/go.mod h1:12etP2OniiIdP4q+kjUGrC/rUagga7ODbqsom5Eo5Yk=
|
|
||||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/denis-tingaikin/go-header v0.5.0 h1:SRdnP5ZKvcO9KKRP1KJrhFR3RrlGuD+42t4429eC9k8=
|
|
||||||
github.com/denis-tingaikin/go-header v0.5.0/go.mod h1:mMenU5bWrok6Wl2UsZjy+1okegmwQ3UgWl4V1D8gjlY=
|
|
||||||
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
|
||||||
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
|
||||||
github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
|
|
||||||
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
|
|
||||||
github.com/ettle/strcase v0.2.0 h1:fGNiVF21fHXpX1niBgk0aROov1LagYsOwV/xqKDKR/Q=
|
|
||||||
github.com/ettle/strcase v0.2.0/go.mod h1:DajmHElDSaX76ITe3/VHVyMin4LWSJN5Z909Wp+ED1A=
|
|
||||||
github.com/fatih/color v1.18.0 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM=
|
|
||||||
github.com/fatih/color v1.18.0/go.mod h1:4FelSpRwEGDpQ12mAdzqdOukCy4u8WUtOY6lkT/6HfU=
|
|
||||||
github.com/fatih/structtag v1.2.0 h1:/OdNE99OxoI/PqaW/SuSK9uxxT3f/tcSZgon/ssNSx4=
|
|
||||||
github.com/fatih/structtag v1.2.0/go.mod h1:mBJUNpUnHmRKrKlQQlmCrh5PuhftFbNv8Ys4/aAZl94=
|
|
||||||
github.com/firefart/nonamedreturns v1.0.5 h1:tM+Me2ZaXs8tfdDw3X6DOX++wMCOqzYUho6tUTYIdRA=
|
|
||||||
github.com/firefart/nonamedreturns v1.0.5/go.mod h1:gHJjDqhGM4WyPt639SOZs+G89Ko7QKH5R5BhnO6xJhw=
|
|
||||||
github.com/fsnotify/fsnotify v1.5.4 h1:jRbGcIw6P2Meqdwuo0H1p6JVLbL5DHKAKlYndzMwVZI=
|
|
||||||
github.com/fsnotify/fsnotify v1.5.4/go.mod h1:OVB6XrOHzAwXMpEM7uPOzcehqUV2UqJxmVXmkdnm1bU=
|
|
||||||
github.com/fzipp/gocyclo v0.6.0 h1:lsblElZG7d3ALtGMx9fmxeTKZaLLpU8mET09yN4BBLo=
|
|
||||||
github.com/fzipp/gocyclo v0.6.0/go.mod h1:rXPyn8fnlpa0R2csP/31uerbiVBugk5whMdlyaLkLoA=
|
|
||||||
github.com/gdamore/encoding v1.0.1 h1:YzKZckdBL6jVt2Gc+5p82qhrGiqMdG/eNs6Wy0u3Uhw=
|
github.com/gdamore/encoding v1.0.1 h1:YzKZckdBL6jVt2Gc+5p82qhrGiqMdG/eNs6Wy0u3Uhw=
|
||||||
github.com/gdamore/encoding v1.0.1/go.mod h1:0Z0cMFinngz9kS1QfMjCP8TY7em3bZYeeklsSDPivEo=
|
github.com/gdamore/encoding v1.0.1/go.mod h1:0Z0cMFinngz9kS1QfMjCP8TY7em3bZYeeklsSDPivEo=
|
||||||
github.com/gdamore/tcell/v2 v2.8.1 h1:KPNxyqclpWpWQlPLx6Xui1pMk8S+7+R37h3g07997NU=
|
github.com/gdamore/tcell/v2 v2.8.1 h1:KPNxyqclpWpWQlPLx6Xui1pMk8S+7+R37h3g07997NU=
|
||||||
github.com/gdamore/tcell/v2 v2.8.1/go.mod h1:bj8ori1BG3OYMjmb3IklZVWfZUJ1UBQt9JXrOCOhGWw=
|
github.com/gdamore/tcell/v2 v2.8.1/go.mod h1:bj8ori1BG3OYMjmb3IklZVWfZUJ1UBQt9JXrOCOhGWw=
|
||||||
github.com/ghostiam/protogetter v0.3.9 h1:j+zlLLWzqLay22Cz/aYwTHKQ88GE2DQ6GkWSYFOI4lQ=
|
|
||||||
github.com/ghostiam/protogetter v0.3.9/go.mod h1:WZ0nw9pfzsgxuRsPOFQomgDVSWtDLJRfQJEhsGbmQMA=
|
|
||||||
github.com/go-critic/go-critic v0.12.0 h1:iLosHZuye812wnkEz1Xu3aBwn5ocCPfc9yqmFG9pa6w=
|
|
||||||
github.com/go-critic/go-critic v0.12.0/go.mod h1:DpE0P6OVc6JzVYzmM5gq5jMU31zLr4am5mB/VfFK64w=
|
|
||||||
github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU=
|
|
||||||
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
|
|
||||||
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
|
|
||||||
github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
|
|
||||||
github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
|
|
||||||
github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY=
|
|
||||||
github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
|
|
||||||
github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
|
|
||||||
github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A=
|
|
||||||
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
|
|
||||||
github.com/go-toolsmith/astcast v1.1.0 h1:+JN9xZV1A+Re+95pgnMgDboWNVnIMMQXwfBwLRPgSC8=
|
|
||||||
github.com/go-toolsmith/astcast v1.1.0/go.mod h1:qdcuFWeGGS2xX5bLM/c3U9lewg7+Zu4mr+xPwZIB4ZU=
|
|
||||||
github.com/go-toolsmith/astcopy v1.1.0 h1:YGwBN0WM+ekI/6SS6+52zLDEf8Yvp3n2seZITCUBt5s=
|
|
||||||
github.com/go-toolsmith/astcopy v1.1.0/go.mod h1:hXM6gan18VA1T/daUEHCFcYiW8Ai1tIwIzHY6srfEAw=
|
|
||||||
github.com/go-toolsmith/astequal v1.0.3/go.mod h1:9Ai4UglvtR+4up+bAD4+hCj7iTo4m/OXVTSLnCyTAx4=
|
|
||||||
github.com/go-toolsmith/astequal v1.1.0/go.mod h1:sedf7VIdCL22LD8qIvv7Nn9MuWJruQA/ysswh64lffQ=
|
|
||||||
github.com/go-toolsmith/astequal v1.2.0 h1:3Fs3CYZ1k9Vo4FzFhwwewC3CHISHDnVUPC4x0bI2+Cw=
|
|
||||||
github.com/go-toolsmith/astequal v1.2.0/go.mod h1:c8NZ3+kSFtFY/8lPso4v8LuJjdJiUFVnSuU3s0qrrDY=
|
|
||||||
github.com/go-toolsmith/astfmt v1.1.0 h1:iJVPDPp6/7AaeLJEruMsBUlOYCmvg0MoCfJprsOmcco=
|
|
||||||
github.com/go-toolsmith/astfmt v1.1.0/go.mod h1:OrcLlRwu0CuiIBp/8b5PYF9ktGVZUjlNMV634mhwuQ4=
|
|
||||||
github.com/go-toolsmith/astp v1.1.0 h1:dXPuCl6u2llURjdPLLDxJeZInAeZ0/eZwFJmqZMnpQA=
|
|
||||||
github.com/go-toolsmith/astp v1.1.0/go.mod h1:0T1xFGz9hicKs8Z5MfAqSUitoUYS30pDMsRVIDHs8CA=
|
|
||||||
github.com/go-toolsmith/strparse v1.0.0/go.mod h1:YI2nUKP9YGZnL/L1/DLFBfixrcjslWct4wyljWhSRy8=
|
|
||||||
github.com/go-toolsmith/strparse v1.1.0 h1:GAioeZUK9TGxnLS+qfdqNbA4z0SSm5zVNtCQiyP2Bvw=
|
|
||||||
github.com/go-toolsmith/strparse v1.1.0/go.mod h1:7ksGy58fsaQkGQlY8WVoBFNyEPMGuJin1rfoPS4lBSQ=
|
|
||||||
github.com/go-toolsmith/typep v1.1.0 h1:fIRYDyF+JywLfqzyhdiHzRop/GQDxxNhLGQ6gFUNHus=
|
|
||||||
github.com/go-toolsmith/typep v1.1.0/go.mod h1:fVIw+7zjdsMxDA3ITWnH1yOiw1rnTQKCsF/sk2H/qig=
|
|
||||||
github.com/go-viper/mapstructure/v2 v2.2.1 h1:ZAaOCxANMuZx5RCeg0mBdEZk7DZasvvZIxtHqx8aGss=
|
|
||||||
github.com/go-viper/mapstructure/v2 v2.2.1/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM=
|
|
||||||
github.com/go-xmlfmt/xmlfmt v1.1.3 h1:t8Ey3Uy7jDSEisW2K3somuMKIpzktkWptA0iFCnRUWY=
|
|
||||||
github.com/go-xmlfmt/xmlfmt v1.1.3/go.mod h1:aUCEOzzezBEjDBbFBoSiya/gduyIiWYRP6CnSFIV8AM=
|
|
||||||
github.com/gobwas/glob v0.2.3 h1:A4xDbljILXROh+kObIiy5kIaPYD8e96x1tgBhUI5J+Y=
|
|
||||||
github.com/gobwas/glob v0.2.3/go.mod h1:d3Ez4x06l9bZtSvzIay5+Yzi0fmZzPgnTbPcKjJAkT8=
|
|
||||||
github.com/gofrs/flock v0.12.1 h1:MTLVXXHf8ekldpJk3AKicLij9MdwOWkZ+a/jHHZby9E=
|
|
||||||
github.com/gofrs/flock v0.12.1/go.mod h1:9zxTsyu5xtJ9DK+1tFZyibEV7y3uwDxPPfbxeeHCoD0=
|
|
||||||
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
|
|
||||||
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
|
|
||||||
github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
|
||||||
github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
|
||||||
github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
|
||||||
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
|
|
||||||
github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
|
|
||||||
github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y=
|
|
||||||
github.com/golang/mock v1.4.0/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw=
|
|
||||||
github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw=
|
|
||||||
github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw=
|
|
||||||
github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4=
|
|
||||||
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
|
||||||
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
|
||||||
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
|
||||||
github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw=
|
|
||||||
github.com/golang/protobuf v1.3.4/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw=
|
|
||||||
github.com/golang/protobuf v1.3.5/go.mod h1:6O5/vntMXwX2lRkT1hjjk0nAC1IDOTvTlVgjlRvqsdk=
|
|
||||||
github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8=
|
|
||||||
github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA=
|
|
||||||
github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs=
|
|
||||||
github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w=
|
|
||||||
github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
|
|
||||||
github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8=
|
|
||||||
github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
|
|
||||||
github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
|
|
||||||
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
|
|
||||||
github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
|
|
||||||
github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg=
|
|
||||||
github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
|
|
||||||
github.com/golangci/dupl v0.0.0-20250308024227-f665c8d69b32 h1:WUvBfQL6EW/40l6OmeSBYQJNSif4O11+bmWEz+C7FYw=
|
|
||||||
github.com/golangci/dupl v0.0.0-20250308024227-f665c8d69b32/go.mod h1:NUw9Zr2Sy7+HxzdjIULge71wI6yEg1lWQr7Evcu8K0E=
|
|
||||||
github.com/golangci/go-printf-func-name v0.1.0 h1:dVokQP+NMTO7jwO4bwsRwLWeudOVUPPyAKJuzv8pEJU=
|
|
||||||
github.com/golangci/go-printf-func-name v0.1.0/go.mod h1:wqhWFH5mUdJQhweRnldEywnR5021wTdZSNgwYceV14s=
|
|
||||||
github.com/golangci/gofmt v0.0.0-20250106114630-d62b90e6713d h1:viFft9sS/dxoYY0aiOTsLKO2aZQAPT4nlQCsimGcSGE=
|
|
||||||
github.com/golangci/gofmt v0.0.0-20250106114630-d62b90e6713d/go.mod h1:ivJ9QDg0XucIkmwhzCDsqcnxxlDStoTl89jDMIoNxKY=
|
|
||||||
github.com/golangci/golangci-lint v1.64.8 h1:y5TdeVidMtBGG32zgSC7ZXTFNHrsJkDnpO4ItB3Am+I=
|
|
||||||
github.com/golangci/golangci-lint v1.64.8/go.mod h1:5cEsUQBSr6zi8XI8OjmcY2Xmliqc4iYL7YoPrL+zLJ4=
|
|
||||||
github.com/golangci/misspell v0.6.0 h1:JCle2HUTNWirNlDIAUO44hUsKhOFqGPoC4LZxlaSXDs=
|
|
||||||
github.com/golangci/misspell v0.6.0/go.mod h1:keMNyY6R9isGaSAu+4Q8NMBwMPkh15Gtc8UCVoDtAWo=
|
|
||||||
github.com/golangci/plugin-module-register v0.1.1 h1:TCmesur25LnyJkpsVrupv1Cdzo+2f7zX0H6Jkw1Ol6c=
|
|
||||||
github.com/golangci/plugin-module-register v0.1.1/go.mod h1:TTpqoB6KkwOJMV8u7+NyXMrkwwESJLOkfl9TxR1DGFc=
|
|
||||||
github.com/golangci/revgrep v0.8.0 h1:EZBctwbVd0aMeRnNUsFogoyayvKHyxlV3CdUA46FX2s=
|
|
||||||
github.com/golangci/revgrep v0.8.0/go.mod h1:U4R/s9dlXZsg8uJmaR1GrloUr14D7qDl8gi2iPXJH8k=
|
|
||||||
github.com/golangci/unconvert v0.0.0-20240309020433-c5143eacb3ed h1:IURFTjxeTfNFP0hTEi1YKjB/ub8zkpaOqFFMApi2EAs=
|
|
||||||
github.com/golangci/unconvert v0.0.0-20240309020433-c5143eacb3ed/go.mod h1:XLXN8bNw4CGRPaqgl3bv/lhz7bsGPh4/xSaMTbo2vkQ=
|
|
||||||
github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
|
|
||||||
github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
|
|
||||||
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
|
|
||||||
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
|
||||||
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
|
||||||
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
|
||||||
github.com/google/go-cmp v0.4.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
|
||||||
github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
|
||||||
github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
|
||||||
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
|
||||||
github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
|
||||||
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
|
||||||
github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
|
||||||
github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
|
||||||
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||||
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
|
|
||||||
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
|
|
||||||
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
|
||||||
github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs=
|
|
||||||
github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0=
|
|
||||||
github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc=
|
|
||||||
github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc=
|
|
||||||
github.com/google/pprof v0.0.0-20191218002539-d4f498aebedc/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
|
|
||||||
github.com/google/pprof v0.0.0-20200212024743-f11f1df84d12/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
|
|
||||||
github.com/google/pprof v0.0.0-20200229191704-1ebb73c60ed3/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
|
|
||||||
github.com/google/pprof v0.0.0-20200430221834-fc25d7d30c6d/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
|
|
||||||
github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
|
|
||||||
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
|
|
||||||
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
||||||
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||||
github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg=
|
|
||||||
github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk=
|
|
||||||
github.com/gordonklaus/ineffassign v0.1.0 h1:y2Gd/9I7MdY1oEIt+n+rowjBNDcLQq3RsH5hwJd0f9s=
|
|
||||||
github.com/gordonklaus/ineffassign v0.1.0/go.mod h1:Qcp2HIAYhR7mNUVSIxZww3Guk4it82ghYcEXIAk+QT0=
|
|
||||||
github.com/gostaticanalysis/analysisutil v0.7.1 h1:ZMCjoue3DtDWQ5WyU16YbjbQEQ3VuzwxALrpYd+HeKk=
|
|
||||||
github.com/gostaticanalysis/analysisutil v0.7.1/go.mod h1:v21E3hY37WKMGSnbsw2S/ojApNWb6C1//mXO48CXbVc=
|
|
||||||
github.com/gostaticanalysis/comment v1.4.1/go.mod h1:ih6ZxzTHLdadaiSnF5WY3dxUoXfXAlTaRzuaNDlSado=
|
|
||||||
github.com/gostaticanalysis/comment v1.4.2/go.mod h1:KLUTGDv6HOCotCH8h2erHKmpci2ZoR8VPu34YA2uzdM=
|
|
||||||
github.com/gostaticanalysis/comment v1.5.0 h1:X82FLl+TswsUMpMh17srGRuKaaXprTaytmEpgnKIDu8=
|
|
||||||
github.com/gostaticanalysis/comment v1.5.0/go.mod h1:V6eb3gpCv9GNVqb6amXzEUX3jXLVK/AdA+IrAMSqvEc=
|
|
||||||
github.com/gostaticanalysis/forcetypeassert v0.2.0 h1:uSnWrrUEYDr86OCxWa4/Tp2jeYDlogZiZHzGkWFefTk=
|
|
||||||
github.com/gostaticanalysis/forcetypeassert v0.2.0/go.mod h1:M5iPavzE9pPqWyeiVXSFghQjljW1+l/Uke3PXHS6ILY=
|
|
||||||
github.com/gostaticanalysis/nilerr v0.1.1 h1:ThE+hJP0fEp4zWLkWHWcRyI2Od0p7DlgYG3Uqrmrcpk=
|
|
||||||
github.com/gostaticanalysis/nilerr v0.1.1/go.mod h1:wZYb6YI5YAxxq0i1+VJbY0s2YONW0HU0GPE3+5PWN4A=
|
|
||||||
github.com/gostaticanalysis/testutil v0.3.1-0.20210208050101-bfb5c8eec0e4/go.mod h1:D+FIZ+7OahH3ePw/izIEeH5I06eKs1IKI4Xr64/Am3M=
|
|
||||||
github.com/hashicorp/go-immutable-radix/v2 v2.1.0 h1:CUW5RYIcysz+D3B+l1mDeXrQ7fUvGGCwJfdASSzbrfo=
|
|
||||||
github.com/hashicorp/go-immutable-radix/v2 v2.1.0/go.mod h1:hgdqLXA4f6NIjRVisM1TJ9aOJVNRqKZj+xDGF6m7PBw=
|
|
||||||
github.com/hashicorp/go-version v1.2.1/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
|
|
||||||
github.com/hashicorp/go-version v1.7.0 h1:5tqGy27NaOTB8yJKUZELlFAS/LTKJkrmONwQKeRZfjY=
|
|
||||||
github.com/hashicorp/go-version v1.7.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
|
|
||||||
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
|
|
||||||
github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
|
|
||||||
github.com/hashicorp/golang-lru/v2 v2.0.7 h1:a+bsQ5rvGLjzHuww6tVxozPZFVghXaHOwFs4luLUK2k=
|
|
||||||
github.com/hashicorp/golang-lru/v2 v2.0.7/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM=
|
|
||||||
github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
|
|
||||||
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
|
|
||||||
github.com/hexops/gotextdiff v1.0.3 h1:gitA9+qJrrTCsiCl7+kh75nPqQt1cx4ZkudSTLoUqJM=
|
|
||||||
github.com/hexops/gotextdiff v1.0.3/go.mod h1:pSWU5MAI3yDq+fZBTazCSJysOMbxWL1BSow5/V2vxeg=
|
|
||||||
github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
|
|
||||||
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
|
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
|
||||||
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
|
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
|
||||||
github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM=
|
github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM=
|
||||||
@@ -301,482 +20,88 @@ github.com/jackc/pgx/v5 v5.7.6 h1:rWQc5FwZSPX58r1OQmkuaNicxdmExaEz5A2DO2hUuTk=
|
|||||||
github.com/jackc/pgx/v5 v5.7.6/go.mod h1:aruU7o91Tc2q2cFp5h4uP3f6ztExVpyVv88Xl/8Vl8M=
|
github.com/jackc/pgx/v5 v5.7.6/go.mod h1:aruU7o91Tc2q2cFp5h4uP3f6ztExVpyVv88Xl/8Vl8M=
|
||||||
github.com/jackc/puddle/v2 v2.2.2 h1:PR8nw+E/1w0GLuRFSmiioY6UooMp6KJv0/61nB7icHo=
|
github.com/jackc/puddle/v2 v2.2.2 h1:PR8nw+E/1w0GLuRFSmiioY6UooMp6KJv0/61nB7icHo=
|
||||||
github.com/jackc/puddle/v2 v2.2.2/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4=
|
github.com/jackc/puddle/v2 v2.2.2/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4=
|
||||||
github.com/jgautheron/goconst v1.7.1 h1:VpdAG7Ca7yvvJk5n8dMwQhfEZJh95kl/Hl9S1OI5Jkk=
|
|
||||||
github.com/jgautheron/goconst v1.7.1/go.mod h1:aAosetZ5zaeC/2EfMeRswtxUFBpe2Hr7HzkgX4fanO4=
|
|
||||||
github.com/jingyugao/rowserrcheck v1.1.1 h1:zibz55j/MJtLsjP1OF4bSdgXxwL1b+Vn7Tjzq7gFzUs=
|
|
||||||
github.com/jingyugao/rowserrcheck v1.1.1/go.mod h1:4yvlZSDb3IyDTUZJUmpZfm2Hwok+Dtp+nu2qOq+er9c=
|
|
||||||
github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E=
|
github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E=
|
||||||
github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
|
github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
|
||||||
github.com/jjti/go-spancheck v0.6.4 h1:Tl7gQpYf4/TMU7AT84MN83/6PutY21Nb9fuQjFTpRRc=
|
|
||||||
github.com/jjti/go-spancheck v0.6.4/go.mod h1:yAEYdKJ2lRkDA8g7X+oKUHXOWVAXSBJRv04OhF+QUjk=
|
|
||||||
github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4=
|
|
||||||
github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
|
|
||||||
github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
|
|
||||||
github.com/json-iterator/go v1.1.11/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
|
|
||||||
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
|
|
||||||
github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU=
|
|
||||||
github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk=
|
|
||||||
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
|
|
||||||
github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM=
|
|
||||||
github.com/julz/importas v0.2.0 h1:y+MJN/UdL63QbFJHws9BVC5RpA2iq0kpjrFajTGivjQ=
|
|
||||||
github.com/julz/importas v0.2.0/go.mod h1:pThlt589EnCYtMnmhmRYY/qn9lCf/frPOK+WMx3xiJY=
|
|
||||||
github.com/karamaru-alpha/copyloopvar v1.2.1 h1:wmZaZYIjnJ0b5UoKDjUHrikcV0zuPyyxI4SVplLd2CI=
|
|
||||||
github.com/karamaru-alpha/copyloopvar v1.2.1/go.mod h1:nFmMlFNlClC2BPvNaHMdkirmTJxVCY0lhxBtlfOypMM=
|
|
||||||
github.com/kisielk/errcheck v1.9.0 h1:9xt1zI9EBfcYBvdU1nVrzMzzUPUtPKs9bVSIM3TAb3M=
|
|
||||||
github.com/kisielk/errcheck v1.9.0/go.mod h1:kQxWMMVZgIkDq7U8xtG/n2juOjbLgZtedi0D+/VL/i8=
|
|
||||||
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
|
|
||||||
github.com/kkHAIKE/contextcheck v1.1.6 h1:7HIyRcnyzxL9Lz06NGhiKvenXq7Zw6Q0UQu/ttjfJCE=
|
|
||||||
github.com/kkHAIKE/contextcheck v1.1.6/go.mod h1:3dDbMRNBFaq8HFXWC1JyvDSPm43CmE6IuHam8Wr0rkg=
|
|
||||||
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
|
||||||
github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
|
||||||
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
|
|
||||||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
|
||||||
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
|
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
|
||||||
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
|
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
|
||||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
|
||||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
|
||||||
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||||
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
||||||
github.com/kulti/thelper v0.6.3 h1:ElhKf+AlItIu+xGnI990no4cE2+XaSu1ULymV2Yulxs=
|
|
||||||
github.com/kulti/thelper v0.6.3/go.mod h1:DsqKShOvP40epevkFrvIwkCMNYxMeTNjdWL4dqWHZ6I=
|
|
||||||
github.com/kunwardeep/paralleltest v1.0.10 h1:wrodoaKYzS2mdNVnc4/w31YaXFtsc21PCTdvWJ/lDDs=
|
|
||||||
github.com/kunwardeep/paralleltest v1.0.10/go.mod h1:2C7s65hONVqY7Q5Efj5aLzRCNLjw2h4eMc9EcypGjcY=
|
|
||||||
github.com/lasiar/canonicalheader v1.1.2 h1:vZ5uqwvDbyJCnMhmFYimgMZnJMjwljN5VGY0VKbMXb4=
|
|
||||||
github.com/lasiar/canonicalheader v1.1.2/go.mod h1:qJCeLFS0G/QlLQ506T+Fk/fWMa2VmBUiEI2cuMK4djI=
|
|
||||||
github.com/ldez/exptostd v0.4.2 h1:l5pOzHBz8mFOlbcifTxzfyYbgEmoUqjxLFHZkjlbHXs=
|
|
||||||
github.com/ldez/exptostd v0.4.2/go.mod h1:iZBRYaUmcW5jwCR3KROEZ1KivQQp6PHXbDPk9hqJKCQ=
|
|
||||||
github.com/ldez/gomoddirectives v0.6.1 h1:Z+PxGAY+217f/bSGjNZr/b2KTXcyYLgiWI6geMBN2Qc=
|
|
||||||
github.com/ldez/gomoddirectives v0.6.1/go.mod h1:cVBiu3AHR9V31em9u2kwfMKD43ayN5/XDgr+cdaFaKs=
|
|
||||||
github.com/ldez/grignotin v0.9.0 h1:MgOEmjZIVNn6p5wPaGp/0OKWyvq42KnzAt/DAb8O4Ow=
|
|
||||||
github.com/ldez/grignotin v0.9.0/go.mod h1:uaVTr0SoZ1KBii33c47O1M8Jp3OP3YDwhZCmzT9GHEk=
|
|
||||||
github.com/ldez/tagliatelle v0.7.1 h1:bTgKjjc2sQcsgPiT902+aadvMjCeMHrY7ly2XKFORIk=
|
|
||||||
github.com/ldez/tagliatelle v0.7.1/go.mod h1:3zjxUpsNB2aEZScWiZTHrAXOl1x25t3cRmzfK1mlo2I=
|
|
||||||
github.com/ldez/usetesting v0.4.2 h1:J2WwbrFGk3wx4cZwSMiCQQ00kjGR0+tuuyW0Lqm4lwA=
|
|
||||||
github.com/ldez/usetesting v0.4.2/go.mod h1:eEs46T3PpQ+9RgN9VjpY6qWdiw2/QmfiDeWmdZdrjIQ=
|
|
||||||
github.com/leonklingele/grouper v1.1.2 h1:o1ARBDLOmmasUaNDesWqWCIFH3u7hoFlM84YrjT3mIY=
|
|
||||||
github.com/leonklingele/grouper v1.1.2/go.mod h1:6D0M/HVkhs2yRKRFZUoGjeDy7EZTfFBE9gl4kjmIGkA=
|
|
||||||
github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY=
|
github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY=
|
||||||
github.com/lucasb-eyer/go-colorful v1.2.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
|
github.com/lucasb-eyer/go-colorful v1.2.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
|
||||||
github.com/macabu/inamedparam v0.1.3 h1:2tk/phHkMlEL/1GNe/Yf6kkR/hkcUdAEY3L0hjYV1Mk=
|
|
||||||
github.com/macabu/inamedparam v0.1.3/go.mod h1:93FLICAIk/quk7eaPPQvbzihUdn/QkGDwIZEoLtpH6I=
|
|
||||||
github.com/magiconair/properties v1.8.6 h1:5ibWZ6iY0NctNGWo87LalDlEZ6R41TqbbDamhfG/Qzo=
|
|
||||||
github.com/magiconair/properties v1.8.6/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60=
|
|
||||||
github.com/maratori/testableexamples v1.0.0 h1:dU5alXRrD8WKSjOUnmJZuzdxWOEQ57+7s93SLMxb2vI=
|
|
||||||
github.com/maratori/testableexamples v1.0.0/go.mod h1:4rhjL1n20TUTT4vdh3RDqSizKLyXp7K2u6HgraZCGzE=
|
|
||||||
github.com/maratori/testpackage v1.1.1 h1:S58XVV5AD7HADMmD0fNnziNHqKvSdDuEKdPD1rNTU04=
|
|
||||||
github.com/maratori/testpackage v1.1.1/go.mod h1:s4gRK/ym6AMrqpOa/kEbQTV4Q4jb7WeLZzVhVVVOQMc=
|
|
||||||
github.com/matoous/godox v1.1.0 h1:W5mqwbyWrwZv6OQ5Z1a/DHGMOvXYCBP3+Ht7KMoJhq4=
|
|
||||||
github.com/matoous/godox v1.1.0/go.mod h1:jgE/3fUXiTurkdHOLT5WEkThTSuE7yxHv5iWPa80afs=
|
|
||||||
github.com/matryer/is v1.4.0/go.mod h1:8I/i5uYgLzgsgEloJE1U6xx5HkBQpAZvepWuujKwMRU=
|
|
||||||
github.com/mattn/go-colorable v0.1.14 h1:9A9LHSqF/7dyVVX6g0U9cwm9pG3kP9gSzcuIPHPsaIE=
|
|
||||||
github.com/mattn/go-colorable v0.1.14/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8=
|
|
||||||
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
|
|
||||||
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
|
||||||
github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
|
|
||||||
github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc=
|
github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc=
|
||||||
github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
|
github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
|
||||||
github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU=
|
|
||||||
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
|
|
||||||
github.com/mgechev/revive v1.7.0 h1:JyeQ4yO5K8aZhIKf5rec56u0376h8AlKNQEmjfkjKlY=
|
|
||||||
github.com/mgechev/revive v1.7.0/go.mod h1:qZnwcNhoguE58dfi96IJeSTPeZQejNeoMQLUZGi4SW4=
|
|
||||||
github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=
|
|
||||||
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
|
|
||||||
github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
|
|
||||||
github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
|
|
||||||
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
|
||||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
|
||||||
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
|
||||||
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
|
||||||
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
|
|
||||||
github.com/moricho/tparallel v0.3.2 h1:odr8aZVFA3NZrNybggMkYO3rgPRcqjeQUlBBFVxKHTI=
|
|
||||||
github.com/moricho/tparallel v0.3.2/go.mod h1:OQ+K3b4Ln3l2TZveGCywybl68glfLEwFGqvnjok8b+U=
|
|
||||||
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
|
|
||||||
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
|
|
||||||
github.com/nakabonne/nestif v0.3.1 h1:wm28nZjhQY5HyYPx+weN3Q65k6ilSBxDb8v5S81B81U=
|
|
||||||
github.com/nakabonne/nestif v0.3.1/go.mod h1:9EtoZochLn5iUprVDmDjqGKPofoUEBL8U4Ngq6aY7OE=
|
|
||||||
github.com/nishanths/exhaustive v0.12.0 h1:vIY9sALmw6T/yxiASewa4TQcFsVYZQQRUQJhKRf3Swg=
|
|
||||||
github.com/nishanths/exhaustive v0.12.0/go.mod h1:mEZ95wPIZW+x8kC4TgC+9YCUgiST7ecevsVDTgc2obs=
|
|
||||||
github.com/nishanths/predeclared v0.2.2 h1:V2EPdZPliZymNAn79T8RkNApBjMmVKh5XRpLm/w98Vk=
|
|
||||||
github.com/nishanths/predeclared v0.2.2/go.mod h1:RROzoN6TnGQupbC+lqggsOlcgysk3LMK/HI84Mp280c=
|
|
||||||
github.com/nunnatsa/ginkgolinter v0.19.1 h1:mjwbOlDQxZi9Cal+KfbEJTCz327OLNfwNvoZ70NJ+c4=
|
|
||||||
github.com/nunnatsa/ginkgolinter v0.19.1/go.mod h1:jkQ3naZDmxaZMXPWaS9rblH+i+GWXQCaS/JFIWcOH2s=
|
|
||||||
github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec=
|
|
||||||
github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY=
|
|
||||||
github.com/otiai10/copy v1.2.0/go.mod h1:rrF5dJ5F0t/EWSYODDu4j9/vEeYHMkc8jt0zJChqQWw=
|
|
||||||
github.com/otiai10/curr v0.0.0-20150429015615-9b4961190c95/go.mod h1:9qAhocn7zKJG+0mI8eUu6xqkFDYS2kb2saOteoSB3cE=
|
|
||||||
github.com/otiai10/curr v1.0.0/go.mod h1:LskTG5wDwr8Rs+nNQ+1LlxRjAtTZZjtJW4rMXl6j4vs=
|
|
||||||
github.com/otiai10/mint v1.3.0/go.mod h1:F5AjcsTsWUqX+Na9fpHb52P8pcRX2CI6A3ctIT91xUo=
|
|
||||||
github.com/otiai10/mint v1.3.1/go.mod h1:/yxELlJQ0ufhjUwhshSj+wFjZ78CnZ48/1wtmBH1OTc=
|
|
||||||
github.com/pelletier/go-toml v1.9.5 h1:4yBQzkHv+7BHq2PQUZF3Mx0IYxG7LsP222s7Agd3ve8=
|
|
||||||
github.com/pelletier/go-toml v1.9.5/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c=
|
|
||||||
github.com/pelletier/go-toml/v2 v2.2.3 h1:YmeHyLY8mFWbdkNWwpr+qIL2bEqT0o95WSdkNHvL12M=
|
|
||||||
github.com/pelletier/go-toml/v2 v2.2.3/go.mod h1:MfCQTFTvCcUyyvvwm1+G6H/jORL20Xlb6rzQu9GuUkc=
|
|
||||||
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
|
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
|
||||||
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
|
||||||
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
|
||||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
|
||||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
github.com/polyfloyd/go-errorlint v1.7.1 h1:RyLVXIbosq1gBdk/pChWA8zWYLsq9UEw7a1L5TVMCnA=
|
|
||||||
github.com/polyfloyd/go-errorlint v1.7.1/go.mod h1:aXjNb1x2TNhoLsk26iv1yl7a+zTnXPhwEMtEXukiLR8=
|
|
||||||
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
|
|
||||||
github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo=
|
|
||||||
github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M=
|
|
||||||
github.com/prometheus/client_golang v1.11.0/go.mod h1:Z6t4BnS23TR94PD6BsDNk8yVqroYurpAkEiz0P2BEV0=
|
|
||||||
github.com/prometheus/client_golang v1.12.1 h1:ZiaPsmm9uiBeaSMRznKsCDNtPCS0T3JVDGF+06gjBzk=
|
|
||||||
github.com/prometheus/client_golang v1.12.1/go.mod h1:3Z9XVyYiZYEO+YQWt3RD2R3jrbd179Rt297l4aS6nDY=
|
|
||||||
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
|
|
||||||
github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
|
||||||
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
|
||||||
github.com/prometheus/client_model v0.2.0 h1:uq5h0d+GuxiXLJLNABMgp2qUWDPiLvgCzz2dUR+/W/M=
|
|
||||||
github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
|
||||||
github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4=
|
|
||||||
github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo=
|
|
||||||
github.com/prometheus/common v0.26.0/go.mod h1:M7rCNAaPfAosfx8veZJCuw84e35h3Cfd9VFqTh1DIvc=
|
|
||||||
github.com/prometheus/common v0.32.1 h1:hWIdL3N2HoUx3B8j3YN9mWor0qhY/NlEKZEaXxuIRh4=
|
|
||||||
github.com/prometheus/common v0.32.1/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls=
|
|
||||||
github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
|
|
||||||
github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
|
|
||||||
github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU=
|
|
||||||
github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA=
|
|
||||||
github.com/prometheus/procfs v0.7.3 h1:4jVXhlkAyzOScmCkXBTOLRLTz8EeU+eyjrwB/EPq0VU=
|
|
||||||
github.com/prometheus/procfs v0.7.3/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA=
|
|
||||||
github.com/puzpuzpuz/xsync/v3 v3.5.1 h1:GJYJZwO6IdxN/IKbneznS6yPkVC+c3zyY/j19c++5Fg=
|
github.com/puzpuzpuz/xsync/v3 v3.5.1 h1:GJYJZwO6IdxN/IKbneznS6yPkVC+c3zyY/j19c++5Fg=
|
||||||
github.com/puzpuzpuz/xsync/v3 v3.5.1/go.mod h1:VjzYrABPabuM4KyBh1Ftq6u8nhwY5tBPKP9jpmh0nnA=
|
github.com/puzpuzpuz/xsync/v3 v3.5.1/go.mod h1:VjzYrABPabuM4KyBh1Ftq6u8nhwY5tBPKP9jpmh0nnA=
|
||||||
github.com/quasilyte/go-ruleguard v0.4.3-0.20240823090925-0fe6f58b47b1 h1:+Wl/0aFp0hpuHM3H//KMft64WQ1yX9LdJY64Qm/gFCo=
|
|
||||||
github.com/quasilyte/go-ruleguard v0.4.3-0.20240823090925-0fe6f58b47b1/go.mod h1:GJLgqsLeo4qgavUoL8JeGFNS7qcisx3awV/w9eWTmNI=
|
|
||||||
github.com/quasilyte/go-ruleguard/dsl v0.3.22 h1:wd8zkOhSNr+I+8Qeciml08ivDt1pSXe60+5DqOpCjPE=
|
|
||||||
github.com/quasilyte/go-ruleguard/dsl v0.3.22/go.mod h1:KeCP03KrjuSO0H1kTuZQCWlQPulDV6YMIXmpQss17rU=
|
|
||||||
github.com/quasilyte/gogrep v0.5.0 h1:eTKODPXbI8ffJMN+W2aE0+oL0z/nh8/5eNdiO34SOAo=
|
|
||||||
github.com/quasilyte/gogrep v0.5.0/go.mod h1:Cm9lpz9NZjEoL1tgZ2OgeUKPIxL1meE7eo60Z6Sk+Ng=
|
|
||||||
github.com/quasilyte/regex/syntax v0.0.0-20210819130434-b3f0c404a727 h1:TCg2WBOl980XxGFEZSS6KlBGIV0diGdySzxATTWoqaU=
|
|
||||||
github.com/quasilyte/regex/syntax v0.0.0-20210819130434-b3f0c404a727/go.mod h1:rlzQ04UMyJXu/aOvhd8qT+hvDrFpiwqp8MRXDY9szc0=
|
|
||||||
github.com/quasilyte/stdinfo v0.0.0-20220114132959-f7386bf02567 h1:M8mH9eK4OUR4lu7Gd+PU1fV2/qnDNfzT635KRSObncs=
|
|
||||||
github.com/quasilyte/stdinfo v0.0.0-20220114132959-f7386bf02567/go.mod h1:DWNGW8A4Y+GyBgPuaQJuWiy0XYftx4Xm/y5Jqk9I6VQ=
|
|
||||||
github.com/raeperd/recvcheck v0.2.0 h1:GnU+NsbiCqdC2XX5+vMZzP+jAJC5fht7rcVTAhX74UI=
|
|
||||||
github.com/raeperd/recvcheck v0.2.0/go.mod h1:n04eYkwIR0JbgD73wT8wL4JjPC3wm0nFtzBnWNocnYU=
|
|
||||||
github.com/rivo/tview v0.42.0 h1:b/ftp+RxtDsHSaynXTbJb+/n/BxDEi+W3UfF5jILK6c=
|
github.com/rivo/tview v0.42.0 h1:b/ftp+RxtDsHSaynXTbJb+/n/BxDEi+W3UfF5jILK6c=
|
||||||
github.com/rivo/tview v0.42.0/go.mod h1:cSfIYfhpSGCjp3r/ECJb+GKS7cGJnqV8vfjQPwoXyfY=
|
github.com/rivo/tview v0.42.0/go.mod h1:cSfIYfhpSGCjp3r/ECJb+GKS7cGJnqV8vfjQPwoXyfY=
|
||||||
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
|
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
|
||||||
github.com/rivo/uniseg v0.4.3/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
|
github.com/rivo/uniseg v0.4.3/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
|
||||||
github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
|
github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
|
||||||
github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
|
github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
|
||||||
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
|
|
||||||
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
|
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
|
||||||
github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ=
|
github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ=
|
||||||
github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc=
|
github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc=
|
||||||
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
||||||
github.com/ryancurrah/gomodguard v1.3.5 h1:cShyguSwUEeC0jS7ylOiG/idnd1TpJ1LfHGpV3oJmPU=
|
|
||||||
github.com/ryancurrah/gomodguard v1.3.5/go.mod h1:MXlEPQRxgfPQa62O8wzK3Ozbkv9Rkqr+wKjSxTdsNJE=
|
|
||||||
github.com/ryanrolds/sqlclosecheck v0.5.1 h1:dibWW826u0P8jNLsLN+En7+RqWWTYrjCB9fJfSfdyCU=
|
|
||||||
github.com/ryanrolds/sqlclosecheck v0.5.1/go.mod h1:2g3dUjoS6AL4huFdv6wn55WpLIDjY7ZgUR4J8HOO/XQ=
|
|
||||||
github.com/sanposhiho/wastedassign/v2 v2.1.0 h1:crurBF7fJKIORrV85u9UUpePDYGWnwvv3+A96WvwXT0=
|
|
||||||
github.com/sanposhiho/wastedassign/v2 v2.1.0/go.mod h1:+oSmSC+9bQ+VUAxA66nBb0Z7N8CK7mscKTDYC6aIek4=
|
|
||||||
github.com/santhosh-tekuri/jsonschema/v6 v6.0.1 h1:PKK9DyHxif4LZo+uQSgXNqs0jj5+xZwwfKHgph2lxBw=
|
|
||||||
github.com/santhosh-tekuri/jsonschema/v6 v6.0.1/go.mod h1:JXeL+ps8p7/KNMjDQk3TCwPpBy0wYklyWTfbkIzdIFU=
|
|
||||||
github.com/sashamelentyev/interfacebloat v1.1.0 h1:xdRdJp0irL086OyW1H/RTZTr1h/tMEOsumirXcOJqAw=
|
|
||||||
github.com/sashamelentyev/interfacebloat v1.1.0/go.mod h1:+Y9yU5YdTkrNvoX0xHc84dxiN1iBi9+G8zZIhPVoNjQ=
|
|
||||||
github.com/sashamelentyev/usestdlibvars v1.28.0 h1:jZnudE2zKCtYlGzLVreNp5pmCdOxXUzwsMDBkR21cyQ=
|
|
||||||
github.com/sashamelentyev/usestdlibvars v1.28.0/go.mod h1:9nl0jgOfHKWNFS43Ojw0i7aRoS4j6EBye3YBhmAIRF8=
|
|
||||||
github.com/securego/gosec/v2 v2.22.2 h1:IXbuI7cJninj0nRpZSLCUlotsj8jGusohfONMrHoF6g=
|
|
||||||
github.com/securego/gosec/v2 v2.22.2/go.mod h1:UEBGA+dSKb+VqM6TdehR7lnQtIIMorYJ4/9CW1KVQBE=
|
|
||||||
github.com/shurcooL/go v0.0.0-20180423040247-9e1955d9fb6e/go.mod h1:TDJrrUr11Vxrven61rcy3hJMUqaf/CLWYhHNPmT14Lk=
|
|
||||||
github.com/shurcooL/go-goon v0.0.0-20170922171312-37c2f522c041/go.mod h1:N5mDOmsrJOB+vfqUK+7DmDyjhSLIIBnXo9lvZJj3MWQ=
|
|
||||||
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
|
|
||||||
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
|
|
||||||
github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88=
|
|
||||||
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
|
|
||||||
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
|
|
||||||
github.com/sivchari/containedctx v1.0.3 h1:x+etemjbsh2fB5ewm5FeLNi5bUjK0V8n0RB+Wwfd0XE=
|
|
||||||
github.com/sivchari/containedctx v1.0.3/go.mod h1:c1RDvCbnJLtH4lLcYD/GqwiBSSf4F5Qk0xld2rBqzJ4=
|
|
||||||
github.com/sivchari/tenv v1.12.1 h1:+E0QzjktdnExv/wwsnnyk4oqZBUfuh89YMQT1cyuvSY=
|
|
||||||
github.com/sivchari/tenv v1.12.1/go.mod h1:1LjSOUCc25snIr5n3DtGGrENhX3LuWefcplwVGC24mw=
|
|
||||||
github.com/sonatard/noctx v0.1.0 h1:JjqOc2WN16ISWAjAk8M5ej0RfExEXtkEyExl2hLW+OM=
|
|
||||||
github.com/sonatard/noctx v0.1.0/go.mod h1:0RvBxqY8D4j9cTTTWE8ylt2vqj2EPI8fHmrxHdsaZ2c=
|
|
||||||
github.com/sourcegraph/go-diff v0.7.0 h1:9uLlrd5T46OXs5qpp8L/MTltk0zikUGi0sNNyCpA8G0=
|
|
||||||
github.com/sourcegraph/go-diff v0.7.0/go.mod h1:iBszgVvyxdc8SFZ7gm69go2KDdt3ag071iBaWPF6cjs=
|
|
||||||
github.com/spf13/afero v1.12.0 h1:UcOPyRBYczmFn6yvphxkn9ZEOY65cpwGKb5mL36mrqs=
|
|
||||||
github.com/spf13/afero v1.12.0/go.mod h1:ZTlWwG4/ahT8W7T0WQ5uYmjI9duaLQGy3Q2OAl4sk/4=
|
|
||||||
github.com/spf13/cast v1.5.0 h1:rj3WzYc11XZaIZMPKmwP96zkFEnnAmV8s6XbB2aY32w=
|
|
||||||
github.com/spf13/cast v1.5.0/go.mod h1:SpXXQ5YoyJw6s3/6cMTQuxvgRl3PCJiyaX9p6b155UU=
|
|
||||||
github.com/spf13/cobra v1.10.2 h1:DMTTonx5m65Ic0GOoRY2c16WCbHxOOw6xxezuLaBpcU=
|
github.com/spf13/cobra v1.10.2 h1:DMTTonx5m65Ic0GOoRY2c16WCbHxOOw6xxezuLaBpcU=
|
||||||
github.com/spf13/cobra v1.10.2/go.mod h1:7C1pvHqHw5A4vrJfjNwvOdzYu0Gml16OCs2GRiTUUS4=
|
github.com/spf13/cobra v1.10.2/go.mod h1:7C1pvHqHw5A4vrJfjNwvOdzYu0Gml16OCs2GRiTUUS4=
|
||||||
github.com/spf13/jwalterweatherman v1.1.0 h1:ue6voC5bR5F8YxI5S67j9i582FU4Qvo2bmqnqMYADFk=
|
|
||||||
github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0EXowPYD95IqWIGo=
|
|
||||||
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
|
|
||||||
github.com/spf13/pflag v1.0.9/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
|
github.com/spf13/pflag v1.0.9/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
|
||||||
github.com/spf13/pflag v1.0.10 h1:4EBh2KAYBwaONj6b2Ye1GiHfwjqyROoF4RwYO+vPwFk=
|
github.com/spf13/pflag v1.0.10 h1:4EBh2KAYBwaONj6b2Ye1GiHfwjqyROoF4RwYO+vPwFk=
|
||||||
github.com/spf13/pflag v1.0.10/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
|
github.com/spf13/pflag v1.0.10/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
|
||||||
github.com/spf13/viper v1.12.0 h1:CZ7eSOd3kZoaYDLbXnmzgQI5RlciuXBMA+18HwHRfZQ=
|
|
||||||
github.com/spf13/viper v1.12.0/go.mod h1:b6COn30jlNxbm/V2IqWiNWkJ+vZNiMNksliPCiuKtSI=
|
|
||||||
github.com/ssgreg/nlreturn/v2 v2.2.1 h1:X4XDI7jstt3ySqGU86YGAURbxw3oTDPK9sPEi6YEwQ0=
|
|
||||||
github.com/ssgreg/nlreturn/v2 v2.2.1/go.mod h1:E/iiPB78hV7Szg2YfRgyIrk1AD6JVMTRkkxBiELzh2I=
|
|
||||||
github.com/stbenjam/no-sprintf-host-port v0.2.0 h1:i8pxvGrt1+4G0czLr/WnmyH7zbZ8Bg8etvARQ1rpyl4=
|
|
||||||
github.com/stbenjam/no-sprintf-host-port v0.2.0/go.mod h1:eL0bQ9PasS0hsyTyfTjjG+E80QIyPnBVQbYZyv20Jfk=
|
|
||||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||||
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
|
||||||
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
|
||||||
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
|
|
||||||
github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY=
|
|
||||||
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
|
|
||||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
|
||||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
|
||||||
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
|
|
||||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||||
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
|
||||||
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
|
||||||
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
|
|
||||||
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
|
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
|
||||||
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
|
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
|
||||||
github.com/subosito/gotenv v1.4.1 h1:jyEFiXpy21Wm81FBN71l9VoMMV8H8jG+qIK3GCpY6Qs=
|
|
||||||
github.com/subosito/gotenv v1.4.1/go.mod h1:ayKnFf/c6rvx/2iiLrJUk1e6plDbT3edrFNGqEflhK0=
|
|
||||||
github.com/tdakkota/asciicheck v0.4.1 h1:bm0tbcmi0jezRA2b5kg4ozmMuGAFotKI3RZfrhfovg8=
|
|
||||||
github.com/tdakkota/asciicheck v0.4.1/go.mod h1:0k7M3rCfRXb0Z6bwgvkEIMleKH3kXNz9UqJ9Xuqopr8=
|
|
||||||
github.com/tenntenn/modver v1.0.1/go.mod h1:bePIyQPb7UeioSRkw3Q0XeMhYZSMx9B8ePqg6SAMGH0=
|
|
||||||
github.com/tenntenn/text/transform v0.0.0-20200319021203-7eef512accb3/go.mod h1:ON8b8w4BN/kE1EOhwT0o+d62W65a6aPw1nouo9LMgyY=
|
|
||||||
github.com/tetafro/godot v1.5.0 h1:aNwfVI4I3+gdxjMgYPus9eHmoBeJIbnajOyqZYStzuw=
|
|
||||||
github.com/tetafro/godot v1.5.0/go.mod h1:2oVxTBSftRTh4+MVfUaUXR6bn2GDXCaMcOG4Dk3rfio=
|
|
||||||
github.com/timakin/bodyclose v0.0.0-20241017074812-ed6a65f985e3 h1:y4mJRFlM6fUyPhoXuFg/Yu02fg/nIPFMOY8tOqppoFg=
|
|
||||||
github.com/timakin/bodyclose v0.0.0-20241017074812-ed6a65f985e3/go.mod h1:mkjARE7Yr8qU23YcGMSALbIxTQ9r9QBVahQOBRfU460=
|
|
||||||
github.com/timonwong/loggercheck v0.10.1 h1:uVZYClxQFpw55eh+PIoqM7uAOHMrhVcDoWDery9R8Lg=
|
|
||||||
github.com/timonwong/loggercheck v0.10.1/go.mod h1:HEAWU8djynujaAVX7QI65Myb8qgfcZ1uKbdpg3ZzKl8=
|
|
||||||
github.com/tmthrgd/go-hex v0.0.0-20190904060850-447a3041c3bc h1:9lRDQMhESg+zvGYmW5DyG0UqvY96Bu5QYsTLvCHdrgo=
|
github.com/tmthrgd/go-hex v0.0.0-20190904060850-447a3041c3bc h1:9lRDQMhESg+zvGYmW5DyG0UqvY96Bu5QYsTLvCHdrgo=
|
||||||
github.com/tmthrgd/go-hex v0.0.0-20190904060850-447a3041c3bc/go.mod h1:bciPuU6GHm1iF1pBvUfxfsH0Wmnc2VbpgvbI9ZWuIRs=
|
github.com/tmthrgd/go-hex v0.0.0-20190904060850-447a3041c3bc/go.mod h1:bciPuU6GHm1iF1pBvUfxfsH0Wmnc2VbpgvbI9ZWuIRs=
|
||||||
github.com/tomarrell/wrapcheck/v2 v2.10.0 h1:SzRCryzy4IrAH7bVGG4cK40tNUhmVmMDuJujy4XwYDg=
|
|
||||||
github.com/tomarrell/wrapcheck/v2 v2.10.0/go.mod h1:g9vNIyhb5/9TQgumxQyOEqDHsmGYcGsVMOx/xGkqdMo=
|
|
||||||
github.com/tommy-muehle/go-mnd/v2 v2.5.1 h1:NowYhSdyE/1zwK9QCLeRb6USWdoif80Ie+v+yU8u1Zw=
|
|
||||||
github.com/tommy-muehle/go-mnd/v2 v2.5.1/go.mod h1:WsUAkMJMYww6l/ufffCD3m+P7LEvr8TnZn9lwVDlgzw=
|
|
||||||
github.com/ultraware/funlen v0.2.0 h1:gCHmCn+d2/1SemTdYMiKLAHFYxTYz7z9VIDRaTGyLkI=
|
|
||||||
github.com/ultraware/funlen v0.2.0/go.mod h1:ZE0q4TsJ8T1SQcjmkhN/w+MceuatI6pBFSxxyteHIJA=
|
|
||||||
github.com/ultraware/whitespace v0.2.0 h1:TYowo2m9Nfj1baEQBjuHzvMRbp19i+RCcRYrSWoFa+g=
|
|
||||||
github.com/ultraware/whitespace v0.2.0/go.mod h1:XcP1RLD81eV4BW8UhQlpaR+SDc2givTvyI8a586WjW8=
|
|
||||||
github.com/uptrace/bun v1.2.16 h1:QlObi6ZIK5Ao7kAALnh91HWYNZUBbVwye52fmlQM9kc=
|
github.com/uptrace/bun v1.2.16 h1:QlObi6ZIK5Ao7kAALnh91HWYNZUBbVwye52fmlQM9kc=
|
||||||
github.com/uptrace/bun v1.2.16/go.mod h1:jMoNg2n56ckaawi/O/J92BHaECmrz6IRjuMWqlMaMTM=
|
github.com/uptrace/bun v1.2.16/go.mod h1:jMoNg2n56ckaawi/O/J92BHaECmrz6IRjuMWqlMaMTM=
|
||||||
github.com/uudashr/gocognit v1.2.0 h1:3BU9aMr1xbhPlvJLSydKwdLN3tEUUrzPSSM8S4hDYRA=
|
|
||||||
github.com/uudashr/gocognit v1.2.0/go.mod h1:k/DdKPI6XBZO1q7HgoV2juESI2/Ofj9AcHPZhBBdrTU=
|
|
||||||
github.com/uudashr/iface v1.3.1 h1:bA51vmVx1UIhiIsQFSNq6GZ6VPTk3WNMZgRiCe9R29U=
|
|
||||||
github.com/uudashr/iface v1.3.1/go.mod h1:4QvspiRd3JLPAEXBQ9AiZpLbJlrWWgRChOKDJEuQTdg=
|
|
||||||
github.com/vmihailenco/msgpack/v5 v5.4.1 h1:cQriyiUvjTwOHg8QZaPihLWeRAAVoCpE00IUPn0Bjt8=
|
github.com/vmihailenco/msgpack/v5 v5.4.1 h1:cQriyiUvjTwOHg8QZaPihLWeRAAVoCpE00IUPn0Bjt8=
|
||||||
github.com/vmihailenco/msgpack/v5 v5.4.1/go.mod h1:GaZTsDaehaPpQVyxrf5mtQlH+pc21PIudVV/E3rRQok=
|
github.com/vmihailenco/msgpack/v5 v5.4.1/go.mod h1:GaZTsDaehaPpQVyxrf5mtQlH+pc21PIudVV/E3rRQok=
|
||||||
github.com/vmihailenco/tagparser/v2 v2.0.0 h1:y09buUbR+b5aycVFQs/g70pqKVZNBmxwAhO7/IwNM9g=
|
github.com/vmihailenco/tagparser/v2 v2.0.0 h1:y09buUbR+b5aycVFQs/g70pqKVZNBmxwAhO7/IwNM9g=
|
||||||
github.com/vmihailenco/tagparser/v2 v2.0.0/go.mod h1:Wri+At7QHww0WTrCBeu4J6bNtoV6mEfg5OIWRZA9qds=
|
github.com/vmihailenco/tagparser/v2 v2.0.0/go.mod h1:Wri+At7QHww0WTrCBeu4J6bNtoV6mEfg5OIWRZA9qds=
|
||||||
github.com/xen0n/gosmopolitan v1.2.2 h1:/p2KTnMzwRexIW8GlKawsTWOxn7UHA+jCMF/V8HHtvU=
|
|
||||||
github.com/xen0n/gosmopolitan v1.2.2/go.mod h1:7XX7Mj61uLYrj0qmeN0zi7XDon9JRAEhYQqAPLVNTeg=
|
|
||||||
github.com/yagipy/maintidx v1.0.0 h1:h5NvIsCz+nRDapQ0exNv4aJ0yXSI0420omVANTv3GJM=
|
|
||||||
github.com/yagipy/maintidx v1.0.0/go.mod h1:0qNf/I/CCZXSMhsRsrEPDZ+DkekpKLXAJfsTACwgXLk=
|
|
||||||
github.com/yeya24/promlinter v0.3.0 h1:JVDbMp08lVCP7Y6NP3qHroGAO6z2yGKQtS5JsjqtoFs=
|
|
||||||
github.com/yeya24/promlinter v0.3.0/go.mod h1:cDfJQQYv9uYciW60QT0eeHlFodotkYZlL+YcPQN+mW4=
|
|
||||||
github.com/ykadowak/zerologlint v0.1.5 h1:Gy/fMz1dFQN9JZTPjv1hxEk+sRWm05row04Yoolgdiw=
|
|
||||||
github.com/ykadowak/zerologlint v0.1.5/go.mod h1:KaUskqF3e/v59oPmdq1U1DnKcuHokl2/K1U4pmIELKg=
|
|
||||||
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
|
||||||
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
|
||||||
github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
|
||||||
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
|
||||||
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
|
|
||||||
github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
|
|
||||||
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
|
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
|
||||||
gitlab.com/bosi/decorder v0.4.2 h1:qbQaV3zgwnBZ4zPMhGLW4KZe7A7NwxEhJx39R3shffo=
|
|
||||||
gitlab.com/bosi/decorder v0.4.2/go.mod h1:muuhHoaJkA9QLcYHq4Mj8FJUwDZ+EirSHRiaTcTf6T8=
|
|
||||||
go-simpler.org/musttag v0.13.0 h1:Q/YAW0AHvaoaIbsPj3bvEI5/QFP7w696IMUpnKXQfCE=
|
|
||||||
go-simpler.org/musttag v0.13.0/go.mod h1:FTzIGeK6OkKlUDVpj0iQUXZLUO1Js9+mvykDQy9C5yM=
|
|
||||||
go-simpler.org/sloglint v0.9.0 h1:/40NQtjRx9txvsB/RN022KsUJU+zaaSb/9q9BSefSrE=
|
|
||||||
go-simpler.org/sloglint v0.9.0/go.mod h1:G/OrAF6uxj48sHahCzrbarVMptL2kjWTaUeC8+fOGww=
|
|
||||||
go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU=
|
|
||||||
go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8=
|
|
||||||
go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
|
|
||||||
go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
|
|
||||||
go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
|
|
||||||
go.uber.org/atomic v1.7.0 h1:ADUqmZGgLDDfbSL9ZmPxKTybcoEYHgpYfELNoN+7hsw=
|
|
||||||
go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
|
|
||||||
go.uber.org/automaxprocs v1.6.0 h1:O3y2/QNTOdbF+e/dpXNNW7Rx2hZ4sTIPyybbxyNqTUs=
|
|
||||||
go.uber.org/automaxprocs v1.6.0/go.mod h1:ifeIMSnPZuznNm6jmdzmU3/bfk01Fe2fotchwEFJ8r8=
|
|
||||||
go.uber.org/multierr v1.6.0 h1:y6IPFStTAIT5Ytl7/XYmHvzXQ7S3g/IeZW9hyZ5thw4=
|
|
||||||
go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU=
|
|
||||||
go.uber.org/zap v1.24.0 h1:FiJd5l1UOLj0wCgbSE0rwwXHzEdAZS6hiiSnxJN/D60=
|
|
||||||
go.uber.org/zap v1.24.0/go.mod h1:2kMP+WWQ8aoFoedH3T2sq6iJ2yDWpHbP0f6MQbS9Gkg=
|
|
||||||
go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg=
|
go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg=
|
||||||
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
|
||||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||||
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
|
||||||
golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
|
||||||
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
|
||||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
|
||||||
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||||
golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliYc=
|
golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliYc=
|
||||||
golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4=
|
|
||||||
golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU=
|
golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU=
|
||||||
golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8=
|
golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8=
|
||||||
golang.org/x/crypto v0.41.0 h1:WKYxWedPGCTVVl5+WHSSrOBT0O8lx32+zxmHxijgXp4=
|
golang.org/x/crypto v0.41.0 h1:WKYxWedPGCTVVl5+WHSSrOBT0O8lx32+zxmHxijgXp4=
|
||||||
golang.org/x/crypto v0.41.0/go.mod h1:pO5AFd7FA68rFak7rOAGVuygIISepHftHnr8dr6+sUc=
|
golang.org/x/crypto v0.41.0/go.mod h1:pO5AFd7FA68rFak7rOAGVuygIISepHftHnr8dr6+sUc=
|
||||||
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
|
||||||
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
|
||||||
golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
|
|
||||||
golang.org/x/exp v0.0.0-20190829153037-c13cbed26979/go.mod h1:86+5VVa7VpoJ4kLfm080zCjGlMRFzhUhsZKEZO7MGek=
|
|
||||||
golang.org/x/exp v0.0.0-20191030013958-a1ab85dbe136/go.mod h1:JXzH8nQsPlswgeRAPE3MuO9GYsAcnJvJ4vnMwN/5qkY=
|
|
||||||
golang.org/x/exp v0.0.0-20191129062945-2f5052295587/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4=
|
|
||||||
golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4=
|
|
||||||
golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4=
|
|
||||||
golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM=
|
|
||||||
golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU=
|
|
||||||
golang.org/x/exp v0.0.0-20240909161429-701f63a606c0 h1:e66Fs6Z+fZTbFBAxKfP3PALWBtpfqks2bwGcexMxgtk=
|
|
||||||
golang.org/x/exp/typeparams v0.0.0-20220428152302-39d4317da171/go.mod h1:AbB0pIl9nAr9wVwH+Z2ZpaocVmF5I4GyWCDIsVjR0bk=
|
|
||||||
golang.org/x/exp/typeparams v0.0.0-20230203172020-98cc5a0785f9/go.mod h1:AbB0pIl9nAr9wVwH+Z2ZpaocVmF5I4GyWCDIsVjR0bk=
|
|
||||||
golang.org/x/exp/typeparams v0.0.0-20250210185358-939b2ce775ac h1:TSSpLIG4v+p0rPv1pNOQtl1I8knsO4S9trOxNMOLVP4=
|
|
||||||
golang.org/x/exp/typeparams v0.0.0-20250210185358-939b2ce775ac/go.mod h1:AbB0pIl9nAr9wVwH+Z2ZpaocVmF5I4GyWCDIsVjR0bk=
|
|
||||||
golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
|
|
||||||
golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
|
|
||||||
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
|
||||||
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
|
|
||||||
golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
|
||||||
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
|
||||||
golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
|
||||||
golang.org/x/lint v0.0.0-20190909230951-414d861bb4ac/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
|
||||||
golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
|
||||||
golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRuDixDT3tpyyb+LUpUlRWLxfhWrs=
|
|
||||||
golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
|
|
||||||
golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
|
|
||||||
golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE=
|
|
||||||
golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o=
|
|
||||||
golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc=
|
|
||||||
golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY=
|
|
||||||
golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
|
|
||||||
golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
|
|
||||||
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
|
||||||
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
|
||||||
golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
|
||||||
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
|
||||||
golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3/go.mod h1:3p9vT2HGsQu2K1YbXdKPJLVgG5VJdoTa1poYQBtP1AY=
|
|
||||||
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
|
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
|
||||||
golang.org/x/mod v0.7.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
|
|
||||||
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
|
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
|
||||||
golang.org/x/mod v0.9.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
|
|
||||||
golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
|
golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
|
||||||
golang.org/x/mod v0.13.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
|
|
||||||
golang.org/x/mod v0.15.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
|
golang.org/x/mod v0.15.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
|
||||||
golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
|
golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
|
||||||
golang.org/x/mod v0.26.0 h1:EGMPT//Ezu+ylkCijjPc+f4Aih7sZvaAr+O3EHBxvZg=
|
|
||||||
golang.org/x/mod v0.26.0/go.mod h1:/j6NAhSk8iQ723BGAUyoAcn7SlD7s15Dp9Nd/SfeaFQ=
|
|
||||||
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
|
||||||
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
|
||||||
golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
|
||||||
golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
|
||||||
golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
|
||||||
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
|
||||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
|
||||||
golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
|
||||||
golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
|
||||||
golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
|
|
||||||
golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
|
||||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||||
golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
|
||||||
golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
|
||||||
golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
|
||||||
golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
|
||||||
golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
|
||||||
golang.org/x/net v0.0.0-20200222125558-5a598a2470a0/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
|
||||||
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
|
||||||
golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
|
||||||
golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
|
||||||
golang.org/x/net v0.0.0-20200501053045-e0ff5e5a1de5/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
|
||||||
golang.org/x/net v0.0.0-20200506145744-7e3656a0809f/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
|
||||||
golang.org/x/net v0.0.0-20200513185701-a91f0712d120/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
|
||||||
golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
|
||||||
golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
|
|
||||||
golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
|
|
||||||
golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
|
|
||||||
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
|
||||||
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||||
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
|
|
||||||
golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
|
||||||
golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
|
||||||
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
|
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
|
||||||
golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY=
|
|
||||||
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
|
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
|
||||||
golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc=
|
|
||||||
golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
|
golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
|
||||||
golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk=
|
golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk=
|
||||||
golang.org/x/net v0.16.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE=
|
|
||||||
golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44=
|
golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44=
|
||||||
golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM=
|
golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM=
|
||||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
|
||||||
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
|
||||||
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
|
||||||
golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
|
||||||
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
|
||||||
golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
|
|
||||||
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
|
||||||
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
|
||||||
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
|
||||||
golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
|
||||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
|
||||||
golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
|
||||||
golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
|
||||||
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
|
||||||
golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
|
||||||
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
|
||||||
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y=
|
golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y=
|
||||||
golang.org/x/sync v0.4.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y=
|
|
||||||
golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
||||||
golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
||||||
golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
||||||
golang.org/x/sync v0.16.0 h1:ycBJEhp9p4vXvUZNszeOq0kGTPghopOL8q0fq3vstxw=
|
golang.org/x/sync v0.16.0 h1:ycBJEhp9p4vXvUZNszeOq0kGTPghopOL8q0fq3vstxw=
|
||||||
golang.org/x/sync v0.16.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
|
golang.org/x/sync v0.16.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
|
||||||
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
|
||||||
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
|
||||||
golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
|
||||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/sys v0.0.0-20200106162015-b016eb3dc98e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/sys v0.0.0-20200113162924-86b910548bc1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/sys v0.0.0-20200212091648-12a6c2dcc1e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/sys v0.0.0-20200331124033-c3d80250170d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/sys v0.0.0-20200501052902-10377860bb8e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/sys v0.0.0-20200511232937-7e40ca221e25/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
|
||||||
golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
|
||||||
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
|
||||||
golang.org/x/sys v0.0.0-20211105183446-c75c47738b0c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
|
||||||
golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
|
||||||
golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
|
||||||
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
|
||||||
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
|
||||||
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
|
||||||
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
|
||||||
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||||
golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||||
golang.org/x/sys v0.29.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
golang.org/x/sys v0.29.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||||
@@ -785,27 +110,18 @@ golang.org/x/sys v0.38.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
|
|||||||
golang.org/x/telemetry v0.0.0-20240228155512-f48c80bd79b2/go.mod h1:TeRTkGYfJXctD9OcfyVLyj2J3IxLnKwHJR8f4D8a3YE=
|
golang.org/x/telemetry v0.0.0-20240228155512-f48c80bd79b2/go.mod h1:TeRTkGYfJXctD9OcfyVLyj2J3IxLnKwHJR8f4D8a3YE=
|
||||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||||
golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc=
|
|
||||||
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
|
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
|
||||||
golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U=
|
|
||||||
golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo=
|
golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo=
|
||||||
golang.org/x/term v0.12.0/go.mod h1:owVbMEjm3cBLCHdkQu9b1opXd4ETQWc3BhuQGKgXgvU=
|
golang.org/x/term v0.12.0/go.mod h1:owVbMEjm3cBLCHdkQu9b1opXd4ETQWc3BhuQGKgXgvU=
|
||||||
golang.org/x/term v0.13.0/go.mod h1:LTmsnFJwVN6bCy1rVCoS+qHT1HhALEFxKncY3WNNh4U=
|
|
||||||
golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk=
|
golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk=
|
||||||
golang.org/x/term v0.20.0/go.mod h1:8UkIAJTvZgivsXaD6/pH6U9ecQzZ45awqEOzuCvwpFY=
|
golang.org/x/term v0.20.0/go.mod h1:8UkIAJTvZgivsXaD6/pH6U9ecQzZ45awqEOzuCvwpFY=
|
||||||
golang.org/x/term v0.28.0/go.mod h1:Sw/lC2IAUZ92udQNf3WodGtn4k/XoLyZoh8v/8uiwek=
|
golang.org/x/term v0.28.0/go.mod h1:Sw/lC2IAUZ92udQNf3WodGtn4k/XoLyZoh8v/8uiwek=
|
||||||
golang.org/x/term v0.34.0 h1:O/2T7POpk0ZZ7MAzMeWFSg6S5IpWd/RXDlM9hgM3DR4=
|
golang.org/x/term v0.34.0 h1:O/2T7POpk0ZZ7MAzMeWFSg6S5IpWd/RXDlM9hgM3DR4=
|
||||||
golang.org/x/term v0.34.0/go.mod h1:5jC53AEywhIVebHgPVeg0mj8OD3VO9OzclacVrqpaAw=
|
golang.org/x/term v0.34.0/go.mod h1:5jC53AEywhIVebHgPVeg0mj8OD3VO9OzclacVrqpaAw=
|
||||||
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
|
||||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||||
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
|
||||||
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
|
||||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||||
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
|
||||||
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||||
golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
|
||||||
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
||||||
golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
|
|
||||||
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
|
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
|
||||||
golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
|
golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
|
||||||
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
||||||
@@ -813,181 +129,16 @@ golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
|||||||
golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ=
|
golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ=
|
||||||
golang.org/x/text v0.28.0 h1:rhazDwis8INMIwQ4tpjLDzUhx6RlXqZNPEM0huQojng=
|
golang.org/x/text v0.28.0 h1:rhazDwis8INMIwQ4tpjLDzUhx6RlXqZNPEM0huQojng=
|
||||||
golang.org/x/text v0.28.0/go.mod h1:U8nCwOR8jO/marOQ0QbDiOngZVEBB7MAiitBuMjXiNU=
|
golang.org/x/text v0.28.0/go.mod h1:U8nCwOR8jO/marOQ0QbDiOngZVEBB7MAiitBuMjXiNU=
|
||||||
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
|
||||||
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
|
||||||
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
|
||||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||||
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
|
||||||
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
|
|
||||||
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
|
||||||
golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
|
||||||
golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
|
||||||
golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
|
|
||||||
golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
|
|
||||||
golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
|
|
||||||
golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
|
|
||||||
golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
|
|
||||||
golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
|
|
||||||
golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
|
||||||
golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
|
||||||
golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
|
||||||
golang.org/x/tools v0.0.0-20191113191852-77e3bb0ad9e7/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
|
||||||
golang.org/x/tools v0.0.0-20191115202509-3a792d9c32b2/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
|
||||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||||
golang.org/x/tools v0.0.0-20191125144606-a911d9008d1f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
|
||||||
golang.org/x/tools v0.0.0-20191130070609-6e064ea0cf2d/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
|
||||||
golang.org/x/tools v0.0.0-20191216173652-a0e659d51361/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
|
||||||
golang.org/x/tools v0.0.0-20191227053925-7b8e75db28f4/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
|
||||||
golang.org/x/tools v0.0.0-20200117161641-43d50277825c/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
|
||||||
golang.org/x/tools v0.0.0-20200122220014-bf1340f18c4a/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
|
||||||
golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
|
||||||
golang.org/x/tools v0.0.0-20200204074204-1cc6d1ef6c74/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
|
||||||
golang.org/x/tools v0.0.0-20200207183749-b753a1ba74fa/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
|
||||||
golang.org/x/tools v0.0.0-20200212150539-ea181f53ac56/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
|
||||||
golang.org/x/tools v0.0.0-20200224181240-023911ca70b2/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
|
||||||
golang.org/x/tools v0.0.0-20200227222343-706bc42d1f0d/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
|
||||||
golang.org/x/tools v0.0.0-20200304193943-95d2e580d8eb/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw=
|
|
||||||
golang.org/x/tools v0.0.0-20200312045724-11d5b4c81c7d/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw=
|
|
||||||
golang.org/x/tools v0.0.0-20200324003944-a576cf524670/go.mod h1:Sl4aGygMT6LrqrWclx+PTx3U+LnKx/seiNR+3G19Ar8=
|
|
||||||
golang.org/x/tools v0.0.0-20200329025819-fd4102a86c65/go.mod h1:Sl4aGygMT6LrqrWclx+PTx3U+LnKx/seiNR+3G19Ar8=
|
|
||||||
golang.org/x/tools v0.0.0-20200331025713-a30bf2db82d4/go.mod h1:Sl4aGygMT6LrqrWclx+PTx3U+LnKx/seiNR+3G19Ar8=
|
|
||||||
golang.org/x/tools v0.0.0-20200501065659-ab2804fb9c9d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
|
|
||||||
golang.org/x/tools v0.0.0-20200512131952-2bc93b1c0c88/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
|
|
||||||
golang.org/x/tools v0.0.0-20200515010526-7d3b6ebf133d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
|
|
||||||
golang.org/x/tools v0.0.0-20200618134242-20370b0cb4b2/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
|
|
||||||
golang.org/x/tools v0.0.0-20200724022722-7017fd6b1305/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
|
|
||||||
golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
|
|
||||||
golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
|
|
||||||
golang.org/x/tools v0.0.0-20200820010801-b793a1359eac/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
|
|
||||||
golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
|
|
||||||
golang.org/x/tools v0.0.0-20201023174141-c8cfbd0f21e6/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
|
||||||
golang.org/x/tools v0.1.1-0.20210205202024-ef80cdb6ec6d/go.mod h1:9bzcO0MWcOuT0tm1iBGzDVPshzfwoVvREIui8C+MHqU=
|
|
||||||
golang.org/x/tools v0.1.1-0.20210302220138-2ac05c832e1a/go.mod h1:9bzcO0MWcOuT0tm1iBGzDVPshzfwoVvREIui8C+MHqU=
|
|
||||||
golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
|
|
||||||
golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
|
|
||||||
golang.org/x/tools v0.1.10/go.mod h1:Uh6Zz+xoGYZom868N8YTex3t7RhtHDBrE8Gzo9bV56E=
|
|
||||||
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
|
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
|
||||||
golang.org/x/tools v0.3.0/go.mod h1:/rWhSS2+zyEVwoJf8YAX6L2f0ntZ7Kn/mGgAWcipA5k=
|
|
||||||
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
|
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
|
||||||
golang.org/x/tools v0.7.0/go.mod h1:4pg6aUX35JBAogB10C9AtvVL+qowtN4pT3CGSQex14s=
|
|
||||||
golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58=
|
golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58=
|
||||||
golang.org/x/tools v0.14.0/go.mod h1:uYBEerGOWcJyEORxN+Ek8+TT266gXkNlHdJBwexUsBg=
|
|
||||||
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk=
|
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk=
|
||||||
golang.org/x/tools v0.35.0 h1:mBffYraMEf7aa0sB+NuKnuCy8qI/9Bughn8dC2Gu5r0=
|
|
||||||
golang.org/x/tools v0.35.0/go.mod h1:NKdj5HkL/73byiZSJjqJgKn3ep7KjFkBOkR/Hps3VPw=
|
|
||||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
|
||||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
|
||||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
|
||||||
google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE=
|
|
||||||
google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M=
|
|
||||||
google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg=
|
|
||||||
google.golang.org/api v0.9.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg=
|
|
||||||
google.golang.org/api v0.13.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI=
|
|
||||||
google.golang.org/api v0.14.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI=
|
|
||||||
google.golang.org/api v0.15.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI=
|
|
||||||
google.golang.org/api v0.17.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE=
|
|
||||||
google.golang.org/api v0.18.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE=
|
|
||||||
google.golang.org/api v0.19.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE=
|
|
||||||
google.golang.org/api v0.20.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE=
|
|
||||||
google.golang.org/api v0.22.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE=
|
|
||||||
google.golang.org/api v0.24.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE=
|
|
||||||
google.golang.org/api v0.28.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE=
|
|
||||||
google.golang.org/api v0.29.0/go.mod h1:Lcubydp8VUV7KeIHD9z2Bys/sm/vGKnG1UHuDBSrHWM=
|
|
||||||
google.golang.org/api v0.30.0/go.mod h1:QGmEvQ87FHZNiUVJkT14jQNYJ4ZJjdRF23ZXz5138Fc=
|
|
||||||
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
|
|
||||||
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
|
|
||||||
google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
|
|
||||||
google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0=
|
|
||||||
google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
|
|
||||||
google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
|
|
||||||
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
|
|
||||||
google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
|
|
||||||
google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
|
|
||||||
google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
|
|
||||||
google.golang.org/genproto v0.0.0-20190502173448-54afdca5d873/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
|
|
||||||
google.golang.org/genproto v0.0.0-20190801165951-fa694d86fc64/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
|
|
||||||
google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
|
|
||||||
google.golang.org/genproto v0.0.0-20190911173649-1774047e7e51/go.mod h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8=
|
|
||||||
google.golang.org/genproto v0.0.0-20191108220845-16a3f7862a1a/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
|
|
||||||
google.golang.org/genproto v0.0.0-20191115194625-c23dd37a84c9/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
|
|
||||||
google.golang.org/genproto v0.0.0-20191216164720-4f79533eabd1/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
|
|
||||||
google.golang.org/genproto v0.0.0-20191230161307-f3c370f40bfb/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
|
|
||||||
google.golang.org/genproto v0.0.0-20200115191322-ca5a22157cba/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
|
|
||||||
google.golang.org/genproto v0.0.0-20200122232147-0452cf42e150/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
|
|
||||||
google.golang.org/genproto v0.0.0-20200204135345-fa8e72b47b90/go.mod h1:GmwEX6Z4W5gMy59cAlVYjN9JhxgbQH6Gn+gFDQe2lzA=
|
|
||||||
google.golang.org/genproto v0.0.0-20200212174721-66ed5ce911ce/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
|
|
||||||
google.golang.org/genproto v0.0.0-20200224152610-e50cd9704f63/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
|
|
||||||
google.golang.org/genproto v0.0.0-20200228133532-8c2c7df3a383/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
|
|
||||||
google.golang.org/genproto v0.0.0-20200305110556-506484158171/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
|
|
||||||
google.golang.org/genproto v0.0.0-20200312145019-da6875a35672/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
|
|
||||||
google.golang.org/genproto v0.0.0-20200331122359-1ee6d9798940/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
|
|
||||||
google.golang.org/genproto v0.0.0-20200430143042-b979b6f78d84/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
|
|
||||||
google.golang.org/genproto v0.0.0-20200511104702-f5ebc3bea380/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
|
|
||||||
google.golang.org/genproto v0.0.0-20200515170657-fc4c6c6a6587/go.mod h1:YsZOwe1myG/8QRHRsmBRE1LrgQY60beZKjly0O1fX9U=
|
|
||||||
google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo=
|
|
||||||
google.golang.org/genproto v0.0.0-20200618031413-b414f8b61790/go.mod h1:jDfRM7FcilCzHH/e9qn6dsT145K34l5v+OpcnNgKAAA=
|
|
||||||
google.golang.org/genproto v0.0.0-20200729003335-053ba62fc06f/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
|
|
||||||
google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
|
|
||||||
google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
|
|
||||||
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
|
|
||||||
google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38=
|
|
||||||
google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM=
|
|
||||||
google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
|
|
||||||
google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY=
|
|
||||||
google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
|
|
||||||
google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
|
|
||||||
google.golang.org/grpc v1.27.1/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
|
|
||||||
google.golang.org/grpc v1.28.0/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKal+60=
|
|
||||||
google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk=
|
|
||||||
google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak=
|
|
||||||
google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak=
|
|
||||||
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
|
|
||||||
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
|
|
||||||
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
|
|
||||||
google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE=
|
|
||||||
google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo=
|
|
||||||
google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
|
||||||
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
|
||||||
google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
|
||||||
google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4=
|
|
||||||
google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
|
|
||||||
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
|
|
||||||
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
|
|
||||||
google.golang.org/protobuf v1.36.5 h1:tPhr+woSbjfYvY6/GPufUoYizxw1cF/yFoxJ2fmpwlM=
|
|
||||||
google.golang.org/protobuf v1.36.5/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
|
|
||||||
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
|
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
|
||||||
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
|
||||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
|
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
|
||||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
|
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
|
||||||
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
|
|
||||||
gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA=
|
|
||||||
gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
|
|
||||||
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
|
||||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
|
||||||
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
|
||||||
gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
|
||||||
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
|
||||||
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
|
|
||||||
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
|
|
||||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
|
||||||
honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
|
||||||
honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
|
||||||
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
|
||||||
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
|
|
||||||
honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
|
|
||||||
honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
|
|
||||||
honnef.co/go/tools v0.6.1 h1:R094WgE8K4JirYjBaOpz/AvTyUu/3wbmAoskKN/pxTI=
|
|
||||||
honnef.co/go/tools v0.6.1/go.mod h1:3puzxxljPCe8RGJX7BIy1plGbxEOZni5mR2aXe3/uk4=
|
|
||||||
mvdan.cc/gofumpt v0.7.0 h1:bg91ttqXmi9y2xawvkuMXyvAA/1ZGJqYAEGjXuP0JXU=
|
|
||||||
mvdan.cc/gofumpt v0.7.0/go.mod h1:txVFJy/Sc/mvaycET54pV8SW8gWxTlUuGHVEcncmNUo=
|
|
||||||
mvdan.cc/unparam v0.0.0-20240528143540-8a5130ca722f h1:lMpcwN6GxNbWtbpI1+xzFLSW8XzX0u72NttUGVFjO3U=
|
|
||||||
mvdan.cc/unparam v0.0.0-20240528143540-8a5130ca722f/go.mod h1:RSLa7mKKCNeTTMHBw5Hsy2rfJmd6O2ivt9Dw9ZqCQpQ=
|
|
||||||
rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=
|
|
||||||
rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0=
|
|
||||||
rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=
|
|
||||||
|
|||||||
714
pkg/commontypes/commontypes_test.go
Normal file
714
pkg/commontypes/commontypes_test.go
Normal file
@@ -0,0 +1,714 @@
|
|||||||
|
package commontypes
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestExtractBaseType(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
sqlType string
|
||||||
|
want string
|
||||||
|
}{
|
||||||
|
{"varchar with length", "varchar(100)", "varchar"},
|
||||||
|
{"VARCHAR uppercase with length", "VARCHAR(255)", "varchar"},
|
||||||
|
{"numeric with precision", "numeric(10,2)", "numeric"},
|
||||||
|
{"NUMERIC uppercase", "NUMERIC(18,4)", "numeric"},
|
||||||
|
{"decimal with precision", "decimal(15,3)", "decimal"},
|
||||||
|
{"char with length", "char(50)", "char"},
|
||||||
|
{"simple integer", "integer", "integer"},
|
||||||
|
{"simple text", "text", "text"},
|
||||||
|
{"bigint", "bigint", "bigint"},
|
||||||
|
{"With spaces", " varchar(100) ", "varchar"},
|
||||||
|
{"No parentheses", "boolean", "boolean"},
|
||||||
|
{"Empty string", "", ""},
|
||||||
|
{"Mixed case", "VarChar(100)", "varchar"},
|
||||||
|
{"timestamp with time zone", "timestamp(6) with time zone", "timestamp"},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
got := ExtractBaseType(tt.sqlType)
|
||||||
|
if got != tt.want {
|
||||||
|
t.Errorf("ExtractBaseType(%q) = %q, want %q", tt.sqlType, got, tt.want)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestNormalizeType(t *testing.T) {
|
||||||
|
// NormalizeType is an alias for ExtractBaseType, test that they behave the same
|
||||||
|
testCases := []string{
|
||||||
|
"varchar(100)",
|
||||||
|
"numeric(10,2)",
|
||||||
|
"integer",
|
||||||
|
"text",
|
||||||
|
" VARCHAR(255) ",
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tc := range testCases {
|
||||||
|
t.Run(tc, func(t *testing.T) {
|
||||||
|
extracted := ExtractBaseType(tc)
|
||||||
|
normalized := NormalizeType(tc)
|
||||||
|
if extracted != normalized {
|
||||||
|
t.Errorf("ExtractBaseType(%q) = %q, but NormalizeType(%q) = %q",
|
||||||
|
tc, extracted, tc, normalized)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestSQLToGo(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
sqlType string
|
||||||
|
nullable bool
|
||||||
|
want string
|
||||||
|
}{
|
||||||
|
// Integer types (nullable)
|
||||||
|
{"integer nullable", "integer", true, "int32"},
|
||||||
|
{"bigint nullable", "bigint", true, "int64"},
|
||||||
|
{"smallint nullable", "smallint", true, "int16"},
|
||||||
|
{"serial nullable", "serial", true, "int32"},
|
||||||
|
|
||||||
|
// Integer types (not nullable)
|
||||||
|
{"integer not nullable", "integer", false, "*int32"},
|
||||||
|
{"bigint not nullable", "bigint", false, "*int64"},
|
||||||
|
{"smallint not nullable", "smallint", false, "*int16"},
|
||||||
|
|
||||||
|
// String types (nullable)
|
||||||
|
{"text nullable", "text", true, "string"},
|
||||||
|
{"varchar nullable", "varchar", true, "string"},
|
||||||
|
{"varchar with length nullable", "varchar(100)", true, "string"},
|
||||||
|
|
||||||
|
// String types (not nullable)
|
||||||
|
{"text not nullable", "text", false, "*string"},
|
||||||
|
{"varchar not nullable", "varchar", false, "*string"},
|
||||||
|
|
||||||
|
// Boolean
|
||||||
|
{"boolean nullable", "boolean", true, "bool"},
|
||||||
|
{"boolean not nullable", "boolean", false, "*bool"},
|
||||||
|
|
||||||
|
// Float types
|
||||||
|
{"real nullable", "real", true, "float32"},
|
||||||
|
{"double precision nullable", "double precision", true, "float64"},
|
||||||
|
{"real not nullable", "real", false, "*float32"},
|
||||||
|
{"double precision not nullable", "double precision", false, "*float64"},
|
||||||
|
|
||||||
|
// Date/Time types
|
||||||
|
{"timestamp nullable", "timestamp", true, "time.Time"},
|
||||||
|
{"date nullable", "date", true, "time.Time"},
|
||||||
|
{"timestamp not nullable", "timestamp", false, "*time.Time"},
|
||||||
|
|
||||||
|
// Binary
|
||||||
|
{"bytea nullable", "bytea", true, "[]byte"},
|
||||||
|
{"bytea not nullable", "bytea", false, "[]byte"}, // Slices don't get pointer
|
||||||
|
|
||||||
|
// UUID
|
||||||
|
{"uuid nullable", "uuid", true, "string"},
|
||||||
|
{"uuid not nullable", "uuid", false, "*string"},
|
||||||
|
|
||||||
|
// JSON
|
||||||
|
{"json nullable", "json", true, "string"},
|
||||||
|
{"jsonb nullable", "jsonb", true, "string"},
|
||||||
|
|
||||||
|
// Array
|
||||||
|
{"array nullable", "array", true, "[]string"},
|
||||||
|
{"array not nullable", "array", false, "[]string"}, // Slices don't get pointer
|
||||||
|
|
||||||
|
// Unknown types
|
||||||
|
{"unknown type nullable", "unknowntype", true, "interface{}"},
|
||||||
|
{"unknown type not nullable", "unknowntype", false, "interface{}"}, // Interface doesn't get pointer
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
got := SQLToGo(tt.sqlType, tt.nullable)
|
||||||
|
if got != tt.want {
|
||||||
|
t.Errorf("SQLToGo(%q, %v) = %q, want %q", tt.sqlType, tt.nullable, got, tt.want)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestSQLToTypeScript(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
sqlType string
|
||||||
|
nullable bool
|
||||||
|
want string
|
||||||
|
}{
|
||||||
|
// Integer types
|
||||||
|
{"integer nullable", "integer", true, "number"},
|
||||||
|
{"integer not nullable", "integer", false, "number | null"},
|
||||||
|
{"bigint nullable", "bigint", true, "number"},
|
||||||
|
{"bigint not nullable", "bigint", false, "number | null"},
|
||||||
|
|
||||||
|
// String types
|
||||||
|
{"text nullable", "text", true, "string"},
|
||||||
|
{"text not nullable", "text", false, "string | null"},
|
||||||
|
{"varchar nullable", "varchar", true, "string"},
|
||||||
|
{"varchar(100) nullable", "varchar(100)", true, "string"},
|
||||||
|
|
||||||
|
// Boolean
|
||||||
|
{"boolean nullable", "boolean", true, "boolean"},
|
||||||
|
{"boolean not nullable", "boolean", false, "boolean | null"},
|
||||||
|
|
||||||
|
// Float types
|
||||||
|
{"real nullable", "real", true, "number"},
|
||||||
|
{"double precision nullable", "double precision", true, "number"},
|
||||||
|
|
||||||
|
// Date/Time types
|
||||||
|
{"timestamp nullable", "timestamp", true, "Date"},
|
||||||
|
{"date nullable", "date", true, "Date"},
|
||||||
|
{"timestamp not nullable", "timestamp", false, "Date | null"},
|
||||||
|
|
||||||
|
// Binary
|
||||||
|
{"bytea nullable", "bytea", true, "Buffer"},
|
||||||
|
{"bytea not nullable", "bytea", false, "Buffer | null"},
|
||||||
|
|
||||||
|
// JSON
|
||||||
|
{"json nullable", "json", true, "any"},
|
||||||
|
{"jsonb nullable", "jsonb", true, "any"},
|
||||||
|
|
||||||
|
// UUID
|
||||||
|
{"uuid nullable", "uuid", true, "string"},
|
||||||
|
|
||||||
|
// Unknown types
|
||||||
|
{"unknown type nullable", "unknowntype", true, "any"},
|
||||||
|
{"unknown type not nullable", "unknowntype", false, "any | null"},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
got := SQLToTypeScript(tt.sqlType, tt.nullable)
|
||||||
|
if got != tt.want {
|
||||||
|
t.Errorf("SQLToTypeScript(%q, %v) = %q, want %q", tt.sqlType, tt.nullable, got, tt.want)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestSQLToPython(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
sqlType string
|
||||||
|
want string
|
||||||
|
}{
|
||||||
|
// Integer types
|
||||||
|
{"integer", "integer", "int"},
|
||||||
|
{"bigint", "bigint", "int"},
|
||||||
|
{"smallint", "smallint", "int"},
|
||||||
|
|
||||||
|
// String types
|
||||||
|
{"text", "text", "str"},
|
||||||
|
{"varchar", "varchar", "str"},
|
||||||
|
{"varchar(100)", "varchar(100)", "str"},
|
||||||
|
|
||||||
|
// Boolean
|
||||||
|
{"boolean", "boolean", "bool"},
|
||||||
|
|
||||||
|
// Float types
|
||||||
|
{"real", "real", "float"},
|
||||||
|
{"double precision", "double precision", "float"},
|
||||||
|
{"numeric", "numeric", "Decimal"},
|
||||||
|
{"decimal", "decimal", "Decimal"},
|
||||||
|
|
||||||
|
// Date/Time types
|
||||||
|
{"timestamp", "timestamp", "datetime"},
|
||||||
|
{"date", "date", "date"},
|
||||||
|
{"time", "time", "time"},
|
||||||
|
|
||||||
|
// Binary
|
||||||
|
{"bytea", "bytea", "bytes"},
|
||||||
|
|
||||||
|
// JSON
|
||||||
|
{"json", "json", "dict"},
|
||||||
|
{"jsonb", "jsonb", "dict"},
|
||||||
|
|
||||||
|
// UUID
|
||||||
|
{"uuid", "uuid", "UUID"},
|
||||||
|
|
||||||
|
// Array
|
||||||
|
{"array", "array", "list"},
|
||||||
|
|
||||||
|
// Unknown types
|
||||||
|
{"unknown type", "unknowntype", "Any"},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
got := SQLToPython(tt.sqlType)
|
||||||
|
if got != tt.want {
|
||||||
|
t.Errorf("SQLToPython(%q) = %q, want %q", tt.sqlType, got, tt.want)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestSQLToCSharp(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
sqlType string
|
||||||
|
nullable bool
|
||||||
|
want string
|
||||||
|
}{
|
||||||
|
// Integer types (nullable)
|
||||||
|
{"integer nullable", "integer", true, "int"},
|
||||||
|
{"bigint nullable", "bigint", true, "long"},
|
||||||
|
{"smallint nullable", "smallint", true, "short"},
|
||||||
|
|
||||||
|
// Integer types (not nullable - value types get ?)
|
||||||
|
{"integer not nullable", "integer", false, "int?"},
|
||||||
|
{"bigint not nullable", "bigint", false, "long?"},
|
||||||
|
{"smallint not nullable", "smallint", false, "short?"},
|
||||||
|
|
||||||
|
// String types (reference types, no ? needed)
|
||||||
|
{"text nullable", "text", true, "string"},
|
||||||
|
{"text not nullable", "text", false, "string"},
|
||||||
|
{"varchar nullable", "varchar", true, "string"},
|
||||||
|
{"varchar(100) nullable", "varchar(100)", true, "string"},
|
||||||
|
|
||||||
|
// Boolean
|
||||||
|
{"boolean nullable", "boolean", true, "bool"},
|
||||||
|
{"boolean not nullable", "boolean", false, "bool?"},
|
||||||
|
|
||||||
|
// Float types
|
||||||
|
{"real nullable", "real", true, "float"},
|
||||||
|
{"double precision nullable", "double precision", true, "double"},
|
||||||
|
{"decimal nullable", "decimal", true, "decimal"},
|
||||||
|
{"real not nullable", "real", false, "float?"},
|
||||||
|
{"double precision not nullable", "double precision", false, "double?"},
|
||||||
|
{"decimal not nullable", "decimal", false, "decimal?"},
|
||||||
|
|
||||||
|
// Date/Time types
|
||||||
|
{"timestamp nullable", "timestamp", true, "DateTime"},
|
||||||
|
{"date nullable", "date", true, "DateTime"},
|
||||||
|
{"timestamptz nullable", "timestamptz", true, "DateTimeOffset"},
|
||||||
|
{"timestamp not nullable", "timestamp", false, "DateTime?"},
|
||||||
|
{"timestamptz not nullable", "timestamptz", false, "DateTimeOffset?"},
|
||||||
|
|
||||||
|
// Binary (array type, no ?)
|
||||||
|
{"bytea nullable", "bytea", true, "byte[]"},
|
||||||
|
{"bytea not nullable", "bytea", false, "byte[]"},
|
||||||
|
|
||||||
|
// UUID
|
||||||
|
{"uuid nullable", "uuid", true, "Guid"},
|
||||||
|
{"uuid not nullable", "uuid", false, "Guid?"},
|
||||||
|
|
||||||
|
// JSON
|
||||||
|
{"json nullable", "json", true, "string"},
|
||||||
|
|
||||||
|
// Unknown types (object is reference type)
|
||||||
|
{"unknown type nullable", "unknowntype", true, "object"},
|
||||||
|
{"unknown type not nullable", "unknowntype", false, "object"},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
got := SQLToCSharp(tt.sqlType, tt.nullable)
|
||||||
|
if got != tt.want {
|
||||||
|
t.Errorf("SQLToCSharp(%q, %v) = %q, want %q", tt.sqlType, tt.nullable, got, tt.want)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestNeedsTimeImport(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
goType string
|
||||||
|
want bool
|
||||||
|
}{
|
||||||
|
{"time.Time type", "time.Time", true},
|
||||||
|
{"pointer to time.Time", "*time.Time", true},
|
||||||
|
{"int32 type", "int32", false},
|
||||||
|
{"string type", "string", false},
|
||||||
|
{"bool type", "bool", false},
|
||||||
|
{"[]byte type", "[]byte", false},
|
||||||
|
{"interface{}", "interface{}", false},
|
||||||
|
{"empty string", "", false},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
got := NeedsTimeImport(tt.goType)
|
||||||
|
if got != tt.want {
|
||||||
|
t.Errorf("NeedsTimeImport(%q) = %v, want %v", tt.goType, got, tt.want)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestGoTypeMap(t *testing.T) {
|
||||||
|
// Test that the map contains expected entries
|
||||||
|
expectedMappings := map[string]string{
|
||||||
|
"integer": "int32",
|
||||||
|
"bigint": "int64",
|
||||||
|
"text": "string",
|
||||||
|
"boolean": "bool",
|
||||||
|
"double precision": "float64",
|
||||||
|
"bytea": "[]byte",
|
||||||
|
"timestamp": "time.Time",
|
||||||
|
"uuid": "string",
|
||||||
|
"json": "string",
|
||||||
|
}
|
||||||
|
|
||||||
|
for sqlType, expectedGoType := range expectedMappings {
|
||||||
|
if goType, ok := GoTypeMap[sqlType]; !ok {
|
||||||
|
t.Errorf("GoTypeMap missing entry for %q", sqlType)
|
||||||
|
} else if goType != expectedGoType {
|
||||||
|
t.Errorf("GoTypeMap[%q] = %q, want %q", sqlType, goType, expectedGoType)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(GoTypeMap) == 0 {
|
||||||
|
t.Error("GoTypeMap is empty")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestTypeScriptTypeMap(t *testing.T) {
|
||||||
|
expectedMappings := map[string]string{
|
||||||
|
"integer": "number",
|
||||||
|
"bigint": "number",
|
||||||
|
"text": "string",
|
||||||
|
"boolean": "boolean",
|
||||||
|
"double precision": "number",
|
||||||
|
"bytea": "Buffer",
|
||||||
|
"timestamp": "Date",
|
||||||
|
"uuid": "string",
|
||||||
|
"json": "any",
|
||||||
|
}
|
||||||
|
|
||||||
|
for sqlType, expectedTSType := range expectedMappings {
|
||||||
|
if tsType, ok := TypeScriptTypeMap[sqlType]; !ok {
|
||||||
|
t.Errorf("TypeScriptTypeMap missing entry for %q", sqlType)
|
||||||
|
} else if tsType != expectedTSType {
|
||||||
|
t.Errorf("TypeScriptTypeMap[%q] = %q, want %q", sqlType, tsType, expectedTSType)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(TypeScriptTypeMap) == 0 {
|
||||||
|
t.Error("TypeScriptTypeMap is empty")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestPythonTypeMap(t *testing.T) {
|
||||||
|
expectedMappings := map[string]string{
|
||||||
|
"integer": "int",
|
||||||
|
"bigint": "int",
|
||||||
|
"text": "str",
|
||||||
|
"boolean": "bool",
|
||||||
|
"real": "float",
|
||||||
|
"numeric": "Decimal",
|
||||||
|
"bytea": "bytes",
|
||||||
|
"date": "date",
|
||||||
|
"uuid": "UUID",
|
||||||
|
"json": "dict",
|
||||||
|
}
|
||||||
|
|
||||||
|
for sqlType, expectedPyType := range expectedMappings {
|
||||||
|
if pyType, ok := PythonTypeMap[sqlType]; !ok {
|
||||||
|
t.Errorf("PythonTypeMap missing entry for %q", sqlType)
|
||||||
|
} else if pyType != expectedPyType {
|
||||||
|
t.Errorf("PythonTypeMap[%q] = %q, want %q", sqlType, pyType, expectedPyType)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(PythonTypeMap) == 0 {
|
||||||
|
t.Error("PythonTypeMap is empty")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestCSharpTypeMap(t *testing.T) {
|
||||||
|
expectedMappings := map[string]string{
|
||||||
|
"integer": "int",
|
||||||
|
"bigint": "long",
|
||||||
|
"smallint": "short",
|
||||||
|
"text": "string",
|
||||||
|
"boolean": "bool",
|
||||||
|
"double precision": "double",
|
||||||
|
"decimal": "decimal",
|
||||||
|
"bytea": "byte[]",
|
||||||
|
"timestamp": "DateTime",
|
||||||
|
"uuid": "Guid",
|
||||||
|
"json": "string",
|
||||||
|
}
|
||||||
|
|
||||||
|
for sqlType, expectedCSType := range expectedMappings {
|
||||||
|
if csType, ok := CSharpTypeMap[sqlType]; !ok {
|
||||||
|
t.Errorf("CSharpTypeMap missing entry for %q", sqlType)
|
||||||
|
} else if csType != expectedCSType {
|
||||||
|
t.Errorf("CSharpTypeMap[%q] = %q, want %q", sqlType, csType, expectedCSType)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(CSharpTypeMap) == 0 {
|
||||||
|
t.Error("CSharpTypeMap is empty")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestSQLToJava(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
sqlType string
|
||||||
|
nullable bool
|
||||||
|
want string
|
||||||
|
}{
|
||||||
|
// Integer types
|
||||||
|
{"integer nullable", "integer", true, "Integer"},
|
||||||
|
{"integer not nullable", "integer", false, "Integer"},
|
||||||
|
{"bigint nullable", "bigint", true, "Long"},
|
||||||
|
{"smallint nullable", "smallint", true, "Short"},
|
||||||
|
|
||||||
|
// String types
|
||||||
|
{"text nullable", "text", true, "String"},
|
||||||
|
{"varchar nullable", "varchar", true, "String"},
|
||||||
|
{"varchar(100) nullable", "varchar(100)", true, "String"},
|
||||||
|
|
||||||
|
// Boolean
|
||||||
|
{"boolean nullable", "boolean", true, "Boolean"},
|
||||||
|
|
||||||
|
// Float types
|
||||||
|
{"real nullable", "real", true, "Float"},
|
||||||
|
{"double precision nullable", "double precision", true, "Double"},
|
||||||
|
{"numeric nullable", "numeric", true, "BigDecimal"},
|
||||||
|
|
||||||
|
// Date/Time types
|
||||||
|
{"timestamp nullable", "timestamp", true, "Timestamp"},
|
||||||
|
{"date nullable", "date", true, "Date"},
|
||||||
|
{"time nullable", "time", true, "Time"},
|
||||||
|
|
||||||
|
// Binary
|
||||||
|
{"bytea nullable", "bytea", true, "byte[]"},
|
||||||
|
|
||||||
|
// UUID
|
||||||
|
{"uuid nullable", "uuid", true, "UUID"},
|
||||||
|
|
||||||
|
// JSON
|
||||||
|
{"json nullable", "json", true, "String"},
|
||||||
|
|
||||||
|
// Unknown types
|
||||||
|
{"unknown type nullable", "unknowntype", true, "Object"},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
got := SQLToJava(tt.sqlType, tt.nullable)
|
||||||
|
if got != tt.want {
|
||||||
|
t.Errorf("SQLToJava(%q, %v) = %q, want %q", tt.sqlType, tt.nullable, got, tt.want)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestSQLToPhp(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
sqlType string
|
||||||
|
nullable bool
|
||||||
|
want string
|
||||||
|
}{
|
||||||
|
// Integer types (nullable)
|
||||||
|
{"integer nullable", "integer", true, "int"},
|
||||||
|
{"bigint nullable", "bigint", true, "int"},
|
||||||
|
{"smallint nullable", "smallint", true, "int"},
|
||||||
|
|
||||||
|
// Integer types (not nullable)
|
||||||
|
{"integer not nullable", "integer", false, "?int"},
|
||||||
|
{"bigint not nullable", "bigint", false, "?int"},
|
||||||
|
|
||||||
|
// String types
|
||||||
|
{"text nullable", "text", true, "string"},
|
||||||
|
{"text not nullable", "text", false, "?string"},
|
||||||
|
{"varchar nullable", "varchar", true, "string"},
|
||||||
|
{"varchar(100) nullable", "varchar(100)", true, "string"},
|
||||||
|
|
||||||
|
// Boolean
|
||||||
|
{"boolean nullable", "boolean", true, "bool"},
|
||||||
|
{"boolean not nullable", "boolean", false, "?bool"},
|
||||||
|
|
||||||
|
// Float types
|
||||||
|
{"real nullable", "real", true, "float"},
|
||||||
|
{"double precision nullable", "double precision", true, "float"},
|
||||||
|
{"real not nullable", "real", false, "?float"},
|
||||||
|
|
||||||
|
// Date/Time types
|
||||||
|
{"timestamp nullable", "timestamp", true, "\\DateTime"},
|
||||||
|
{"date nullable", "date", true, "\\DateTime"},
|
||||||
|
{"timestamp not nullable", "timestamp", false, "?\\DateTime"},
|
||||||
|
|
||||||
|
// Binary
|
||||||
|
{"bytea nullable", "bytea", true, "string"},
|
||||||
|
{"bytea not nullable", "bytea", false, "?string"},
|
||||||
|
|
||||||
|
// JSON
|
||||||
|
{"json nullable", "json", true, "array"},
|
||||||
|
{"json not nullable", "json", false, "?array"},
|
||||||
|
|
||||||
|
// UUID
|
||||||
|
{"uuid nullable", "uuid", true, "string"},
|
||||||
|
|
||||||
|
// Unknown types
|
||||||
|
{"unknown type nullable", "unknowntype", true, "mixed"},
|
||||||
|
{"unknown type not nullable", "unknowntype", false, "mixed"},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
got := SQLToPhp(tt.sqlType, tt.nullable)
|
||||||
|
if got != tt.want {
|
||||||
|
t.Errorf("SQLToPhp(%q, %v) = %q, want %q", tt.sqlType, tt.nullable, got, tt.want)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestSQLToRust(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
sqlType string
|
||||||
|
nullable bool
|
||||||
|
want string
|
||||||
|
}{
|
||||||
|
// Integer types (nullable)
|
||||||
|
{"integer nullable", "integer", true, "i32"},
|
||||||
|
{"bigint nullable", "bigint", true, "i64"},
|
||||||
|
{"smallint nullable", "smallint", true, "i16"},
|
||||||
|
|
||||||
|
// Integer types (not nullable)
|
||||||
|
{"integer not nullable", "integer", false, "Option<i32>"},
|
||||||
|
{"bigint not nullable", "bigint", false, "Option<i64>"},
|
||||||
|
{"smallint not nullable", "smallint", false, "Option<i16>"},
|
||||||
|
|
||||||
|
// String types
|
||||||
|
{"text nullable", "text", true, "String"},
|
||||||
|
{"text not nullable", "text", false, "Option<String>"},
|
||||||
|
{"varchar nullable", "varchar", true, "String"},
|
||||||
|
{"varchar(100) nullable", "varchar(100)", true, "String"},
|
||||||
|
|
||||||
|
// Boolean
|
||||||
|
{"boolean nullable", "boolean", true, "bool"},
|
||||||
|
{"boolean not nullable", "boolean", false, "Option<bool>"},
|
||||||
|
|
||||||
|
// Float types
|
||||||
|
{"real nullable", "real", true, "f32"},
|
||||||
|
{"double precision nullable", "double precision", true, "f64"},
|
||||||
|
{"real not nullable", "real", false, "Option<f32>"},
|
||||||
|
{"double precision not nullable", "double precision", false, "Option<f64>"},
|
||||||
|
|
||||||
|
// Date/Time types
|
||||||
|
{"timestamp nullable", "timestamp", true, "NaiveDateTime"},
|
||||||
|
{"timestamptz nullable", "timestamptz", true, "DateTime<Utc>"},
|
||||||
|
{"date nullable", "date", true, "NaiveDate"},
|
||||||
|
{"time nullable", "time", true, "NaiveTime"},
|
||||||
|
{"timestamp not nullable", "timestamp", false, "Option<NaiveDateTime>"},
|
||||||
|
|
||||||
|
// Binary
|
||||||
|
{"bytea nullable", "bytea", true, "Vec<u8>"},
|
||||||
|
{"bytea not nullable", "bytea", false, "Option<Vec<u8>>"},
|
||||||
|
|
||||||
|
// JSON
|
||||||
|
{"json nullable", "json", true, "serde_json::Value"},
|
||||||
|
{"json not nullable", "json", false, "Option<serde_json::Value>"},
|
||||||
|
|
||||||
|
// UUID
|
||||||
|
{"uuid nullable", "uuid", true, "String"},
|
||||||
|
|
||||||
|
// Unknown types
|
||||||
|
{"unknown type nullable", "unknowntype", true, "String"},
|
||||||
|
{"unknown type not nullable", "unknowntype", false, "Option<String>"},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
got := SQLToRust(tt.sqlType, tt.nullable)
|
||||||
|
if got != tt.want {
|
||||||
|
t.Errorf("SQLToRust(%q, %v) = %q, want %q", tt.sqlType, tt.nullable, got, tt.want)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestJavaTypeMap(t *testing.T) {
|
||||||
|
expectedMappings := map[string]string{
|
||||||
|
"integer": "Integer",
|
||||||
|
"bigint": "Long",
|
||||||
|
"smallint": "Short",
|
||||||
|
"text": "String",
|
||||||
|
"boolean": "Boolean",
|
||||||
|
"double precision": "Double",
|
||||||
|
"numeric": "BigDecimal",
|
||||||
|
"bytea": "byte[]",
|
||||||
|
"timestamp": "Timestamp",
|
||||||
|
"uuid": "UUID",
|
||||||
|
"date": "Date",
|
||||||
|
}
|
||||||
|
|
||||||
|
for sqlType, expectedJavaType := range expectedMappings {
|
||||||
|
if javaType, ok := JavaTypeMap[sqlType]; !ok {
|
||||||
|
t.Errorf("JavaTypeMap missing entry for %q", sqlType)
|
||||||
|
} else if javaType != expectedJavaType {
|
||||||
|
t.Errorf("JavaTypeMap[%q] = %q, want %q", sqlType, javaType, expectedJavaType)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(JavaTypeMap) == 0 {
|
||||||
|
t.Error("JavaTypeMap is empty")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestPHPTypeMap(t *testing.T) {
|
||||||
|
expectedMappings := map[string]string{
|
||||||
|
"integer": "int",
|
||||||
|
"bigint": "int",
|
||||||
|
"text": "string",
|
||||||
|
"boolean": "bool",
|
||||||
|
"double precision": "float",
|
||||||
|
"bytea": "string",
|
||||||
|
"timestamp": "\\DateTime",
|
||||||
|
"uuid": "string",
|
||||||
|
"json": "array",
|
||||||
|
}
|
||||||
|
|
||||||
|
for sqlType, expectedPHPType := range expectedMappings {
|
||||||
|
if phpType, ok := PHPTypeMap[sqlType]; !ok {
|
||||||
|
t.Errorf("PHPTypeMap missing entry for %q", sqlType)
|
||||||
|
} else if phpType != expectedPHPType {
|
||||||
|
t.Errorf("PHPTypeMap[%q] = %q, want %q", sqlType, phpType, expectedPHPType)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(PHPTypeMap) == 0 {
|
||||||
|
t.Error("PHPTypeMap is empty")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestRustTypeMap(t *testing.T) {
|
||||||
|
expectedMappings := map[string]string{
|
||||||
|
"integer": "i32",
|
||||||
|
"bigint": "i64",
|
||||||
|
"smallint": "i16",
|
||||||
|
"text": "String",
|
||||||
|
"boolean": "bool",
|
||||||
|
"double precision": "f64",
|
||||||
|
"real": "f32",
|
||||||
|
"bytea": "Vec<u8>",
|
||||||
|
"timestamp": "NaiveDateTime",
|
||||||
|
"timestamptz": "DateTime<Utc>",
|
||||||
|
"date": "NaiveDate",
|
||||||
|
"json": "serde_json::Value",
|
||||||
|
}
|
||||||
|
|
||||||
|
for sqlType, expectedRustType := range expectedMappings {
|
||||||
|
if rustType, ok := RustTypeMap[sqlType]; !ok {
|
||||||
|
t.Errorf("RustTypeMap missing entry for %q", sqlType)
|
||||||
|
} else if rustType != expectedRustType {
|
||||||
|
t.Errorf("RustTypeMap[%q] = %q, want %q", sqlType, rustType, expectedRustType)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(RustTypeMap) == 0 {
|
||||||
|
t.Error("RustTypeMap is empty")
|
||||||
|
}
|
||||||
|
}
|
||||||
558
pkg/diff/diff_test.go
Normal file
558
pkg/diff/diff_test.go
Normal file
@@ -0,0 +1,558 @@
|
|||||||
|
package diff
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"git.warky.dev/wdevs/relspecgo/pkg/models"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestCompareDatabases(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
source *models.Database
|
||||||
|
target *models.Database
|
||||||
|
want func(*DiffResult) bool
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "identical databases",
|
||||||
|
source: &models.Database{
|
||||||
|
Name: "source",
|
||||||
|
Schemas: []*models.Schema{},
|
||||||
|
},
|
||||||
|
target: &models.Database{
|
||||||
|
Name: "target",
|
||||||
|
Schemas: []*models.Schema{},
|
||||||
|
},
|
||||||
|
want: func(r *DiffResult) bool {
|
||||||
|
return r.Source == "source" && r.Target == "target" &&
|
||||||
|
len(r.Schemas.Missing) == 0 && len(r.Schemas.Extra) == 0
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "different schemas",
|
||||||
|
source: &models.Database{
|
||||||
|
Name: "source",
|
||||||
|
Schemas: []*models.Schema{
|
||||||
|
{Name: "public"},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
target: &models.Database{
|
||||||
|
Name: "target",
|
||||||
|
Schemas: []*models.Schema{},
|
||||||
|
},
|
||||||
|
want: func(r *DiffResult) bool {
|
||||||
|
return len(r.Schemas.Missing) == 1 && r.Schemas.Missing[0].Name == "public"
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
got := CompareDatabases(tt.source, tt.target)
|
||||||
|
if !tt.want(got) {
|
||||||
|
t.Errorf("CompareDatabases() result doesn't match expectations")
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestCompareColumns(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
source map[string]*models.Column
|
||||||
|
target map[string]*models.Column
|
||||||
|
want func(*ColumnDiff) bool
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "identical columns",
|
||||||
|
source: map[string]*models.Column{},
|
||||||
|
target: map[string]*models.Column{},
|
||||||
|
want: func(d *ColumnDiff) bool {
|
||||||
|
return len(d.Missing) == 0 && len(d.Extra) == 0 && len(d.Modified) == 0
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "missing column",
|
||||||
|
source: map[string]*models.Column{
|
||||||
|
"id": {Name: "id", Type: "integer"},
|
||||||
|
},
|
||||||
|
target: map[string]*models.Column{},
|
||||||
|
want: func(d *ColumnDiff) bool {
|
||||||
|
return len(d.Missing) == 1 && d.Missing[0].Name == "id"
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "extra column",
|
||||||
|
source: map[string]*models.Column{},
|
||||||
|
target: map[string]*models.Column{
|
||||||
|
"id": {Name: "id", Type: "integer"},
|
||||||
|
},
|
||||||
|
want: func(d *ColumnDiff) bool {
|
||||||
|
return len(d.Extra) == 1 && d.Extra[0].Name == "id"
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "modified column type",
|
||||||
|
source: map[string]*models.Column{
|
||||||
|
"id": {Name: "id", Type: "integer"},
|
||||||
|
},
|
||||||
|
target: map[string]*models.Column{
|
||||||
|
"id": {Name: "id", Type: "bigint"},
|
||||||
|
},
|
||||||
|
want: func(d *ColumnDiff) bool {
|
||||||
|
return len(d.Modified) == 1 && d.Modified[0].Name == "id" &&
|
||||||
|
d.Modified[0].Changes["type"] != nil
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "modified column nullable",
|
||||||
|
source: map[string]*models.Column{
|
||||||
|
"name": {Name: "name", Type: "text", NotNull: true},
|
||||||
|
},
|
||||||
|
target: map[string]*models.Column{
|
||||||
|
"name": {Name: "name", Type: "text", NotNull: false},
|
||||||
|
},
|
||||||
|
want: func(d *ColumnDiff) bool {
|
||||||
|
return len(d.Modified) == 1 && d.Modified[0].Changes["not_null"] != nil
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "modified column length",
|
||||||
|
source: map[string]*models.Column{
|
||||||
|
"name": {Name: "name", Type: "varchar", Length: 100},
|
||||||
|
},
|
||||||
|
target: map[string]*models.Column{
|
||||||
|
"name": {Name: "name", Type: "varchar", Length: 255},
|
||||||
|
},
|
||||||
|
want: func(d *ColumnDiff) bool {
|
||||||
|
return len(d.Modified) == 1 && d.Modified[0].Changes["length"] != nil
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
got := compareColumns(tt.source, tt.target)
|
||||||
|
if !tt.want(got) {
|
||||||
|
t.Errorf("compareColumns() result doesn't match expectations")
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestCompareColumnDetails(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
source *models.Column
|
||||||
|
target *models.Column
|
||||||
|
want int // number of changes
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "identical columns",
|
||||||
|
source: &models.Column{Name: "id", Type: "integer"},
|
||||||
|
target: &models.Column{Name: "id", Type: "integer"},
|
||||||
|
want: 0,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "type change",
|
||||||
|
source: &models.Column{Name: "id", Type: "integer"},
|
||||||
|
target: &models.Column{Name: "id", Type: "bigint"},
|
||||||
|
want: 1,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "length change",
|
||||||
|
source: &models.Column{Name: "name", Type: "varchar", Length: 100},
|
||||||
|
target: &models.Column{Name: "name", Type: "varchar", Length: 255},
|
||||||
|
want: 1,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "precision change",
|
||||||
|
source: &models.Column{Name: "price", Type: "numeric", Precision: 10},
|
||||||
|
target: &models.Column{Name: "price", Type: "numeric", Precision: 12},
|
||||||
|
want: 1,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "scale change",
|
||||||
|
source: &models.Column{Name: "price", Type: "numeric", Scale: 2},
|
||||||
|
target: &models.Column{Name: "price", Type: "numeric", Scale: 4},
|
||||||
|
want: 1,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "not null change",
|
||||||
|
source: &models.Column{Name: "name", Type: "text", NotNull: true},
|
||||||
|
target: &models.Column{Name: "name", Type: "text", NotNull: false},
|
||||||
|
want: 1,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "auto increment change",
|
||||||
|
source: &models.Column{Name: "id", Type: "integer", AutoIncrement: true},
|
||||||
|
target: &models.Column{Name: "id", Type: "integer", AutoIncrement: false},
|
||||||
|
want: 1,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "primary key change",
|
||||||
|
source: &models.Column{Name: "id", Type: "integer", IsPrimaryKey: true},
|
||||||
|
target: &models.Column{Name: "id", Type: "integer", IsPrimaryKey: false},
|
||||||
|
want: 1,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "multiple changes",
|
||||||
|
source: &models.Column{Name: "id", Type: "integer", NotNull: true, AutoIncrement: true},
|
||||||
|
target: &models.Column{Name: "id", Type: "bigint", NotNull: false, AutoIncrement: false},
|
||||||
|
want: 3,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
got := compareColumnDetails(tt.source, tt.target)
|
||||||
|
if len(got) != tt.want {
|
||||||
|
t.Errorf("compareColumnDetails() = %d changes, want %d", len(got), tt.want)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestCompareIndexes(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
source map[string]*models.Index
|
||||||
|
target map[string]*models.Index
|
||||||
|
want func(*IndexDiff) bool
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "identical indexes",
|
||||||
|
source: map[string]*models.Index{},
|
||||||
|
target: map[string]*models.Index{},
|
||||||
|
want: func(d *IndexDiff) bool {
|
||||||
|
return len(d.Missing) == 0 && len(d.Extra) == 0 && len(d.Modified) == 0
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "missing index",
|
||||||
|
source: map[string]*models.Index{
|
||||||
|
"idx_name": {Name: "idx_name", Columns: []string{"name"}},
|
||||||
|
},
|
||||||
|
target: map[string]*models.Index{},
|
||||||
|
want: func(d *IndexDiff) bool {
|
||||||
|
return len(d.Missing) == 1 && d.Missing[0].Name == "idx_name"
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "extra index",
|
||||||
|
source: map[string]*models.Index{},
|
||||||
|
target: map[string]*models.Index{
|
||||||
|
"idx_name": {Name: "idx_name", Columns: []string{"name"}},
|
||||||
|
},
|
||||||
|
want: func(d *IndexDiff) bool {
|
||||||
|
return len(d.Extra) == 1 && d.Extra[0].Name == "idx_name"
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "modified index uniqueness",
|
||||||
|
source: map[string]*models.Index{
|
||||||
|
"idx_name": {Name: "idx_name", Columns: []string{"name"}, Unique: false},
|
||||||
|
},
|
||||||
|
target: map[string]*models.Index{
|
||||||
|
"idx_name": {Name: "idx_name", Columns: []string{"name"}, Unique: true},
|
||||||
|
},
|
||||||
|
want: func(d *IndexDiff) bool {
|
||||||
|
return len(d.Modified) == 1 && d.Modified[0].Name == "idx_name"
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
got := compareIndexes(tt.source, tt.target)
|
||||||
|
if !tt.want(got) {
|
||||||
|
t.Errorf("compareIndexes() result doesn't match expectations")
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestCompareConstraints(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
source map[string]*models.Constraint
|
||||||
|
target map[string]*models.Constraint
|
||||||
|
want func(*ConstraintDiff) bool
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "identical constraints",
|
||||||
|
source: map[string]*models.Constraint{},
|
||||||
|
target: map[string]*models.Constraint{},
|
||||||
|
want: func(d *ConstraintDiff) bool {
|
||||||
|
return len(d.Missing) == 0 && len(d.Extra) == 0 && len(d.Modified) == 0
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "missing constraint",
|
||||||
|
source: map[string]*models.Constraint{
|
||||||
|
"pk_id": {Name: "pk_id", Type: "PRIMARY KEY", Columns: []string{"id"}},
|
||||||
|
},
|
||||||
|
target: map[string]*models.Constraint{},
|
||||||
|
want: func(d *ConstraintDiff) bool {
|
||||||
|
return len(d.Missing) == 1 && d.Missing[0].Name == "pk_id"
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "extra constraint",
|
||||||
|
source: map[string]*models.Constraint{},
|
||||||
|
target: map[string]*models.Constraint{
|
||||||
|
"pk_id": {Name: "pk_id", Type: "PRIMARY KEY", Columns: []string{"id"}},
|
||||||
|
},
|
||||||
|
want: func(d *ConstraintDiff) bool {
|
||||||
|
return len(d.Extra) == 1 && d.Extra[0].Name == "pk_id"
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
got := compareConstraints(tt.source, tt.target)
|
||||||
|
if !tt.want(got) {
|
||||||
|
t.Errorf("compareConstraints() result doesn't match expectations")
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestCompareRelationships(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
source map[string]*models.Relationship
|
||||||
|
target map[string]*models.Relationship
|
||||||
|
want func(*RelationshipDiff) bool
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "identical relationships",
|
||||||
|
source: map[string]*models.Relationship{},
|
||||||
|
target: map[string]*models.Relationship{},
|
||||||
|
want: func(d *RelationshipDiff) bool {
|
||||||
|
return len(d.Missing) == 0 && len(d.Extra) == 0 && len(d.Modified) == 0
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "missing relationship",
|
||||||
|
source: map[string]*models.Relationship{
|
||||||
|
"fk_user": {Name: "fk_user", Type: "FOREIGN KEY"},
|
||||||
|
},
|
||||||
|
target: map[string]*models.Relationship{},
|
||||||
|
want: func(d *RelationshipDiff) bool {
|
||||||
|
return len(d.Missing) == 1 && d.Missing[0].Name == "fk_user"
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "extra relationship",
|
||||||
|
source: map[string]*models.Relationship{},
|
||||||
|
target: map[string]*models.Relationship{
|
||||||
|
"fk_user": {Name: "fk_user", Type: "FOREIGN KEY"},
|
||||||
|
},
|
||||||
|
want: func(d *RelationshipDiff) bool {
|
||||||
|
return len(d.Extra) == 1 && d.Extra[0].Name == "fk_user"
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
got := compareRelationships(tt.source, tt.target)
|
||||||
|
if !tt.want(got) {
|
||||||
|
t.Errorf("compareRelationships() result doesn't match expectations")
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestCompareTables(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
source []*models.Table
|
||||||
|
target []*models.Table
|
||||||
|
want func(*TableDiff) bool
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "identical tables",
|
||||||
|
source: []*models.Table{},
|
||||||
|
target: []*models.Table{},
|
||||||
|
want: func(d *TableDiff) bool {
|
||||||
|
return len(d.Missing) == 0 && len(d.Extra) == 0 && len(d.Modified) == 0
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "missing table",
|
||||||
|
source: []*models.Table{
|
||||||
|
{Name: "users", Schema: "public"},
|
||||||
|
},
|
||||||
|
target: []*models.Table{},
|
||||||
|
want: func(d *TableDiff) bool {
|
||||||
|
return len(d.Missing) == 1 && d.Missing[0].Name == "users"
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "extra table",
|
||||||
|
source: []*models.Table{},
|
||||||
|
target: []*models.Table{
|
||||||
|
{Name: "users", Schema: "public"},
|
||||||
|
},
|
||||||
|
want: func(d *TableDiff) bool {
|
||||||
|
return len(d.Extra) == 1 && d.Extra[0].Name == "users"
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "modified table",
|
||||||
|
source: []*models.Table{
|
||||||
|
{
|
||||||
|
Name: "users",
|
||||||
|
Schema: "public",
|
||||||
|
Columns: map[string]*models.Column{
|
||||||
|
"id": {Name: "id", Type: "integer"},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
target: []*models.Table{
|
||||||
|
{
|
||||||
|
Name: "users",
|
||||||
|
Schema: "public",
|
||||||
|
Columns: map[string]*models.Column{
|
||||||
|
"id": {Name: "id", Type: "bigint"},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
want: func(d *TableDiff) bool {
|
||||||
|
return len(d.Modified) == 1 && d.Modified[0].Name == "users"
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
got := compareTables(tt.source, tt.target)
|
||||||
|
if !tt.want(got) {
|
||||||
|
t.Errorf("compareTables() result doesn't match expectations")
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestCompareSchemas(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
source []*models.Schema
|
||||||
|
target []*models.Schema
|
||||||
|
want func(*SchemaDiff) bool
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "identical schemas",
|
||||||
|
source: []*models.Schema{},
|
||||||
|
target: []*models.Schema{},
|
||||||
|
want: func(d *SchemaDiff) bool {
|
||||||
|
return len(d.Missing) == 0 && len(d.Extra) == 0 && len(d.Modified) == 0
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "missing schema",
|
||||||
|
source: []*models.Schema{
|
||||||
|
{Name: "public"},
|
||||||
|
},
|
||||||
|
target: []*models.Schema{},
|
||||||
|
want: func(d *SchemaDiff) bool {
|
||||||
|
return len(d.Missing) == 1 && d.Missing[0].Name == "public"
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "extra schema",
|
||||||
|
source: []*models.Schema{},
|
||||||
|
target: []*models.Schema{
|
||||||
|
{Name: "public"},
|
||||||
|
},
|
||||||
|
want: func(d *SchemaDiff) bool {
|
||||||
|
return len(d.Extra) == 1 && d.Extra[0].Name == "public"
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
got := compareSchemas(tt.source, tt.target)
|
||||||
|
if !tt.want(got) {
|
||||||
|
t.Errorf("compareSchemas() result doesn't match expectations")
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestIsEmpty(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
v interface{}
|
||||||
|
want bool
|
||||||
|
}{
|
||||||
|
{"empty ColumnDiff", &ColumnDiff{Missing: []*models.Column{}, Extra: []*models.Column{}, Modified: []*ColumnChange{}}, true},
|
||||||
|
{"ColumnDiff with missing", &ColumnDiff{Missing: []*models.Column{{Name: "id"}}, Extra: []*models.Column{}, Modified: []*ColumnChange{}}, false},
|
||||||
|
{"ColumnDiff with extra", &ColumnDiff{Missing: []*models.Column{}, Extra: []*models.Column{{Name: "id"}}, Modified: []*ColumnChange{}}, false},
|
||||||
|
{"empty IndexDiff", &IndexDiff{Missing: []*models.Index{}, Extra: []*models.Index{}, Modified: []*IndexChange{}}, true},
|
||||||
|
{"IndexDiff with missing", &IndexDiff{Missing: []*models.Index{{Name: "idx"}}, Extra: []*models.Index{}, Modified: []*IndexChange{}}, false},
|
||||||
|
{"empty TableDiff", &TableDiff{Missing: []*models.Table{}, Extra: []*models.Table{}, Modified: []*TableChange{}}, true},
|
||||||
|
{"TableDiff with extra", &TableDiff{Missing: []*models.Table{}, Extra: []*models.Table{{Name: "users"}}, Modified: []*TableChange{}}, false},
|
||||||
|
{"empty ConstraintDiff", &ConstraintDiff{Missing: []*models.Constraint{}, Extra: []*models.Constraint{}, Modified: []*ConstraintChange{}}, true},
|
||||||
|
{"empty RelationshipDiff", &RelationshipDiff{Missing: []*models.Relationship{}, Extra: []*models.Relationship{}, Modified: []*RelationshipChange{}}, true},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
got := isEmpty(tt.v)
|
||||||
|
if got != tt.want {
|
||||||
|
t.Errorf("isEmpty() = %v, want %v", got, tt.want)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestComputeSummary(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
result *DiffResult
|
||||||
|
want func(*Summary) bool
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "empty diff",
|
||||||
|
result: &DiffResult{
|
||||||
|
Schemas: &SchemaDiff{
|
||||||
|
Missing: []*models.Schema{},
|
||||||
|
Extra: []*models.Schema{},
|
||||||
|
Modified: []*SchemaChange{},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
want: func(s *Summary) bool {
|
||||||
|
return s.Schemas.Missing == 0 && s.Schemas.Extra == 0 && s.Schemas.Modified == 0
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "schemas with differences",
|
||||||
|
result: &DiffResult{
|
||||||
|
Schemas: &SchemaDiff{
|
||||||
|
Missing: []*models.Schema{{Name: "schema1"}},
|
||||||
|
Extra: []*models.Schema{{Name: "schema2"}, {Name: "schema3"}},
|
||||||
|
Modified: []*SchemaChange{
|
||||||
|
{Name: "public"},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
want: func(s *Summary) bool {
|
||||||
|
return s.Schemas.Missing == 1 && s.Schemas.Extra == 2 && s.Schemas.Modified == 1
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
got := ComputeSummary(tt.result)
|
||||||
|
if !tt.want(got) {
|
||||||
|
t.Errorf("ComputeSummary() result doesn't match expectations")
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
440
pkg/diff/formatters_test.go
Normal file
440
pkg/diff/formatters_test.go
Normal file
@@ -0,0 +1,440 @@
|
|||||||
|
package diff
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"encoding/json"
|
||||||
|
"strings"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"git.warky.dev/wdevs/relspecgo/pkg/models"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestFormatDiff(t *testing.T) {
|
||||||
|
result := &DiffResult{
|
||||||
|
Source: "source_db",
|
||||||
|
Target: "target_db",
|
||||||
|
Schemas: &SchemaDiff{
|
||||||
|
Missing: []*models.Schema{},
|
||||||
|
Extra: []*models.Schema{},
|
||||||
|
Modified: []*SchemaChange{},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
format OutputFormat
|
||||||
|
wantErr bool
|
||||||
|
}{
|
||||||
|
{"summary format", FormatSummary, false},
|
||||||
|
{"json format", FormatJSON, false},
|
||||||
|
{"html format", FormatHTML, false},
|
||||||
|
{"invalid format", OutputFormat("invalid"), true},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
var buf bytes.Buffer
|
||||||
|
err := FormatDiff(result, tt.format, &buf)
|
||||||
|
|
||||||
|
if (err != nil) != tt.wantErr {
|
||||||
|
t.Errorf("FormatDiff() error = %v, wantErr %v", err, tt.wantErr)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if !tt.wantErr && buf.Len() == 0 {
|
||||||
|
t.Error("FormatDiff() produced empty output")
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestFormatSummary(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
result *DiffResult
|
||||||
|
wantStr []string // strings that should appear in output
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "no differences",
|
||||||
|
result: &DiffResult{
|
||||||
|
Source: "source",
|
||||||
|
Target: "target",
|
||||||
|
Schemas: &SchemaDiff{
|
||||||
|
Missing: []*models.Schema{},
|
||||||
|
Extra: []*models.Schema{},
|
||||||
|
Modified: []*SchemaChange{},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
wantStr: []string{"source", "target", "No differences found"},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "with schema differences",
|
||||||
|
result: &DiffResult{
|
||||||
|
Source: "source",
|
||||||
|
Target: "target",
|
||||||
|
Schemas: &SchemaDiff{
|
||||||
|
Missing: []*models.Schema{{Name: "schema1"}},
|
||||||
|
Extra: []*models.Schema{{Name: "schema2"}},
|
||||||
|
Modified: []*SchemaChange{
|
||||||
|
{Name: "public"},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
wantStr: []string{"Schemas:", "Missing: 1", "Extra: 1", "Modified: 1"},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "with table differences",
|
||||||
|
result: &DiffResult{
|
||||||
|
Source: "source",
|
||||||
|
Target: "target",
|
||||||
|
Schemas: &SchemaDiff{
|
||||||
|
Modified: []*SchemaChange{
|
||||||
|
{
|
||||||
|
Name: "public",
|
||||||
|
Tables: &TableDiff{
|
||||||
|
Missing: []*models.Table{{Name: "users"}},
|
||||||
|
Extra: []*models.Table{{Name: "posts"}},
|
||||||
|
Modified: []*TableChange{
|
||||||
|
{Name: "comments", Schema: "public"},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
wantStr: []string{"Tables:", "Missing: 1", "Extra: 1", "Modified: 1"},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
var buf bytes.Buffer
|
||||||
|
err := formatSummary(tt.result, &buf)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("formatSummary() error = %v", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
output := buf.String()
|
||||||
|
for _, want := range tt.wantStr {
|
||||||
|
if !strings.Contains(output, want) {
|
||||||
|
t.Errorf("formatSummary() output doesn't contain %q\nGot: %s", want, output)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestFormatJSON(t *testing.T) {
|
||||||
|
result := &DiffResult{
|
||||||
|
Source: "source",
|
||||||
|
Target: "target",
|
||||||
|
Schemas: &SchemaDiff{
|
||||||
|
Missing: []*models.Schema{{Name: "schema1"}},
|
||||||
|
Extra: []*models.Schema{},
|
||||||
|
Modified: []*SchemaChange{},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
var buf bytes.Buffer
|
||||||
|
err := formatJSON(result, &buf)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("formatJSON() error = %v", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if output is valid JSON
|
||||||
|
var decoded DiffResult
|
||||||
|
if err := json.Unmarshal(buf.Bytes(), &decoded); err != nil {
|
||||||
|
t.Errorf("formatJSON() produced invalid JSON: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check basic structure
|
||||||
|
if decoded.Source != "source" {
|
||||||
|
t.Errorf("formatJSON() source = %v, want %v", decoded.Source, "source")
|
||||||
|
}
|
||||||
|
if decoded.Target != "target" {
|
||||||
|
t.Errorf("formatJSON() target = %v, want %v", decoded.Target, "target")
|
||||||
|
}
|
||||||
|
if len(decoded.Schemas.Missing) != 1 {
|
||||||
|
t.Errorf("formatJSON() missing schemas = %v, want 1", len(decoded.Schemas.Missing))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestFormatHTML(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
result *DiffResult
|
||||||
|
wantStr []string // HTML elements/content that should appear
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "basic HTML structure",
|
||||||
|
result: &DiffResult{
|
||||||
|
Source: "source",
|
||||||
|
Target: "target",
|
||||||
|
Schemas: &SchemaDiff{
|
||||||
|
Missing: []*models.Schema{},
|
||||||
|
Extra: []*models.Schema{},
|
||||||
|
Modified: []*SchemaChange{},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
wantStr: []string{
|
||||||
|
"<!DOCTYPE html>",
|
||||||
|
"<title>Database Diff Report</title>",
|
||||||
|
"source",
|
||||||
|
"target",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "with schema differences",
|
||||||
|
result: &DiffResult{
|
||||||
|
Source: "source",
|
||||||
|
Target: "target",
|
||||||
|
Schemas: &SchemaDiff{
|
||||||
|
Missing: []*models.Schema{{Name: "missing_schema"}},
|
||||||
|
Extra: []*models.Schema{{Name: "extra_schema"}},
|
||||||
|
Modified: []*SchemaChange{},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
wantStr: []string{
|
||||||
|
"<!DOCTYPE html>",
|
||||||
|
"missing_schema",
|
||||||
|
"extra_schema",
|
||||||
|
"MISSING",
|
||||||
|
"EXTRA",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "with table modifications",
|
||||||
|
result: &DiffResult{
|
||||||
|
Source: "source",
|
||||||
|
Target: "target",
|
||||||
|
Schemas: &SchemaDiff{
|
||||||
|
Modified: []*SchemaChange{
|
||||||
|
{
|
||||||
|
Name: "public",
|
||||||
|
Tables: &TableDiff{
|
||||||
|
Modified: []*TableChange{
|
||||||
|
{
|
||||||
|
Name: "users",
|
||||||
|
Schema: "public",
|
||||||
|
Columns: &ColumnDiff{
|
||||||
|
Missing: []*models.Column{{Name: "email", Type: "text"}},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
wantStr: []string{
|
||||||
|
"public",
|
||||||
|
"users",
|
||||||
|
"email",
|
||||||
|
"text",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
var buf bytes.Buffer
|
||||||
|
err := formatHTML(tt.result, &buf)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("formatHTML() error = %v", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
output := buf.String()
|
||||||
|
for _, want := range tt.wantStr {
|
||||||
|
if !strings.Contains(output, want) {
|
||||||
|
t.Errorf("formatHTML() output doesn't contain %q", want)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestFormatSummaryWithColumns(t *testing.T) {
|
||||||
|
result := &DiffResult{
|
||||||
|
Source: "source",
|
||||||
|
Target: "target",
|
||||||
|
Schemas: &SchemaDiff{
|
||||||
|
Modified: []*SchemaChange{
|
||||||
|
{
|
||||||
|
Name: "public",
|
||||||
|
Tables: &TableDiff{
|
||||||
|
Modified: []*TableChange{
|
||||||
|
{
|
||||||
|
Name: "users",
|
||||||
|
Schema: "public",
|
||||||
|
Columns: &ColumnDiff{
|
||||||
|
Missing: []*models.Column{{Name: "email"}},
|
||||||
|
Extra: []*models.Column{{Name: "phone"}, {Name: "address"}},
|
||||||
|
Modified: []*ColumnChange{
|
||||||
|
{Name: "name"},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
var buf bytes.Buffer
|
||||||
|
err := formatSummary(result, &buf)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("formatSummary() error = %v", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
output := buf.String()
|
||||||
|
wantStrings := []string{
|
||||||
|
"Columns:",
|
||||||
|
"Missing: 1",
|
||||||
|
"Extra: 2",
|
||||||
|
"Modified: 1",
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, want := range wantStrings {
|
||||||
|
if !strings.Contains(output, want) {
|
||||||
|
t.Errorf("formatSummary() output doesn't contain %q\nGot: %s", want, output)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestFormatSummaryWithIndexes(t *testing.T) {
|
||||||
|
result := &DiffResult{
|
||||||
|
Source: "source",
|
||||||
|
Target: "target",
|
||||||
|
Schemas: &SchemaDiff{
|
||||||
|
Modified: []*SchemaChange{
|
||||||
|
{
|
||||||
|
Name: "public",
|
||||||
|
Tables: &TableDiff{
|
||||||
|
Modified: []*TableChange{
|
||||||
|
{
|
||||||
|
Name: "users",
|
||||||
|
Schema: "public",
|
||||||
|
Indexes: &IndexDiff{
|
||||||
|
Missing: []*models.Index{{Name: "idx_email"}},
|
||||||
|
Extra: []*models.Index{{Name: "idx_phone"}},
|
||||||
|
Modified: []*IndexChange{{Name: "idx_name"}},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
var buf bytes.Buffer
|
||||||
|
err := formatSummary(result, &buf)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("formatSummary() error = %v", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
output := buf.String()
|
||||||
|
if !strings.Contains(output, "Indexes:") {
|
||||||
|
t.Error("formatSummary() output doesn't contain Indexes section")
|
||||||
|
}
|
||||||
|
if !strings.Contains(output, "Missing: 1") {
|
||||||
|
t.Error("formatSummary() output doesn't contain correct missing count")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestFormatSummaryWithConstraints(t *testing.T) {
|
||||||
|
result := &DiffResult{
|
||||||
|
Source: "source",
|
||||||
|
Target: "target",
|
||||||
|
Schemas: &SchemaDiff{
|
||||||
|
Modified: []*SchemaChange{
|
||||||
|
{
|
||||||
|
Name: "public",
|
||||||
|
Tables: &TableDiff{
|
||||||
|
Modified: []*TableChange{
|
||||||
|
{
|
||||||
|
Name: "users",
|
||||||
|
Schema: "public",
|
||||||
|
Constraints: &ConstraintDiff{
|
||||||
|
Missing: []*models.Constraint{{Name: "pk_users", Type: "PRIMARY KEY"}},
|
||||||
|
Extra: []*models.Constraint{{Name: "fk_users_roles", Type: "FOREIGN KEY"}},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
var buf bytes.Buffer
|
||||||
|
err := formatSummary(result, &buf)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("formatSummary() error = %v", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
output := buf.String()
|
||||||
|
if !strings.Contains(output, "Constraints:") {
|
||||||
|
t.Error("formatSummary() output doesn't contain Constraints section")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestFormatJSONIndentation(t *testing.T) {
|
||||||
|
result := &DiffResult{
|
||||||
|
Source: "source",
|
||||||
|
Target: "target",
|
||||||
|
Schemas: &SchemaDiff{
|
||||||
|
Missing: []*models.Schema{{Name: "test"}},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
var buf bytes.Buffer
|
||||||
|
err := formatJSON(result, &buf)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("formatJSON() error = %v", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check that JSON is indented (has newlines and spaces)
|
||||||
|
output := buf.String()
|
||||||
|
if !strings.Contains(output, "\n") {
|
||||||
|
t.Error("formatJSON() should produce indented JSON with newlines")
|
||||||
|
}
|
||||||
|
if !strings.Contains(output, " ") {
|
||||||
|
t.Error("formatJSON() should produce indented JSON with spaces")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestOutputFormatConstants(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
format OutputFormat
|
||||||
|
want string
|
||||||
|
}{
|
||||||
|
{"summary constant", FormatSummary, "summary"},
|
||||||
|
{"json constant", FormatJSON, "json"},
|
||||||
|
{"html constant", FormatHTML, "html"},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
if string(tt.format) != tt.want {
|
||||||
|
t.Errorf("OutputFormat %v = %v, want %v", tt.name, tt.format, tt.want)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
238
pkg/inspector/inspector_test.go
Normal file
238
pkg/inspector/inspector_test.go
Normal file
@@ -0,0 +1,238 @@
|
|||||||
|
package inspector
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestNewInspector(t *testing.T) {
|
||||||
|
db := createTestDatabase()
|
||||||
|
config := GetDefaultConfig()
|
||||||
|
|
||||||
|
inspector := NewInspector(db, config)
|
||||||
|
|
||||||
|
if inspector == nil {
|
||||||
|
t.Fatal("NewInspector() returned nil")
|
||||||
|
}
|
||||||
|
|
||||||
|
if inspector.db != db {
|
||||||
|
t.Error("NewInspector() database not set correctly")
|
||||||
|
}
|
||||||
|
|
||||||
|
if inspector.config != config {
|
||||||
|
t.Error("NewInspector() config not set correctly")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestInspect(t *testing.T) {
|
||||||
|
db := createTestDatabase()
|
||||||
|
config := GetDefaultConfig()
|
||||||
|
|
||||||
|
inspector := NewInspector(db, config)
|
||||||
|
report, err := inspector.Inspect()
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Inspect() returned error: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if report == nil {
|
||||||
|
t.Fatal("Inspect() returned nil report")
|
||||||
|
}
|
||||||
|
|
||||||
|
if report.Database != db.Name {
|
||||||
|
t.Errorf("Inspect() report.Database = %q, want %q", report.Database, db.Name)
|
||||||
|
}
|
||||||
|
|
||||||
|
if report.Summary.TotalRules != len(config.Rules) {
|
||||||
|
t.Errorf("Inspect() TotalRules = %d, want %d", report.Summary.TotalRules, len(config.Rules))
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(report.Violations) == 0 {
|
||||||
|
t.Error("Inspect() returned no violations, expected some results")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestInspectWithDisabledRules(t *testing.T) {
|
||||||
|
db := createTestDatabase()
|
||||||
|
config := GetDefaultConfig()
|
||||||
|
|
||||||
|
// Disable all rules
|
||||||
|
for name := range config.Rules {
|
||||||
|
rule := config.Rules[name]
|
||||||
|
rule.Enabled = "off"
|
||||||
|
config.Rules[name] = rule
|
||||||
|
}
|
||||||
|
|
||||||
|
inspector := NewInspector(db, config)
|
||||||
|
report, err := inspector.Inspect()
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Inspect() with disabled rules returned error: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if report.Summary.RulesChecked != 0 {
|
||||||
|
t.Errorf("Inspect() RulesChecked = %d, want 0 (all disabled)", report.Summary.RulesChecked)
|
||||||
|
}
|
||||||
|
|
||||||
|
if report.Summary.RulesSkipped != len(config.Rules) {
|
||||||
|
t.Errorf("Inspect() RulesSkipped = %d, want %d", report.Summary.RulesSkipped, len(config.Rules))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestInspectWithEnforcedRules(t *testing.T) {
|
||||||
|
db := createTestDatabase()
|
||||||
|
config := GetDefaultConfig()
|
||||||
|
|
||||||
|
// Enable only one rule and enforce it
|
||||||
|
for name := range config.Rules {
|
||||||
|
rule := config.Rules[name]
|
||||||
|
rule.Enabled = "off"
|
||||||
|
config.Rules[name] = rule
|
||||||
|
}
|
||||||
|
|
||||||
|
primaryKeyRule := config.Rules["primary_key_naming"]
|
||||||
|
primaryKeyRule.Enabled = "enforce"
|
||||||
|
primaryKeyRule.Pattern = "^id$"
|
||||||
|
config.Rules["primary_key_naming"] = primaryKeyRule
|
||||||
|
|
||||||
|
inspector := NewInspector(db, config)
|
||||||
|
report, err := inspector.Inspect()
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Inspect() returned error: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if report.Summary.RulesChecked != 1 {
|
||||||
|
t.Errorf("Inspect() RulesChecked = %d, want 1", report.Summary.RulesChecked)
|
||||||
|
}
|
||||||
|
|
||||||
|
// All results should be at error level for enforced rules
|
||||||
|
for _, violation := range report.Violations {
|
||||||
|
if violation.Level != "error" {
|
||||||
|
t.Errorf("Enforced rule violation has Level = %q, want \"error\"", violation.Level)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestGenerateSummary(t *testing.T) {
|
||||||
|
db := createTestDatabase()
|
||||||
|
config := GetDefaultConfig()
|
||||||
|
inspector := NewInspector(db, config)
|
||||||
|
|
||||||
|
results := []ValidationResult{
|
||||||
|
{RuleName: "rule1", Passed: true, Level: "error"},
|
||||||
|
{RuleName: "rule2", Passed: false, Level: "error"},
|
||||||
|
{RuleName: "rule3", Passed: false, Level: "warning"},
|
||||||
|
{RuleName: "rule4", Passed: true, Level: "warning"},
|
||||||
|
}
|
||||||
|
|
||||||
|
summary := inspector.generateSummary(results)
|
||||||
|
|
||||||
|
if summary.PassedCount != 2 {
|
||||||
|
t.Errorf("generateSummary() PassedCount = %d, want 2", summary.PassedCount)
|
||||||
|
}
|
||||||
|
|
||||||
|
if summary.ErrorCount != 1 {
|
||||||
|
t.Errorf("generateSummary() ErrorCount = %d, want 1", summary.ErrorCount)
|
||||||
|
}
|
||||||
|
|
||||||
|
if summary.WarningCount != 1 {
|
||||||
|
t.Errorf("generateSummary() WarningCount = %d, want 1", summary.WarningCount)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestHasErrors(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
report *InspectorReport
|
||||||
|
want bool
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "with errors",
|
||||||
|
report: &InspectorReport{
|
||||||
|
Summary: ReportSummary{
|
||||||
|
ErrorCount: 5,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
want: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "without errors",
|
||||||
|
report: &InspectorReport{
|
||||||
|
Summary: ReportSummary{
|
||||||
|
ErrorCount: 0,
|
||||||
|
WarningCount: 3,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
want: false,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
if got := tt.report.HasErrors(); got != tt.want {
|
||||||
|
t.Errorf("HasErrors() = %v, want %v", got, tt.want)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestGetValidator(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
functionName string
|
||||||
|
wantExists bool
|
||||||
|
}{
|
||||||
|
{"primary_key_naming", "primary_key_naming", true},
|
||||||
|
{"primary_key_datatype", "primary_key_datatype", true},
|
||||||
|
{"foreign_key_column_naming", "foreign_key_column_naming", true},
|
||||||
|
{"table_regexpr", "table_regexpr", true},
|
||||||
|
{"column_regexpr", "column_regexpr", true},
|
||||||
|
{"reserved_words", "reserved_words", true},
|
||||||
|
{"have_primary_key", "have_primary_key", true},
|
||||||
|
{"orphaned_foreign_key", "orphaned_foreign_key", true},
|
||||||
|
{"circular_dependency", "circular_dependency", true},
|
||||||
|
{"unknown_function", "unknown_function", false},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
_, exists := getValidator(tt.functionName)
|
||||||
|
if exists != tt.wantExists {
|
||||||
|
t.Errorf("getValidator(%q) exists = %v, want %v", tt.functionName, exists, tt.wantExists)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestCreateResult(t *testing.T) {
|
||||||
|
result := createResult(
|
||||||
|
"test_rule",
|
||||||
|
true,
|
||||||
|
"Test message",
|
||||||
|
"schema.table.column",
|
||||||
|
map[string]interface{}{
|
||||||
|
"key1": "value1",
|
||||||
|
"key2": 42,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
if result.RuleName != "test_rule" {
|
||||||
|
t.Errorf("createResult() RuleName = %q, want \"test_rule\"", result.RuleName)
|
||||||
|
}
|
||||||
|
|
||||||
|
if !result.Passed {
|
||||||
|
t.Error("createResult() Passed = false, want true")
|
||||||
|
}
|
||||||
|
|
||||||
|
if result.Message != "Test message" {
|
||||||
|
t.Errorf("createResult() Message = %q, want \"Test message\"", result.Message)
|
||||||
|
}
|
||||||
|
|
||||||
|
if result.Location != "schema.table.column" {
|
||||||
|
t.Errorf("createResult() Location = %q, want \"schema.table.column\"", result.Location)
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(result.Context) != 2 {
|
||||||
|
t.Errorf("createResult() Context length = %d, want 2", len(result.Context))
|
||||||
|
}
|
||||||
|
}
|
||||||
366
pkg/inspector/report_test.go
Normal file
366
pkg/inspector/report_test.go
Normal file
@@ -0,0 +1,366 @@
|
|||||||
|
package inspector
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"encoding/json"
|
||||||
|
"strings"
|
||||||
|
"testing"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
func createTestReport() *InspectorReport {
|
||||||
|
return &InspectorReport{
|
||||||
|
Summary: ReportSummary{
|
||||||
|
TotalRules: 10,
|
||||||
|
RulesChecked: 8,
|
||||||
|
RulesSkipped: 2,
|
||||||
|
ErrorCount: 3,
|
||||||
|
WarningCount: 5,
|
||||||
|
PassedCount: 12,
|
||||||
|
},
|
||||||
|
Violations: []ValidationResult{
|
||||||
|
{
|
||||||
|
RuleName: "primary_key_naming",
|
||||||
|
Level: "error",
|
||||||
|
Message: "Primary key should start with 'id_'",
|
||||||
|
Location: "public.users.user_id",
|
||||||
|
Passed: false,
|
||||||
|
Context: map[string]interface{}{
|
||||||
|
"schema": "public",
|
||||||
|
"table": "users",
|
||||||
|
"column": "user_id",
|
||||||
|
"pattern": "^id_",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
RuleName: "table_name_length",
|
||||||
|
Level: "warning",
|
||||||
|
Message: "Table name too long",
|
||||||
|
Location: "public.very_long_table_name_that_exceeds_limits",
|
||||||
|
Passed: false,
|
||||||
|
Context: map[string]interface{}{
|
||||||
|
"schema": "public",
|
||||||
|
"table": "very_long_table_name_that_exceeds_limits",
|
||||||
|
"length": 44,
|
||||||
|
"max_length": 32,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
GeneratedAt: time.Now(),
|
||||||
|
Database: "testdb",
|
||||||
|
SourceFormat: "postgresql",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestNewMarkdownFormatter(t *testing.T) {
|
||||||
|
var buf bytes.Buffer
|
||||||
|
formatter := NewMarkdownFormatter(&buf)
|
||||||
|
|
||||||
|
if formatter == nil {
|
||||||
|
t.Fatal("NewMarkdownFormatter() returned nil")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Buffer is not a terminal, so colors should be disabled
|
||||||
|
if formatter.UseColors {
|
||||||
|
t.Error("NewMarkdownFormatter() UseColors should be false for non-terminal")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestNewJSONFormatter(t *testing.T) {
|
||||||
|
formatter := NewJSONFormatter()
|
||||||
|
|
||||||
|
if formatter == nil {
|
||||||
|
t.Fatal("NewJSONFormatter() returned nil")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestMarkdownFormatter_Format(t *testing.T) {
|
||||||
|
report := createTestReport()
|
||||||
|
var buf bytes.Buffer
|
||||||
|
formatter := NewMarkdownFormatter(&buf)
|
||||||
|
|
||||||
|
output, err := formatter.Format(report)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("MarkdownFormatter.Format() returned error: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check that output contains expected sections
|
||||||
|
if !strings.Contains(output, "# RelSpec Inspector Report") {
|
||||||
|
t.Error("Markdown output missing header")
|
||||||
|
}
|
||||||
|
|
||||||
|
if !strings.Contains(output, "Database:") {
|
||||||
|
t.Error("Markdown output missing database field")
|
||||||
|
}
|
||||||
|
|
||||||
|
if !strings.Contains(output, "testdb") {
|
||||||
|
t.Error("Markdown output missing database name")
|
||||||
|
}
|
||||||
|
|
||||||
|
if !strings.Contains(output, "Summary") {
|
||||||
|
t.Error("Markdown output missing summary section")
|
||||||
|
}
|
||||||
|
|
||||||
|
if !strings.Contains(output, "Rules Checked: 8") {
|
||||||
|
t.Error("Markdown output missing rules checked count")
|
||||||
|
}
|
||||||
|
|
||||||
|
if !strings.Contains(output, "Errors: 3") {
|
||||||
|
t.Error("Markdown output missing error count")
|
||||||
|
}
|
||||||
|
|
||||||
|
if !strings.Contains(output, "Warnings: 5") {
|
||||||
|
t.Error("Markdown output missing warning count")
|
||||||
|
}
|
||||||
|
|
||||||
|
if !strings.Contains(output, "Violations") {
|
||||||
|
t.Error("Markdown output missing violations section")
|
||||||
|
}
|
||||||
|
|
||||||
|
if !strings.Contains(output, "primary_key_naming") {
|
||||||
|
t.Error("Markdown output missing rule name")
|
||||||
|
}
|
||||||
|
|
||||||
|
if !strings.Contains(output, "public.users.user_id") {
|
||||||
|
t.Error("Markdown output missing location")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestMarkdownFormatter_FormatNoViolations(t *testing.T) {
|
||||||
|
report := &InspectorReport{
|
||||||
|
Summary: ReportSummary{
|
||||||
|
TotalRules: 10,
|
||||||
|
RulesChecked: 10,
|
||||||
|
RulesSkipped: 0,
|
||||||
|
ErrorCount: 0,
|
||||||
|
WarningCount: 0,
|
||||||
|
PassedCount: 50,
|
||||||
|
},
|
||||||
|
Violations: []ValidationResult{},
|
||||||
|
GeneratedAt: time.Now(),
|
||||||
|
Database: "testdb",
|
||||||
|
SourceFormat: "postgresql",
|
||||||
|
}
|
||||||
|
|
||||||
|
var buf bytes.Buffer
|
||||||
|
formatter := NewMarkdownFormatter(&buf)
|
||||||
|
|
||||||
|
output, err := formatter.Format(report)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("MarkdownFormatter.Format() returned error: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if !strings.Contains(output, "No violations found") {
|
||||||
|
t.Error("Markdown output should indicate no violations")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestJSONFormatter_Format(t *testing.T) {
|
||||||
|
report := createTestReport()
|
||||||
|
formatter := NewJSONFormatter()
|
||||||
|
|
||||||
|
output, err := formatter.Format(report)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("JSONFormatter.Format() returned error: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Verify it's valid JSON
|
||||||
|
var decoded InspectorReport
|
||||||
|
if err := json.Unmarshal([]byte(output), &decoded); err != nil {
|
||||||
|
t.Fatalf("JSONFormatter.Format() produced invalid JSON: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check key fields
|
||||||
|
if decoded.Database != "testdb" {
|
||||||
|
t.Errorf("JSON decoded Database = %q, want \"testdb\"", decoded.Database)
|
||||||
|
}
|
||||||
|
|
||||||
|
if decoded.Summary.ErrorCount != 3 {
|
||||||
|
t.Errorf("JSON decoded ErrorCount = %d, want 3", decoded.Summary.ErrorCount)
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(decoded.Violations) != 2 {
|
||||||
|
t.Errorf("JSON decoded Violations length = %d, want 2", len(decoded.Violations))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestMarkdownFormatter_FormatHeader(t *testing.T) {
|
||||||
|
var buf bytes.Buffer
|
||||||
|
formatter := NewMarkdownFormatter(&buf)
|
||||||
|
|
||||||
|
header := formatter.formatHeader("Test Header")
|
||||||
|
|
||||||
|
if !strings.Contains(header, "# Test Header") {
|
||||||
|
t.Errorf("formatHeader() = %q, want to contain \"# Test Header\"", header)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestMarkdownFormatter_FormatBold(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
useColors bool
|
||||||
|
text string
|
||||||
|
wantContains string
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "without colors",
|
||||||
|
useColors: false,
|
||||||
|
text: "Bold Text",
|
||||||
|
wantContains: "**Bold Text**",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "with colors",
|
||||||
|
useColors: true,
|
||||||
|
text: "Bold Text",
|
||||||
|
wantContains: "Bold Text",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
formatter := &MarkdownFormatter{UseColors: tt.useColors}
|
||||||
|
result := formatter.formatBold(tt.text)
|
||||||
|
|
||||||
|
if !strings.Contains(result, tt.wantContains) {
|
||||||
|
t.Errorf("formatBold() = %q, want to contain %q", result, tt.wantContains)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestMarkdownFormatter_Colorize(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
useColors bool
|
||||||
|
text string
|
||||||
|
color string
|
||||||
|
wantColor bool
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "without colors",
|
||||||
|
useColors: false,
|
||||||
|
text: "Test",
|
||||||
|
color: colorRed,
|
||||||
|
wantColor: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "with colors",
|
||||||
|
useColors: true,
|
||||||
|
text: "Test",
|
||||||
|
color: colorRed,
|
||||||
|
wantColor: true,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
formatter := &MarkdownFormatter{UseColors: tt.useColors}
|
||||||
|
result := formatter.colorize(tt.text, tt.color)
|
||||||
|
|
||||||
|
hasColor := strings.Contains(result, tt.color)
|
||||||
|
if hasColor != tt.wantColor {
|
||||||
|
t.Errorf("colorize() has color codes = %v, want %v", hasColor, tt.wantColor)
|
||||||
|
}
|
||||||
|
|
||||||
|
if !strings.Contains(result, tt.text) {
|
||||||
|
t.Errorf("colorize() doesn't contain original text %q", tt.text)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestMarkdownFormatter_FormatContext(t *testing.T) {
|
||||||
|
formatter := &MarkdownFormatter{UseColors: false}
|
||||||
|
|
||||||
|
context := map[string]interface{}{
|
||||||
|
"schema": "public",
|
||||||
|
"table": "users",
|
||||||
|
"column": "id",
|
||||||
|
"pattern": "^id_",
|
||||||
|
"max_length": 64,
|
||||||
|
}
|
||||||
|
|
||||||
|
result := formatter.formatContext(context)
|
||||||
|
|
||||||
|
// Should not include schema, table, column (they're in location)
|
||||||
|
if strings.Contains(result, "schema") {
|
||||||
|
t.Error("formatContext() should skip schema field")
|
||||||
|
}
|
||||||
|
|
||||||
|
if strings.Contains(result, "table=") {
|
||||||
|
t.Error("formatContext() should skip table field")
|
||||||
|
}
|
||||||
|
|
||||||
|
if strings.Contains(result, "column=") {
|
||||||
|
t.Error("formatContext() should skip column field")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Should include other fields
|
||||||
|
if !strings.Contains(result, "pattern") {
|
||||||
|
t.Error("formatContext() should include pattern field")
|
||||||
|
}
|
||||||
|
|
||||||
|
if !strings.Contains(result, "max_length") {
|
||||||
|
t.Error("formatContext() should include max_length field")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestMarkdownFormatter_FormatViolation(t *testing.T) {
|
||||||
|
formatter := &MarkdownFormatter{UseColors: false}
|
||||||
|
|
||||||
|
violation := ValidationResult{
|
||||||
|
RuleName: "test_rule",
|
||||||
|
Level: "error",
|
||||||
|
Message: "Test violation message",
|
||||||
|
Location: "public.users.id",
|
||||||
|
Passed: false,
|
||||||
|
Context: map[string]interface{}{
|
||||||
|
"pattern": "^id_",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
result := formatter.formatViolation(violation, colorRed)
|
||||||
|
|
||||||
|
if !strings.Contains(result, "test_rule") {
|
||||||
|
t.Error("formatViolation() should include rule name")
|
||||||
|
}
|
||||||
|
|
||||||
|
if !strings.Contains(result, "Test violation message") {
|
||||||
|
t.Error("formatViolation() should include message")
|
||||||
|
}
|
||||||
|
|
||||||
|
if !strings.Contains(result, "public.users.id") {
|
||||||
|
t.Error("formatViolation() should include location")
|
||||||
|
}
|
||||||
|
|
||||||
|
if !strings.Contains(result, "Location:") {
|
||||||
|
t.Error("formatViolation() should include Location label")
|
||||||
|
}
|
||||||
|
|
||||||
|
if !strings.Contains(result, "Message:") {
|
||||||
|
t.Error("formatViolation() should include Message label")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestReportFormatConstants(t *testing.T) {
|
||||||
|
// Test that color constants are defined
|
||||||
|
if colorReset == "" {
|
||||||
|
t.Error("colorReset is not defined")
|
||||||
|
}
|
||||||
|
|
||||||
|
if colorRed == "" {
|
||||||
|
t.Error("colorRed is not defined")
|
||||||
|
}
|
||||||
|
|
||||||
|
if colorYellow == "" {
|
||||||
|
t.Error("colorYellow is not defined")
|
||||||
|
}
|
||||||
|
|
||||||
|
if colorGreen == "" {
|
||||||
|
t.Error("colorGreen is not defined")
|
||||||
|
}
|
||||||
|
|
||||||
|
if colorBold == "" {
|
||||||
|
t.Error("colorBold is not defined")
|
||||||
|
}
|
||||||
|
}
|
||||||
249
pkg/inspector/rules_test.go
Normal file
249
pkg/inspector/rules_test.go
Normal file
@@ -0,0 +1,249 @@
|
|||||||
|
package inspector
|
||||||
|
|
||||||
|
import (
|
||||||
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestGetDefaultConfig(t *testing.T) {
|
||||||
|
config := GetDefaultConfig()
|
||||||
|
|
||||||
|
if config == nil {
|
||||||
|
t.Fatal("GetDefaultConfig() returned nil")
|
||||||
|
}
|
||||||
|
|
||||||
|
if config.Version != "1.0" {
|
||||||
|
t.Errorf("GetDefaultConfig() Version = %q, want \"1.0\"", config.Version)
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(config.Rules) == 0 {
|
||||||
|
t.Error("GetDefaultConfig() returned no rules")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check that all expected rules are present
|
||||||
|
expectedRules := []string{
|
||||||
|
"primary_key_naming",
|
||||||
|
"primary_key_datatype",
|
||||||
|
"primary_key_auto_increment",
|
||||||
|
"foreign_key_column_naming",
|
||||||
|
"foreign_key_constraint_naming",
|
||||||
|
"foreign_key_index",
|
||||||
|
"table_naming_case",
|
||||||
|
"column_naming_case",
|
||||||
|
"table_name_length",
|
||||||
|
"column_name_length",
|
||||||
|
"reserved_keywords",
|
||||||
|
"missing_primary_key",
|
||||||
|
"orphaned_foreign_key",
|
||||||
|
"circular_dependency",
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, ruleName := range expectedRules {
|
||||||
|
if _, exists := config.Rules[ruleName]; !exists {
|
||||||
|
t.Errorf("GetDefaultConfig() missing rule: %q", ruleName)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestLoadConfig_NonExistentFile(t *testing.T) {
|
||||||
|
// Try to load a non-existent file
|
||||||
|
config, err := LoadConfig("/path/to/nonexistent/file.yaml")
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("LoadConfig() with non-existent file returned error: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Should return default config
|
||||||
|
if config == nil {
|
||||||
|
t.Fatal("LoadConfig() returned nil config for non-existent file")
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(config.Rules) == 0 {
|
||||||
|
t.Error("LoadConfig() returned config with no rules")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestLoadConfig_ValidFile(t *testing.T) {
|
||||||
|
// Create a temporary config file
|
||||||
|
tmpDir := t.TempDir()
|
||||||
|
configPath := filepath.Join(tmpDir, "test-config.yaml")
|
||||||
|
|
||||||
|
configContent := `version: "1.0"
|
||||||
|
rules:
|
||||||
|
primary_key_naming:
|
||||||
|
enabled: "enforce"
|
||||||
|
function: "primary_key_naming"
|
||||||
|
pattern: "^pk_"
|
||||||
|
message: "Primary keys must start with pk_"
|
||||||
|
table_name_length:
|
||||||
|
enabled: "warn"
|
||||||
|
function: "table_name_length"
|
||||||
|
max_length: 50
|
||||||
|
message: "Table name too long"
|
||||||
|
`
|
||||||
|
|
||||||
|
err := os.WriteFile(configPath, []byte(configContent), 0644)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Failed to create test config file: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
config, err := LoadConfig(configPath)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("LoadConfig() returned error: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if config.Version != "1.0" {
|
||||||
|
t.Errorf("LoadConfig() Version = %q, want \"1.0\"", config.Version)
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(config.Rules) != 2 {
|
||||||
|
t.Errorf("LoadConfig() loaded %d rules, want 2", len(config.Rules))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check primary_key_naming rule
|
||||||
|
pkRule, exists := config.Rules["primary_key_naming"]
|
||||||
|
if !exists {
|
||||||
|
t.Fatal("LoadConfig() missing primary_key_naming rule")
|
||||||
|
}
|
||||||
|
|
||||||
|
if pkRule.Enabled != "enforce" {
|
||||||
|
t.Errorf("primary_key_naming.Enabled = %q, want \"enforce\"", pkRule.Enabled)
|
||||||
|
}
|
||||||
|
|
||||||
|
if pkRule.Pattern != "^pk_" {
|
||||||
|
t.Errorf("primary_key_naming.Pattern = %q, want \"^pk_\"", pkRule.Pattern)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check table_name_length rule
|
||||||
|
lengthRule, exists := config.Rules["table_name_length"]
|
||||||
|
if !exists {
|
||||||
|
t.Fatal("LoadConfig() missing table_name_length rule")
|
||||||
|
}
|
||||||
|
|
||||||
|
if lengthRule.MaxLength != 50 {
|
||||||
|
t.Errorf("table_name_length.MaxLength = %d, want 50", lengthRule.MaxLength)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestLoadConfig_InvalidYAML(t *testing.T) {
|
||||||
|
// Create a temporary invalid config file
|
||||||
|
tmpDir := t.TempDir()
|
||||||
|
configPath := filepath.Join(tmpDir, "invalid-config.yaml")
|
||||||
|
|
||||||
|
invalidContent := `invalid: yaml: content: {[}]`
|
||||||
|
|
||||||
|
err := os.WriteFile(configPath, []byte(invalidContent), 0644)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Failed to create test config file: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err = LoadConfig(configPath)
|
||||||
|
if err == nil {
|
||||||
|
t.Error("LoadConfig() with invalid YAML did not return error")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestRuleIsEnabled(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
rule Rule
|
||||||
|
want bool
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "enforce is enabled",
|
||||||
|
rule: Rule{Enabled: "enforce"},
|
||||||
|
want: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "warn is enabled",
|
||||||
|
rule: Rule{Enabled: "warn"},
|
||||||
|
want: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "off is not enabled",
|
||||||
|
rule: Rule{Enabled: "off"},
|
||||||
|
want: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "empty is not enabled",
|
||||||
|
rule: Rule{Enabled: ""},
|
||||||
|
want: false,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
if got := tt.rule.IsEnabled(); got != tt.want {
|
||||||
|
t.Errorf("Rule.IsEnabled() = %v, want %v", got, tt.want)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestRuleIsEnforced(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
rule Rule
|
||||||
|
want bool
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "enforce is enforced",
|
||||||
|
rule: Rule{Enabled: "enforce"},
|
||||||
|
want: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "warn is not enforced",
|
||||||
|
rule: Rule{Enabled: "warn"},
|
||||||
|
want: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "off is not enforced",
|
||||||
|
rule: Rule{Enabled: "off"},
|
||||||
|
want: false,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
if got := tt.rule.IsEnforced(); got != tt.want {
|
||||||
|
t.Errorf("Rule.IsEnforced() = %v, want %v", got, tt.want)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestDefaultConfigRuleSettings(t *testing.T) {
|
||||||
|
config := GetDefaultConfig()
|
||||||
|
|
||||||
|
// Test specific rule settings
|
||||||
|
pkNamingRule := config.Rules["primary_key_naming"]
|
||||||
|
if pkNamingRule.Function != "primary_key_naming" {
|
||||||
|
t.Errorf("primary_key_naming.Function = %q, want \"primary_key_naming\"", pkNamingRule.Function)
|
||||||
|
}
|
||||||
|
|
||||||
|
if pkNamingRule.Pattern != "^id_" {
|
||||||
|
t.Errorf("primary_key_naming.Pattern = %q, want \"^id_\"", pkNamingRule.Pattern)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test datatype rule
|
||||||
|
pkDatatypeRule := config.Rules["primary_key_datatype"]
|
||||||
|
if len(pkDatatypeRule.AllowedTypes) == 0 {
|
||||||
|
t.Error("primary_key_datatype has no allowed types")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test length rule
|
||||||
|
tableLengthRule := config.Rules["table_name_length"]
|
||||||
|
if tableLengthRule.MaxLength != 64 {
|
||||||
|
t.Errorf("table_name_length.MaxLength = %d, want 64", tableLengthRule.MaxLength)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test reserved keywords rule
|
||||||
|
reservedRule := config.Rules["reserved_keywords"]
|
||||||
|
if !reservedRule.CheckTables {
|
||||||
|
t.Error("reserved_keywords.CheckTables should be true")
|
||||||
|
}
|
||||||
|
if !reservedRule.CheckColumns {
|
||||||
|
t.Error("reserved_keywords.CheckColumns should be true")
|
||||||
|
}
|
||||||
|
}
|
||||||
837
pkg/inspector/validators_test.go
Normal file
837
pkg/inspector/validators_test.go
Normal file
@@ -0,0 +1,837 @@
|
|||||||
|
package inspector
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"git.warky.dev/wdevs/relspecgo/pkg/models"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Helper function to create test database
|
||||||
|
func createTestDatabase() *models.Database {
|
||||||
|
return &models.Database{
|
||||||
|
Name: "testdb",
|
||||||
|
Schemas: []*models.Schema{
|
||||||
|
{
|
||||||
|
Name: "public",
|
||||||
|
Tables: []*models.Table{
|
||||||
|
{
|
||||||
|
Name: "users",
|
||||||
|
Columns: map[string]*models.Column{
|
||||||
|
"id": {
|
||||||
|
Name: "id",
|
||||||
|
Type: "bigserial",
|
||||||
|
IsPrimaryKey: true,
|
||||||
|
AutoIncrement: true,
|
||||||
|
},
|
||||||
|
"username": {
|
||||||
|
Name: "username",
|
||||||
|
Type: "varchar(50)",
|
||||||
|
NotNull: true,
|
||||||
|
IsPrimaryKey: false,
|
||||||
|
},
|
||||||
|
"rid_organization": {
|
||||||
|
Name: "rid_organization",
|
||||||
|
Type: "bigint",
|
||||||
|
NotNull: true,
|
||||||
|
IsPrimaryKey: false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Constraints: map[string]*models.Constraint{
|
||||||
|
"fk_users_organization": {
|
||||||
|
Name: "fk_users_organization",
|
||||||
|
Type: models.ForeignKeyConstraint,
|
||||||
|
Columns: []string{"rid_organization"},
|
||||||
|
ReferencedTable: "organizations",
|
||||||
|
ReferencedSchema: "public",
|
||||||
|
ReferencedColumns: []string{"id"},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Indexes: map[string]*models.Index{
|
||||||
|
"idx_rid_organization": {
|
||||||
|
Name: "idx_rid_organization",
|
||||||
|
Columns: []string{"rid_organization"},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name: "organizations",
|
||||||
|
Columns: map[string]*models.Column{
|
||||||
|
"id": {
|
||||||
|
Name: "id",
|
||||||
|
Type: "bigserial",
|
||||||
|
IsPrimaryKey: true,
|
||||||
|
AutoIncrement: true,
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
Name: "name",
|
||||||
|
Type: "varchar(100)",
|
||||||
|
NotNull: true,
|
||||||
|
IsPrimaryKey: false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestValidatePrimaryKeyNaming(t *testing.T) {
|
||||||
|
db := createTestDatabase()
|
||||||
|
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
rule Rule
|
||||||
|
wantLen int
|
||||||
|
wantPass bool
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "matching pattern id",
|
||||||
|
rule: Rule{
|
||||||
|
Pattern: "^id$",
|
||||||
|
Message: "Primary key should be 'id'",
|
||||||
|
},
|
||||||
|
wantLen: 2,
|
||||||
|
wantPass: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "non-matching pattern id_",
|
||||||
|
rule: Rule{
|
||||||
|
Pattern: "^id_",
|
||||||
|
Message: "Primary key should start with 'id_'",
|
||||||
|
},
|
||||||
|
wantLen: 2,
|
||||||
|
wantPass: false,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
results := validatePrimaryKeyNaming(db, tt.rule, "test_rule")
|
||||||
|
if len(results) != tt.wantLen {
|
||||||
|
t.Errorf("validatePrimaryKeyNaming() returned %d results, want %d", len(results), tt.wantLen)
|
||||||
|
}
|
||||||
|
if len(results) > 0 && results[0].Passed != tt.wantPass {
|
||||||
|
t.Errorf("validatePrimaryKeyNaming() passed=%v, want %v", results[0].Passed, tt.wantPass)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestValidatePrimaryKeyDatatype(t *testing.T) {
|
||||||
|
db := createTestDatabase()
|
||||||
|
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
rule Rule
|
||||||
|
wantLen int
|
||||||
|
wantPass bool
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "allowed type bigserial",
|
||||||
|
rule: Rule{
|
||||||
|
AllowedTypes: []string{"bigserial", "bigint", "int"},
|
||||||
|
Message: "Primary key should use integer types",
|
||||||
|
},
|
||||||
|
wantLen: 2,
|
||||||
|
wantPass: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "disallowed type",
|
||||||
|
rule: Rule{
|
||||||
|
AllowedTypes: []string{"uuid"},
|
||||||
|
Message: "Primary key should use UUID",
|
||||||
|
},
|
||||||
|
wantLen: 2,
|
||||||
|
wantPass: false,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
results := validatePrimaryKeyDatatype(db, tt.rule, "test_rule")
|
||||||
|
if len(results) != tt.wantLen {
|
||||||
|
t.Errorf("validatePrimaryKeyDatatype() returned %d results, want %d", len(results), tt.wantLen)
|
||||||
|
}
|
||||||
|
if len(results) > 0 && results[0].Passed != tt.wantPass {
|
||||||
|
t.Errorf("validatePrimaryKeyDatatype() passed=%v, want %v", results[0].Passed, tt.wantPass)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestValidatePrimaryKeyAutoIncrement(t *testing.T) {
|
||||||
|
db := createTestDatabase()
|
||||||
|
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
rule Rule
|
||||||
|
wantLen int
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "require auto increment",
|
||||||
|
rule: Rule{
|
||||||
|
RequireAutoIncrement: true,
|
||||||
|
Message: "Primary key should have auto-increment",
|
||||||
|
},
|
||||||
|
wantLen: 0, // No violations - all PKs have auto-increment
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "disallow auto increment",
|
||||||
|
rule: Rule{
|
||||||
|
RequireAutoIncrement: false,
|
||||||
|
Message: "Primary key should not have auto-increment",
|
||||||
|
},
|
||||||
|
wantLen: 2, // 2 violations - both PKs have auto-increment
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
results := validatePrimaryKeyAutoIncrement(db, tt.rule, "test_rule")
|
||||||
|
if len(results) != tt.wantLen {
|
||||||
|
t.Errorf("validatePrimaryKeyAutoIncrement() returned %d results, want %d", len(results), tt.wantLen)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestValidateForeignKeyColumnNaming(t *testing.T) {
|
||||||
|
db := createTestDatabase()
|
||||||
|
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
rule Rule
|
||||||
|
wantLen int
|
||||||
|
wantPass bool
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "matching pattern rid_",
|
||||||
|
rule: Rule{
|
||||||
|
Pattern: "^rid_",
|
||||||
|
Message: "Foreign key columns should start with 'rid_'",
|
||||||
|
},
|
||||||
|
wantLen: 1,
|
||||||
|
wantPass: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "non-matching pattern fk_",
|
||||||
|
rule: Rule{
|
||||||
|
Pattern: "^fk_",
|
||||||
|
Message: "Foreign key columns should start with 'fk_'",
|
||||||
|
},
|
||||||
|
wantLen: 1,
|
||||||
|
wantPass: false,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
results := validateForeignKeyColumnNaming(db, tt.rule, "test_rule")
|
||||||
|
if len(results) != tt.wantLen {
|
||||||
|
t.Errorf("validateForeignKeyColumnNaming() returned %d results, want %d", len(results), tt.wantLen)
|
||||||
|
}
|
||||||
|
if len(results) > 0 && results[0].Passed != tt.wantPass {
|
||||||
|
t.Errorf("validateForeignKeyColumnNaming() passed=%v, want %v", results[0].Passed, tt.wantPass)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestValidateForeignKeyConstraintNaming(t *testing.T) {
|
||||||
|
db := createTestDatabase()
|
||||||
|
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
rule Rule
|
||||||
|
wantLen int
|
||||||
|
wantPass bool
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "matching pattern fk_",
|
||||||
|
rule: Rule{
|
||||||
|
Pattern: "^fk_",
|
||||||
|
Message: "Foreign key constraints should start with 'fk_'",
|
||||||
|
},
|
||||||
|
wantLen: 1,
|
||||||
|
wantPass: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "non-matching pattern FK_",
|
||||||
|
rule: Rule{
|
||||||
|
Pattern: "^FK_",
|
||||||
|
Message: "Foreign key constraints should start with 'FK_'",
|
||||||
|
},
|
||||||
|
wantLen: 1,
|
||||||
|
wantPass: false,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
results := validateForeignKeyConstraintNaming(db, tt.rule, "test_rule")
|
||||||
|
if len(results) != tt.wantLen {
|
||||||
|
t.Errorf("validateForeignKeyConstraintNaming() returned %d results, want %d", len(results), tt.wantLen)
|
||||||
|
}
|
||||||
|
if len(results) > 0 && results[0].Passed != tt.wantPass {
|
||||||
|
t.Errorf("validateForeignKeyConstraintNaming() passed=%v, want %v", results[0].Passed, tt.wantPass)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestValidateForeignKeyIndex(t *testing.T) {
|
||||||
|
db := createTestDatabase()
|
||||||
|
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
rule Rule
|
||||||
|
wantLen int
|
||||||
|
wantPass bool
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "require index with index present",
|
||||||
|
rule: Rule{
|
||||||
|
RequireIndex: true,
|
||||||
|
Message: "Foreign key columns should have indexes",
|
||||||
|
},
|
||||||
|
wantLen: 1,
|
||||||
|
wantPass: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "no requirement",
|
||||||
|
rule: Rule{
|
||||||
|
RequireIndex: false,
|
||||||
|
Message: "Foreign key index check disabled",
|
||||||
|
},
|
||||||
|
wantLen: 0,
|
||||||
|
wantPass: true,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
results := validateForeignKeyIndex(db, tt.rule, "test_rule")
|
||||||
|
if len(results) != tt.wantLen {
|
||||||
|
t.Errorf("validateForeignKeyIndex() returned %d results, want %d", len(results), tt.wantLen)
|
||||||
|
}
|
||||||
|
if len(results) > 0 && results[0].Passed != tt.wantPass {
|
||||||
|
t.Errorf("validateForeignKeyIndex() passed=%v, want %v", results[0].Passed, tt.wantPass)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestValidateTableNamingCase(t *testing.T) {
|
||||||
|
db := createTestDatabase()
|
||||||
|
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
rule Rule
|
||||||
|
wantLen int
|
||||||
|
wantPass bool
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "lowercase snake_case pattern",
|
||||||
|
rule: Rule{
|
||||||
|
Pattern: "^[a-z][a-z0-9_]*$",
|
||||||
|
Case: "lowercase",
|
||||||
|
Message: "Table names should be lowercase snake_case",
|
||||||
|
},
|
||||||
|
wantLen: 2,
|
||||||
|
wantPass: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "uppercase pattern",
|
||||||
|
rule: Rule{
|
||||||
|
Pattern: "^[A-Z][A-Z0-9_]*$",
|
||||||
|
Case: "uppercase",
|
||||||
|
Message: "Table names should be uppercase",
|
||||||
|
},
|
||||||
|
wantLen: 2,
|
||||||
|
wantPass: false,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
results := validateTableNamingCase(db, tt.rule, "test_rule")
|
||||||
|
if len(results) != tt.wantLen {
|
||||||
|
t.Errorf("validateTableNamingCase() returned %d results, want %d", len(results), tt.wantLen)
|
||||||
|
}
|
||||||
|
if len(results) > 0 && results[0].Passed != tt.wantPass {
|
||||||
|
t.Errorf("validateTableNamingCase() passed=%v, want %v", results[0].Passed, tt.wantPass)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestValidateColumnNamingCase(t *testing.T) {
|
||||||
|
db := createTestDatabase()
|
||||||
|
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
rule Rule
|
||||||
|
wantLen int
|
||||||
|
wantPass bool
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "lowercase snake_case pattern",
|
||||||
|
rule: Rule{
|
||||||
|
Pattern: "^[a-z][a-z0-9_]*$",
|
||||||
|
Case: "lowercase",
|
||||||
|
Message: "Column names should be lowercase snake_case",
|
||||||
|
},
|
||||||
|
wantLen: 5, // 5 total columns across both tables
|
||||||
|
wantPass: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "camelCase pattern",
|
||||||
|
rule: Rule{
|
||||||
|
Pattern: "^[a-z][a-zA-Z0-9]*$",
|
||||||
|
Case: "camelCase",
|
||||||
|
Message: "Column names should be camelCase",
|
||||||
|
},
|
||||||
|
wantLen: 5,
|
||||||
|
wantPass: false, // rid_organization has underscore
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
results := validateColumnNamingCase(db, tt.rule, "test_rule")
|
||||||
|
if len(results) != tt.wantLen {
|
||||||
|
t.Errorf("validateColumnNamingCase() returned %d results, want %d", len(results), tt.wantLen)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestValidateTableNameLength(t *testing.T) {
|
||||||
|
db := createTestDatabase()
|
||||||
|
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
rule Rule
|
||||||
|
wantLen int
|
||||||
|
wantPass bool
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "max length 64",
|
||||||
|
rule: Rule{
|
||||||
|
MaxLength: 64,
|
||||||
|
Message: "Table name too long",
|
||||||
|
},
|
||||||
|
wantLen: 2,
|
||||||
|
wantPass: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "max length 5",
|
||||||
|
rule: Rule{
|
||||||
|
MaxLength: 5,
|
||||||
|
Message: "Table name too long",
|
||||||
|
},
|
||||||
|
wantLen: 2,
|
||||||
|
wantPass: false, // "users" is 5 chars (passes), "organizations" is 13 (fails)
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
results := validateTableNameLength(db, tt.rule, "test_rule")
|
||||||
|
if len(results) != tt.wantLen {
|
||||||
|
t.Errorf("validateTableNameLength() returned %d results, want %d", len(results), tt.wantLen)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestValidateColumnNameLength(t *testing.T) {
|
||||||
|
db := createTestDatabase()
|
||||||
|
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
rule Rule
|
||||||
|
wantLen int
|
||||||
|
wantPass bool
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "max length 64",
|
||||||
|
rule: Rule{
|
||||||
|
MaxLength: 64,
|
||||||
|
Message: "Column name too long",
|
||||||
|
},
|
||||||
|
wantLen: 5,
|
||||||
|
wantPass: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "max length 5",
|
||||||
|
rule: Rule{
|
||||||
|
MaxLength: 5,
|
||||||
|
Message: "Column name too long",
|
||||||
|
},
|
||||||
|
wantLen: 5,
|
||||||
|
wantPass: false, // Some columns exceed 5 chars
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
results := validateColumnNameLength(db, tt.rule, "test_rule")
|
||||||
|
if len(results) != tt.wantLen {
|
||||||
|
t.Errorf("validateColumnNameLength() returned %d results, want %d", len(results), tt.wantLen)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestValidateReservedKeywords(t *testing.T) {
|
||||||
|
// Create a database with reserved keywords
|
||||||
|
db := &models.Database{
|
||||||
|
Name: "testdb",
|
||||||
|
Schemas: []*models.Schema{
|
||||||
|
{
|
||||||
|
Name: "public",
|
||||||
|
Tables: []*models.Table{
|
||||||
|
{
|
||||||
|
Name: "user", // "user" is a reserved keyword
|
||||||
|
Columns: map[string]*models.Column{
|
||||||
|
"id": {
|
||||||
|
Name: "id",
|
||||||
|
Type: "bigint",
|
||||||
|
IsPrimaryKey: true,
|
||||||
|
},
|
||||||
|
"select": { // "select" is a reserved keyword
|
||||||
|
Name: "select",
|
||||||
|
Type: "varchar(50)",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
rule Rule
|
||||||
|
wantLen int
|
||||||
|
checkPasses bool
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "check tables only",
|
||||||
|
rule: Rule{
|
||||||
|
CheckTables: true,
|
||||||
|
CheckColumns: false,
|
||||||
|
Message: "Reserved keyword used",
|
||||||
|
},
|
||||||
|
wantLen: 1, // "user" table
|
||||||
|
checkPasses: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "check columns only",
|
||||||
|
rule: Rule{
|
||||||
|
CheckTables: false,
|
||||||
|
CheckColumns: true,
|
||||||
|
Message: "Reserved keyword used",
|
||||||
|
},
|
||||||
|
wantLen: 2, // "id", "select" columns (id passes, select fails)
|
||||||
|
checkPasses: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "check both",
|
||||||
|
rule: Rule{
|
||||||
|
CheckTables: true,
|
||||||
|
CheckColumns: true,
|
||||||
|
Message: "Reserved keyword used",
|
||||||
|
},
|
||||||
|
wantLen: 3, // "user" table + "id", "select" columns
|
||||||
|
checkPasses: false,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
results := validateReservedKeywords(db, tt.rule, "test_rule")
|
||||||
|
if len(results) != tt.wantLen {
|
||||||
|
t.Errorf("validateReservedKeywords() returned %d results, want %d", len(results), tt.wantLen)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestValidateMissingPrimaryKey(t *testing.T) {
|
||||||
|
// Create database with and without primary keys
|
||||||
|
db := &models.Database{
|
||||||
|
Name: "testdb",
|
||||||
|
Schemas: []*models.Schema{
|
||||||
|
{
|
||||||
|
Name: "public",
|
||||||
|
Tables: []*models.Table{
|
||||||
|
{
|
||||||
|
Name: "with_pk",
|
||||||
|
Columns: map[string]*models.Column{
|
||||||
|
"id": {
|
||||||
|
Name: "id",
|
||||||
|
Type: "bigint",
|
||||||
|
IsPrimaryKey: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name: "without_pk",
|
||||||
|
Columns: map[string]*models.Column{
|
||||||
|
"name": {
|
||||||
|
Name: "name",
|
||||||
|
Type: "varchar(50)",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
rule := Rule{
|
||||||
|
Message: "Table missing primary key",
|
||||||
|
}
|
||||||
|
|
||||||
|
results := validateMissingPrimaryKey(db, rule, "test_rule")
|
||||||
|
|
||||||
|
if len(results) != 2 {
|
||||||
|
t.Errorf("validateMissingPrimaryKey() returned %d results, want 2", len(results))
|
||||||
|
}
|
||||||
|
|
||||||
|
// First result should pass (with_pk has PK)
|
||||||
|
if results[0].Passed != true {
|
||||||
|
t.Errorf("validateMissingPrimaryKey() result[0].Passed=%v, want true", results[0].Passed)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Second result should fail (without_pk missing PK)
|
||||||
|
if results[1].Passed != false {
|
||||||
|
t.Errorf("validateMissingPrimaryKey() result[1].Passed=%v, want false", results[1].Passed)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestValidateOrphanedForeignKey(t *testing.T) {
|
||||||
|
// Create database with orphaned FK
|
||||||
|
db := &models.Database{
|
||||||
|
Name: "testdb",
|
||||||
|
Schemas: []*models.Schema{
|
||||||
|
{
|
||||||
|
Name: "public",
|
||||||
|
Tables: []*models.Table{
|
||||||
|
{
|
||||||
|
Name: "users",
|
||||||
|
Columns: map[string]*models.Column{
|
||||||
|
"id": {
|
||||||
|
Name: "id",
|
||||||
|
Type: "bigint",
|
||||||
|
IsPrimaryKey: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Constraints: map[string]*models.Constraint{
|
||||||
|
"fk_nonexistent": {
|
||||||
|
Name: "fk_nonexistent",
|
||||||
|
Type: models.ForeignKeyConstraint,
|
||||||
|
Columns: []string{"rid_organization"},
|
||||||
|
ReferencedTable: "nonexistent_table",
|
||||||
|
ReferencedSchema: "public",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
rule := Rule{
|
||||||
|
Message: "Foreign key references non-existent table",
|
||||||
|
}
|
||||||
|
|
||||||
|
results := validateOrphanedForeignKey(db, rule, "test_rule")
|
||||||
|
|
||||||
|
if len(results) != 1 {
|
||||||
|
t.Errorf("validateOrphanedForeignKey() returned %d results, want 1", len(results))
|
||||||
|
}
|
||||||
|
|
||||||
|
if results[0].Passed != false {
|
||||||
|
t.Errorf("validateOrphanedForeignKey() passed=%v, want false", results[0].Passed)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestValidateCircularDependency(t *testing.T) {
|
||||||
|
// Create database with circular dependency
|
||||||
|
db := &models.Database{
|
||||||
|
Name: "testdb",
|
||||||
|
Schemas: []*models.Schema{
|
||||||
|
{
|
||||||
|
Name: "public",
|
||||||
|
Tables: []*models.Table{
|
||||||
|
{
|
||||||
|
Name: "table_a",
|
||||||
|
Columns: map[string]*models.Column{
|
||||||
|
"id": {Name: "id", Type: "bigint", IsPrimaryKey: true},
|
||||||
|
},
|
||||||
|
Constraints: map[string]*models.Constraint{
|
||||||
|
"fk_to_b": {
|
||||||
|
Name: "fk_to_b",
|
||||||
|
Type: models.ForeignKeyConstraint,
|
||||||
|
ReferencedTable: "table_b",
|
||||||
|
ReferencedSchema: "public",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name: "table_b",
|
||||||
|
Columns: map[string]*models.Column{
|
||||||
|
"id": {Name: "id", Type: "bigint", IsPrimaryKey: true},
|
||||||
|
},
|
||||||
|
Constraints: map[string]*models.Constraint{
|
||||||
|
"fk_to_a": {
|
||||||
|
Name: "fk_to_a",
|
||||||
|
Type: models.ForeignKeyConstraint,
|
||||||
|
ReferencedTable: "table_a",
|
||||||
|
ReferencedSchema: "public",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
rule := Rule{
|
||||||
|
Message: "Circular dependency detected",
|
||||||
|
}
|
||||||
|
|
||||||
|
results := validateCircularDependency(db, rule, "test_rule")
|
||||||
|
|
||||||
|
// Should detect circular dependency in both tables
|
||||||
|
if len(results) == 0 {
|
||||||
|
t.Error("validateCircularDependency() returned 0 results, expected circular dependency detection")
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, result := range results {
|
||||||
|
if result.Passed {
|
||||||
|
t.Error("validateCircularDependency() passed=true, want false for circular dependency")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestNormalizeDataType(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
input string
|
||||||
|
expected string
|
||||||
|
}{
|
||||||
|
{"varchar(50)", "varchar"},
|
||||||
|
{"decimal(10,2)", "decimal"},
|
||||||
|
{"int", "int"},
|
||||||
|
{"BIGINT", "bigint"},
|
||||||
|
{"VARCHAR(255)", "varchar"},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.input, func(t *testing.T) {
|
||||||
|
result := normalizeDataType(tt.input)
|
||||||
|
if result != tt.expected {
|
||||||
|
t.Errorf("normalizeDataType(%q) = %q, want %q", tt.input, result, tt.expected)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestContains(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
slice []string
|
||||||
|
value string
|
||||||
|
expected bool
|
||||||
|
}{
|
||||||
|
{"found exact", []string{"foo", "bar", "baz"}, "bar", true},
|
||||||
|
{"not found", []string{"foo", "bar", "baz"}, "qux", false},
|
||||||
|
{"case insensitive match", []string{"foo", "Bar", "baz"}, "bar", true},
|
||||||
|
{"empty slice", []string{}, "foo", false},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
result := contains(tt.slice, tt.value)
|
||||||
|
if result != tt.expected {
|
||||||
|
t.Errorf("contains(%v, %q) = %v, want %v", tt.slice, tt.value, result, tt.expected)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestHasCycle(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
graph map[string][]string
|
||||||
|
node string
|
||||||
|
expected bool
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "simple cycle",
|
||||||
|
graph: map[string][]string{
|
||||||
|
"A": {"B"},
|
||||||
|
"B": {"C"},
|
||||||
|
"C": {"A"},
|
||||||
|
},
|
||||||
|
node: "A",
|
||||||
|
expected: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "no cycle",
|
||||||
|
graph: map[string][]string{
|
||||||
|
"A": {"B"},
|
||||||
|
"B": {"C"},
|
||||||
|
"C": {},
|
||||||
|
},
|
||||||
|
node: "A",
|
||||||
|
expected: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "self cycle",
|
||||||
|
graph: map[string][]string{
|
||||||
|
"A": {"A"},
|
||||||
|
},
|
||||||
|
node: "A",
|
||||||
|
expected: true,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
visited := make(map[string]bool)
|
||||||
|
recStack := make(map[string]bool)
|
||||||
|
result := hasCycle(tt.node, tt.graph, visited, recStack)
|
||||||
|
if result != tt.expected {
|
||||||
|
t.Errorf("hasCycle() = %v, want %v", result, tt.expected)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestFormatLocation(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
schema string
|
||||||
|
table string
|
||||||
|
column string
|
||||||
|
expected string
|
||||||
|
}{
|
||||||
|
{"public", "users", "id", "public.users.id"},
|
||||||
|
{"public", "users", "", "public.users"},
|
||||||
|
{"public", "", "", "public"},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.expected, func(t *testing.T) {
|
||||||
|
result := formatLocation(tt.schema, tt.table, tt.column)
|
||||||
|
if result != tt.expected {
|
||||||
|
t.Errorf("formatLocation(%q, %q, %q) = %q, want %q",
|
||||||
|
tt.schema, tt.table, tt.column, result, tt.expected)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -12,14 +12,16 @@ import (
|
|||||||
|
|
||||||
// MergeResult represents the result of a merge operation
|
// MergeResult represents the result of a merge operation
|
||||||
type MergeResult struct {
|
type MergeResult struct {
|
||||||
SchemasAdded int
|
SchemasAdded int
|
||||||
TablesAdded int
|
TablesAdded int
|
||||||
ColumnsAdded int
|
ColumnsAdded int
|
||||||
RelationsAdded int
|
ConstraintsAdded int
|
||||||
DomainsAdded int
|
IndexesAdded int
|
||||||
EnumsAdded int
|
RelationsAdded int
|
||||||
ViewsAdded int
|
DomainsAdded int
|
||||||
SequencesAdded int
|
EnumsAdded int
|
||||||
|
ViewsAdded int
|
||||||
|
SequencesAdded int
|
||||||
}
|
}
|
||||||
|
|
||||||
// MergeOptions contains options for merge operations
|
// MergeOptions contains options for merge operations
|
||||||
@@ -120,8 +122,10 @@ func (r *MergeResult) mergeTables(schema *models.Schema, source *models.Schema,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if tgtTable, exists := existingTables[tableName]; exists {
|
if tgtTable, exists := existingTables[tableName]; exists {
|
||||||
// Table exists, merge its columns
|
// Table exists, merge its columns, constraints, and indexes
|
||||||
r.mergeColumns(tgtTable, srcTable)
|
r.mergeColumns(tgtTable, srcTable)
|
||||||
|
r.mergeConstraints(tgtTable, srcTable)
|
||||||
|
r.mergeIndexes(tgtTable, srcTable)
|
||||||
} else {
|
} else {
|
||||||
// Table doesn't exist, add it
|
// Table doesn't exist, add it
|
||||||
newTable := cloneTable(srcTable)
|
newTable := cloneTable(srcTable)
|
||||||
@@ -151,6 +155,52 @@ func (r *MergeResult) mergeColumns(table *models.Table, srcTable *models.Table)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (r *MergeResult) mergeConstraints(table *models.Table, srcTable *models.Table) {
|
||||||
|
// Initialize constraints map if nil
|
||||||
|
if table.Constraints == nil {
|
||||||
|
table.Constraints = make(map[string]*models.Constraint)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create map of existing constraints
|
||||||
|
existingConstraints := make(map[string]*models.Constraint)
|
||||||
|
for constName := range table.Constraints {
|
||||||
|
existingConstraints[constName] = table.Constraints[constName]
|
||||||
|
}
|
||||||
|
|
||||||
|
// Merge constraints
|
||||||
|
for constName, srcConst := range srcTable.Constraints {
|
||||||
|
if _, exists := existingConstraints[constName]; !exists {
|
||||||
|
// Constraint doesn't exist, add it
|
||||||
|
newConst := cloneConstraint(srcConst)
|
||||||
|
table.Constraints[constName] = newConst
|
||||||
|
r.ConstraintsAdded++
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *MergeResult) mergeIndexes(table *models.Table, srcTable *models.Table) {
|
||||||
|
// Initialize indexes map if nil
|
||||||
|
if table.Indexes == nil {
|
||||||
|
table.Indexes = make(map[string]*models.Index)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create map of existing indexes
|
||||||
|
existingIndexes := make(map[string]*models.Index)
|
||||||
|
for idxName := range table.Indexes {
|
||||||
|
existingIndexes[idxName] = table.Indexes[idxName]
|
||||||
|
}
|
||||||
|
|
||||||
|
// Merge indexes
|
||||||
|
for idxName, srcIdx := range srcTable.Indexes {
|
||||||
|
if _, exists := existingIndexes[idxName]; !exists {
|
||||||
|
// Index doesn't exist, add it
|
||||||
|
newIdx := cloneIndex(srcIdx)
|
||||||
|
table.Indexes[idxName] = newIdx
|
||||||
|
r.IndexesAdded++
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (r *MergeResult) mergeViews(schema *models.Schema, source *models.Schema) {
|
func (r *MergeResult) mergeViews(schema *models.Schema, source *models.Schema) {
|
||||||
// Create map of existing views
|
// Create map of existing views
|
||||||
existingViews := make(map[string]*models.View)
|
existingViews := make(map[string]*models.View)
|
||||||
@@ -552,6 +602,8 @@ func GetMergeSummary(result *MergeResult) string {
|
|||||||
fmt.Sprintf("Schemas added: %d", result.SchemasAdded),
|
fmt.Sprintf("Schemas added: %d", result.SchemasAdded),
|
||||||
fmt.Sprintf("Tables added: %d", result.TablesAdded),
|
fmt.Sprintf("Tables added: %d", result.TablesAdded),
|
||||||
fmt.Sprintf("Columns added: %d", result.ColumnsAdded),
|
fmt.Sprintf("Columns added: %d", result.ColumnsAdded),
|
||||||
|
fmt.Sprintf("Constraints added: %d", result.ConstraintsAdded),
|
||||||
|
fmt.Sprintf("Indexes added: %d", result.IndexesAdded),
|
||||||
fmt.Sprintf("Views added: %d", result.ViewsAdded),
|
fmt.Sprintf("Views added: %d", result.ViewsAdded),
|
||||||
fmt.Sprintf("Sequences added: %d", result.SequencesAdded),
|
fmt.Sprintf("Sequences added: %d", result.SequencesAdded),
|
||||||
fmt.Sprintf("Enums added: %d", result.EnumsAdded),
|
fmt.Sprintf("Enums added: %d", result.EnumsAdded),
|
||||||
@@ -560,6 +612,7 @@ func GetMergeSummary(result *MergeResult) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
totalAdded := result.SchemasAdded + result.TablesAdded + result.ColumnsAdded +
|
totalAdded := result.SchemasAdded + result.TablesAdded + result.ColumnsAdded +
|
||||||
|
result.ConstraintsAdded + result.IndexesAdded +
|
||||||
result.ViewsAdded + result.SequencesAdded + result.EnumsAdded +
|
result.ViewsAdded + result.SequencesAdded + result.EnumsAdded +
|
||||||
result.RelationsAdded + result.DomainsAdded
|
result.RelationsAdded + result.DomainsAdded
|
||||||
|
|
||||||
|
|||||||
617
pkg/merge/merge_test.go
Normal file
617
pkg/merge/merge_test.go
Normal file
@@ -0,0 +1,617 @@
|
|||||||
|
package merge
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"git.warky.dev/wdevs/relspecgo/pkg/models"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestMergeDatabases_NilInputs(t *testing.T) {
|
||||||
|
result := MergeDatabases(nil, nil, nil)
|
||||||
|
if result == nil {
|
||||||
|
t.Fatal("Expected non-nil result")
|
||||||
|
}
|
||||||
|
if result.SchemasAdded != 0 {
|
||||||
|
t.Errorf("Expected 0 schemas added, got %d", result.SchemasAdded)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestMergeDatabases_NewSchema(t *testing.T) {
|
||||||
|
target := &models.Database{
|
||||||
|
Schemas: []*models.Schema{
|
||||||
|
{Name: "public"},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
source := &models.Database{
|
||||||
|
Schemas: []*models.Schema{
|
||||||
|
{Name: "auth"},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
result := MergeDatabases(target, source, nil)
|
||||||
|
if result.SchemasAdded != 1 {
|
||||||
|
t.Errorf("Expected 1 schema added, got %d", result.SchemasAdded)
|
||||||
|
}
|
||||||
|
if len(target.Schemas) != 2 {
|
||||||
|
t.Errorf("Expected 2 schemas in target, got %d", len(target.Schemas))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestMergeDatabases_ExistingSchema(t *testing.T) {
|
||||||
|
target := &models.Database{
|
||||||
|
Schemas: []*models.Schema{
|
||||||
|
{Name: "public"},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
source := &models.Database{
|
||||||
|
Schemas: []*models.Schema{
|
||||||
|
{Name: "public"},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
result := MergeDatabases(target, source, nil)
|
||||||
|
if result.SchemasAdded != 0 {
|
||||||
|
t.Errorf("Expected 0 schemas added, got %d", result.SchemasAdded)
|
||||||
|
}
|
||||||
|
if len(target.Schemas) != 1 {
|
||||||
|
t.Errorf("Expected 1 schema in target, got %d", len(target.Schemas))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestMergeTables_NewTable(t *testing.T) {
|
||||||
|
target := &models.Database{
|
||||||
|
Schemas: []*models.Schema{
|
||||||
|
{
|
||||||
|
Name: "public",
|
||||||
|
Tables: []*models.Table{
|
||||||
|
{
|
||||||
|
Name: "users",
|
||||||
|
Schema: "public",
|
||||||
|
Columns: map[string]*models.Column{},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
source := &models.Database{
|
||||||
|
Schemas: []*models.Schema{
|
||||||
|
{
|
||||||
|
Name: "public",
|
||||||
|
Tables: []*models.Table{
|
||||||
|
{
|
||||||
|
Name: "posts",
|
||||||
|
Schema: "public",
|
||||||
|
Columns: map[string]*models.Column{},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
result := MergeDatabases(target, source, nil)
|
||||||
|
if result.TablesAdded != 1 {
|
||||||
|
t.Errorf("Expected 1 table added, got %d", result.TablesAdded)
|
||||||
|
}
|
||||||
|
if len(target.Schemas[0].Tables) != 2 {
|
||||||
|
t.Errorf("Expected 2 tables in target schema, got %d", len(target.Schemas[0].Tables))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestMergeColumns_NewColumn(t *testing.T) {
|
||||||
|
target := &models.Database{
|
||||||
|
Schemas: []*models.Schema{
|
||||||
|
{
|
||||||
|
Name: "public",
|
||||||
|
Tables: []*models.Table{
|
||||||
|
{
|
||||||
|
Name: "users",
|
||||||
|
Schema: "public",
|
||||||
|
Columns: map[string]*models.Column{
|
||||||
|
"id": {Name: "id", Type: "int"},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
source := &models.Database{
|
||||||
|
Schemas: []*models.Schema{
|
||||||
|
{
|
||||||
|
Name: "public",
|
||||||
|
Tables: []*models.Table{
|
||||||
|
{
|
||||||
|
Name: "users",
|
||||||
|
Schema: "public",
|
||||||
|
Columns: map[string]*models.Column{
|
||||||
|
"email": {Name: "email", Type: "varchar"},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
result := MergeDatabases(target, source, nil)
|
||||||
|
if result.ColumnsAdded != 1 {
|
||||||
|
t.Errorf("Expected 1 column added, got %d", result.ColumnsAdded)
|
||||||
|
}
|
||||||
|
if len(target.Schemas[0].Tables[0].Columns) != 2 {
|
||||||
|
t.Errorf("Expected 2 columns in target table, got %d", len(target.Schemas[0].Tables[0].Columns))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestMergeConstraints_NewConstraint(t *testing.T) {
|
||||||
|
target := &models.Database{
|
||||||
|
Schemas: []*models.Schema{
|
||||||
|
{
|
||||||
|
Name: "public",
|
||||||
|
Tables: []*models.Table{
|
||||||
|
{
|
||||||
|
Name: "users",
|
||||||
|
Schema: "public",
|
||||||
|
Columns: map[string]*models.Column{},
|
||||||
|
Constraints: map[string]*models.Constraint{},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
source := &models.Database{
|
||||||
|
Schemas: []*models.Schema{
|
||||||
|
{
|
||||||
|
Name: "public",
|
||||||
|
Tables: []*models.Table{
|
||||||
|
{
|
||||||
|
Name: "users",
|
||||||
|
Schema: "public",
|
||||||
|
Columns: map[string]*models.Column{},
|
||||||
|
Constraints: map[string]*models.Constraint{
|
||||||
|
"ukey_users_email": {
|
||||||
|
Type: models.UniqueConstraint,
|
||||||
|
Columns: []string{"email"},
|
||||||
|
Name: "ukey_users_email",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
result := MergeDatabases(target, source, nil)
|
||||||
|
if result.ConstraintsAdded != 1 {
|
||||||
|
t.Errorf("Expected 1 constraint added, got %d", result.ConstraintsAdded)
|
||||||
|
}
|
||||||
|
if len(target.Schemas[0].Tables[0].Constraints) != 1 {
|
||||||
|
t.Errorf("Expected 1 constraint in target table, got %d", len(target.Schemas[0].Tables[0].Constraints))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestMergeConstraints_NilConstraintsMap(t *testing.T) {
|
||||||
|
target := &models.Database{
|
||||||
|
Schemas: []*models.Schema{
|
||||||
|
{
|
||||||
|
Name: "public",
|
||||||
|
Tables: []*models.Table{
|
||||||
|
{
|
||||||
|
Name: "users",
|
||||||
|
Schema: "public",
|
||||||
|
Columns: map[string]*models.Column{},
|
||||||
|
Constraints: nil, // Nil map
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
source := &models.Database{
|
||||||
|
Schemas: []*models.Schema{
|
||||||
|
{
|
||||||
|
Name: "public",
|
||||||
|
Tables: []*models.Table{
|
||||||
|
{
|
||||||
|
Name: "users",
|
||||||
|
Schema: "public",
|
||||||
|
Columns: map[string]*models.Column{},
|
||||||
|
Constraints: map[string]*models.Constraint{
|
||||||
|
"ukey_users_email": {
|
||||||
|
Type: models.UniqueConstraint,
|
||||||
|
Columns: []string{"email"},
|
||||||
|
Name: "ukey_users_email",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
result := MergeDatabases(target, source, nil)
|
||||||
|
if result.ConstraintsAdded != 1 {
|
||||||
|
t.Errorf("Expected 1 constraint added, got %d", result.ConstraintsAdded)
|
||||||
|
}
|
||||||
|
if target.Schemas[0].Tables[0].Constraints == nil {
|
||||||
|
t.Error("Expected constraints map to be initialized")
|
||||||
|
}
|
||||||
|
if len(target.Schemas[0].Tables[0].Constraints) != 1 {
|
||||||
|
t.Errorf("Expected 1 constraint in target table, got %d", len(target.Schemas[0].Tables[0].Constraints))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestMergeIndexes_NewIndex(t *testing.T) {
|
||||||
|
target := &models.Database{
|
||||||
|
Schemas: []*models.Schema{
|
||||||
|
{
|
||||||
|
Name: "public",
|
||||||
|
Tables: []*models.Table{
|
||||||
|
{
|
||||||
|
Name: "users",
|
||||||
|
Schema: "public",
|
||||||
|
Columns: map[string]*models.Column{},
|
||||||
|
Indexes: map[string]*models.Index{},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
source := &models.Database{
|
||||||
|
Schemas: []*models.Schema{
|
||||||
|
{
|
||||||
|
Name: "public",
|
||||||
|
Tables: []*models.Table{
|
||||||
|
{
|
||||||
|
Name: "users",
|
||||||
|
Schema: "public",
|
||||||
|
Columns: map[string]*models.Column{},
|
||||||
|
Indexes: map[string]*models.Index{
|
||||||
|
"idx_users_email": {
|
||||||
|
Name: "idx_users_email",
|
||||||
|
Columns: []string{"email"},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
result := MergeDatabases(target, source, nil)
|
||||||
|
if result.IndexesAdded != 1 {
|
||||||
|
t.Errorf("Expected 1 index added, got %d", result.IndexesAdded)
|
||||||
|
}
|
||||||
|
if len(target.Schemas[0].Tables[0].Indexes) != 1 {
|
||||||
|
t.Errorf("Expected 1 index in target table, got %d", len(target.Schemas[0].Tables[0].Indexes))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestMergeIndexes_NilIndexesMap(t *testing.T) {
|
||||||
|
target := &models.Database{
|
||||||
|
Schemas: []*models.Schema{
|
||||||
|
{
|
||||||
|
Name: "public",
|
||||||
|
Tables: []*models.Table{
|
||||||
|
{
|
||||||
|
Name: "users",
|
||||||
|
Schema: "public",
|
||||||
|
Columns: map[string]*models.Column{},
|
||||||
|
Indexes: nil, // Nil map
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
source := &models.Database{
|
||||||
|
Schemas: []*models.Schema{
|
||||||
|
{
|
||||||
|
Name: "public",
|
||||||
|
Tables: []*models.Table{
|
||||||
|
{
|
||||||
|
Name: "users",
|
||||||
|
Schema: "public",
|
||||||
|
Columns: map[string]*models.Column{},
|
||||||
|
Indexes: map[string]*models.Index{
|
||||||
|
"idx_users_email": {
|
||||||
|
Name: "idx_users_email",
|
||||||
|
Columns: []string{"email"},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
result := MergeDatabases(target, source, nil)
|
||||||
|
if result.IndexesAdded != 1 {
|
||||||
|
t.Errorf("Expected 1 index added, got %d", result.IndexesAdded)
|
||||||
|
}
|
||||||
|
if target.Schemas[0].Tables[0].Indexes == nil {
|
||||||
|
t.Error("Expected indexes map to be initialized")
|
||||||
|
}
|
||||||
|
if len(target.Schemas[0].Tables[0].Indexes) != 1 {
|
||||||
|
t.Errorf("Expected 1 index in target table, got %d", len(target.Schemas[0].Tables[0].Indexes))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestMergeOptions_SkipTableNames(t *testing.T) {
|
||||||
|
target := &models.Database{
|
||||||
|
Schemas: []*models.Schema{
|
||||||
|
{
|
||||||
|
Name: "public",
|
||||||
|
Tables: []*models.Table{
|
||||||
|
{
|
||||||
|
Name: "users",
|
||||||
|
Schema: "public",
|
||||||
|
Columns: map[string]*models.Column{},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
source := &models.Database{
|
||||||
|
Schemas: []*models.Schema{
|
||||||
|
{
|
||||||
|
Name: "public",
|
||||||
|
Tables: []*models.Table{
|
||||||
|
{
|
||||||
|
Name: "migrations",
|
||||||
|
Schema: "public",
|
||||||
|
Columns: map[string]*models.Column{},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
opts := &MergeOptions{
|
||||||
|
SkipTableNames: map[string]bool{
|
||||||
|
"migrations": true,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
result := MergeDatabases(target, source, opts)
|
||||||
|
if result.TablesAdded != 0 {
|
||||||
|
t.Errorf("Expected 0 tables added (skipped), got %d", result.TablesAdded)
|
||||||
|
}
|
||||||
|
if len(target.Schemas[0].Tables) != 1 {
|
||||||
|
t.Errorf("Expected 1 table in target schema, got %d", len(target.Schemas[0].Tables))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestMergeViews_NewView(t *testing.T) {
|
||||||
|
target := &models.Database{
|
||||||
|
Schemas: []*models.Schema{
|
||||||
|
{
|
||||||
|
Name: "public",
|
||||||
|
Views: []*models.View{},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
source := &models.Database{
|
||||||
|
Schemas: []*models.Schema{
|
||||||
|
{
|
||||||
|
Name: "public",
|
||||||
|
Views: []*models.View{
|
||||||
|
{
|
||||||
|
Name: "user_summary",
|
||||||
|
Schema: "public",
|
||||||
|
Definition: "SELECT * FROM users",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
result := MergeDatabases(target, source, nil)
|
||||||
|
if result.ViewsAdded != 1 {
|
||||||
|
t.Errorf("Expected 1 view added, got %d", result.ViewsAdded)
|
||||||
|
}
|
||||||
|
if len(target.Schemas[0].Views) != 1 {
|
||||||
|
t.Errorf("Expected 1 view in target schema, got %d", len(target.Schemas[0].Views))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestMergeEnums_NewEnum(t *testing.T) {
|
||||||
|
target := &models.Database{
|
||||||
|
Schemas: []*models.Schema{
|
||||||
|
{
|
||||||
|
Name: "public",
|
||||||
|
Enums: []*models.Enum{},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
source := &models.Database{
|
||||||
|
Schemas: []*models.Schema{
|
||||||
|
{
|
||||||
|
Name: "public",
|
||||||
|
Enums: []*models.Enum{
|
||||||
|
{
|
||||||
|
Name: "user_role",
|
||||||
|
Schema: "public",
|
||||||
|
Values: []string{"admin", "user"},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
result := MergeDatabases(target, source, nil)
|
||||||
|
if result.EnumsAdded != 1 {
|
||||||
|
t.Errorf("Expected 1 enum added, got %d", result.EnumsAdded)
|
||||||
|
}
|
||||||
|
if len(target.Schemas[0].Enums) != 1 {
|
||||||
|
t.Errorf("Expected 1 enum in target schema, got %d", len(target.Schemas[0].Enums))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestMergeDomains_NewDomain(t *testing.T) {
|
||||||
|
target := &models.Database{
|
||||||
|
Domains: []*models.Domain{},
|
||||||
|
}
|
||||||
|
source := &models.Database{
|
||||||
|
Domains: []*models.Domain{
|
||||||
|
{
|
||||||
|
Name: "auth",
|
||||||
|
Description: "Authentication domain",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
result := MergeDatabases(target, source, nil)
|
||||||
|
if result.DomainsAdded != 1 {
|
||||||
|
t.Errorf("Expected 1 domain added, got %d", result.DomainsAdded)
|
||||||
|
}
|
||||||
|
if len(target.Domains) != 1 {
|
||||||
|
t.Errorf("Expected 1 domain in target, got %d", len(target.Domains))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestMergeRelations_NewRelation(t *testing.T) {
|
||||||
|
target := &models.Database{
|
||||||
|
Schemas: []*models.Schema{
|
||||||
|
{
|
||||||
|
Name: "public",
|
||||||
|
Relations: []*models.Relationship{},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
source := &models.Database{
|
||||||
|
Schemas: []*models.Schema{
|
||||||
|
{
|
||||||
|
Name: "public",
|
||||||
|
Relations: []*models.Relationship{
|
||||||
|
{
|
||||||
|
Name: "fk_posts_user",
|
||||||
|
Type: models.OneToMany,
|
||||||
|
FromTable: "posts",
|
||||||
|
FromColumns: []string{"user_id"},
|
||||||
|
ToTable: "users",
|
||||||
|
ToColumns: []string{"id"},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
result := MergeDatabases(target, source, nil)
|
||||||
|
if result.RelationsAdded != 1 {
|
||||||
|
t.Errorf("Expected 1 relation added, got %d", result.RelationsAdded)
|
||||||
|
}
|
||||||
|
if len(target.Schemas[0].Relations) != 1 {
|
||||||
|
t.Errorf("Expected 1 relation in target schema, got %d", len(target.Schemas[0].Relations))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestGetMergeSummary(t *testing.T) {
|
||||||
|
result := &MergeResult{
|
||||||
|
SchemasAdded: 1,
|
||||||
|
TablesAdded: 2,
|
||||||
|
ColumnsAdded: 5,
|
||||||
|
ConstraintsAdded: 3,
|
||||||
|
IndexesAdded: 2,
|
||||||
|
ViewsAdded: 1,
|
||||||
|
}
|
||||||
|
|
||||||
|
summary := GetMergeSummary(result)
|
||||||
|
if summary == "" {
|
||||||
|
t.Error("Expected non-empty summary")
|
||||||
|
}
|
||||||
|
if len(summary) < 50 {
|
||||||
|
t.Errorf("Summary seems too short: %s", summary)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestGetMergeSummary_Nil(t *testing.T) {
|
||||||
|
summary := GetMergeSummary(nil)
|
||||||
|
if summary == "" {
|
||||||
|
t.Error("Expected non-empty summary for nil result")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestComplexMerge(t *testing.T) {
|
||||||
|
// Target with existing structure
|
||||||
|
target := &models.Database{
|
||||||
|
Schemas: []*models.Schema{
|
||||||
|
{
|
||||||
|
Name: "public",
|
||||||
|
Tables: []*models.Table{
|
||||||
|
{
|
||||||
|
Name: "users",
|
||||||
|
Schema: "public",
|
||||||
|
Columns: map[string]*models.Column{
|
||||||
|
"id": {Name: "id", Type: "int"},
|
||||||
|
},
|
||||||
|
Constraints: map[string]*models.Constraint{},
|
||||||
|
Indexes: map[string]*models.Index{},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
// Source with new columns, constraints, and indexes
|
||||||
|
source := &models.Database{
|
||||||
|
Schemas: []*models.Schema{
|
||||||
|
{
|
||||||
|
Name: "public",
|
||||||
|
Tables: []*models.Table{
|
||||||
|
{
|
||||||
|
Name: "users",
|
||||||
|
Schema: "public",
|
||||||
|
Columns: map[string]*models.Column{
|
||||||
|
"email": {Name: "email", Type: "varchar"},
|
||||||
|
"guid": {Name: "guid", Type: "uuid"},
|
||||||
|
},
|
||||||
|
Constraints: map[string]*models.Constraint{
|
||||||
|
"ukey_users_email": {
|
||||||
|
Type: models.UniqueConstraint,
|
||||||
|
Columns: []string{"email"},
|
||||||
|
Name: "ukey_users_email",
|
||||||
|
},
|
||||||
|
"ukey_users_guid": {
|
||||||
|
Type: models.UniqueConstraint,
|
||||||
|
Columns: []string{"guid"},
|
||||||
|
Name: "ukey_users_guid",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Indexes: map[string]*models.Index{
|
||||||
|
"idx_users_email": {
|
||||||
|
Name: "idx_users_email",
|
||||||
|
Columns: []string{"email"},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
result := MergeDatabases(target, source, nil)
|
||||||
|
|
||||||
|
// Verify counts
|
||||||
|
if result.ColumnsAdded != 2 {
|
||||||
|
t.Errorf("Expected 2 columns added, got %d", result.ColumnsAdded)
|
||||||
|
}
|
||||||
|
if result.ConstraintsAdded != 2 {
|
||||||
|
t.Errorf("Expected 2 constraints added, got %d", result.ConstraintsAdded)
|
||||||
|
}
|
||||||
|
if result.IndexesAdded != 1 {
|
||||||
|
t.Errorf("Expected 1 index added, got %d", result.IndexesAdded)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Verify target has merged data
|
||||||
|
table := target.Schemas[0].Tables[0]
|
||||||
|
if len(table.Columns) != 3 {
|
||||||
|
t.Errorf("Expected 3 columns in merged table, got %d", len(table.Columns))
|
||||||
|
}
|
||||||
|
if len(table.Constraints) != 2 {
|
||||||
|
t.Errorf("Expected 2 constraints in merged table, got %d", len(table.Constraints))
|
||||||
|
}
|
||||||
|
if len(table.Indexes) != 1 {
|
||||||
|
t.Errorf("Expected 1 index in merged table, got %d", len(table.Indexes))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Verify specific constraint
|
||||||
|
if _, exists := table.Constraints["ukey_users_guid"]; !exists {
|
||||||
|
t.Error("Expected ukey_users_guid constraint to exist")
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,31 +4,31 @@ import "strings"
|
|||||||
|
|
||||||
var GoToStdTypes = map[string]string{
|
var GoToStdTypes = map[string]string{
|
||||||
"bool": "boolean",
|
"bool": "boolean",
|
||||||
"int64": "integer",
|
"int64": "bigint",
|
||||||
"int": "integer",
|
"int": "integer",
|
||||||
"int8": "integer",
|
"int8": "smallint",
|
||||||
"int16": "integer",
|
"int16": "smallint",
|
||||||
"int32": "integer",
|
"int32": "integer",
|
||||||
"uint": "integer",
|
"uint": "integer",
|
||||||
"uint8": "integer",
|
"uint8": "smallint",
|
||||||
"uint16": "integer",
|
"uint16": "smallint",
|
||||||
"uint32": "integer",
|
"uint32": "integer",
|
||||||
"uint64": "integer",
|
"uint64": "bigint",
|
||||||
"uintptr": "integer",
|
"uintptr": "bigint",
|
||||||
"znullint64": "integer",
|
"znullint64": "bigint",
|
||||||
"znullint32": "integer",
|
"znullint32": "integer",
|
||||||
"znullbyte": "integer",
|
"znullbyte": "smallint",
|
||||||
"float64": "double",
|
"float64": "double",
|
||||||
"float32": "double",
|
"float32": "double",
|
||||||
"complex64": "double",
|
"complex64": "double",
|
||||||
"complex128": "double",
|
"complex128": "double",
|
||||||
"customfloat64": "double",
|
"customfloat64": "double",
|
||||||
"string": "string",
|
"string": "text",
|
||||||
"Pointer": "integer",
|
"Pointer": "bigint",
|
||||||
"[]byte": "blob",
|
"[]byte": "blob",
|
||||||
"customdate": "string",
|
"customdate": "date",
|
||||||
"customtime": "string",
|
"customtime": "time",
|
||||||
"customtimestamp": "string",
|
"customtimestamp": "timestamp",
|
||||||
"sqlfloat64": "double",
|
"sqlfloat64": "double",
|
||||||
"sqlfloat16": "double",
|
"sqlfloat16": "double",
|
||||||
"sqluuid": "uuid",
|
"sqluuid": "uuid",
|
||||||
@@ -36,9 +36,9 @@ var GoToStdTypes = map[string]string{
|
|||||||
"sqljson": "json",
|
"sqljson": "json",
|
||||||
"sqlint64": "bigint",
|
"sqlint64": "bigint",
|
||||||
"sqlint32": "integer",
|
"sqlint32": "integer",
|
||||||
"sqlint16": "integer",
|
"sqlint16": "smallint",
|
||||||
"sqlbool": "boolean",
|
"sqlbool": "boolean",
|
||||||
"sqlstring": "string",
|
"sqlstring": "text",
|
||||||
"nullablejsonb": "jsonb",
|
"nullablejsonb": "jsonb",
|
||||||
"nullablejson": "json",
|
"nullablejson": "json",
|
||||||
"nullableuuid": "uuid",
|
"nullableuuid": "uuid",
|
||||||
@@ -67,7 +67,7 @@ var GoToPGSQLTypes = map[string]string{
|
|||||||
"float32": "real",
|
"float32": "real",
|
||||||
"complex64": "double precision",
|
"complex64": "double precision",
|
||||||
"complex128": "double precision",
|
"complex128": "double precision",
|
||||||
"customfloat64": "double precisio",
|
"customfloat64": "double precision",
|
||||||
"string": "text",
|
"string": "text",
|
||||||
"Pointer": "bigint",
|
"Pointer": "bigint",
|
||||||
"[]byte": "bytea",
|
"[]byte": "bytea",
|
||||||
@@ -81,9 +81,9 @@ var GoToPGSQLTypes = map[string]string{
|
|||||||
"sqljson": "json",
|
"sqljson": "json",
|
||||||
"sqlint64": "bigint",
|
"sqlint64": "bigint",
|
||||||
"sqlint32": "integer",
|
"sqlint32": "integer",
|
||||||
"sqlint16": "integer",
|
"sqlint16": "smallint",
|
||||||
"sqlbool": "boolean",
|
"sqlbool": "boolean",
|
||||||
"sqlstring": "string",
|
"sqlstring": "text",
|
||||||
"nullablejsonb": "jsonb",
|
"nullablejsonb": "jsonb",
|
||||||
"nullablejson": "json",
|
"nullablejson": "json",
|
||||||
"nullableuuid": "uuid",
|
"nullableuuid": "uuid",
|
||||||
|
|||||||
339
pkg/pgsql/datatypes_test.go
Normal file
339
pkg/pgsql/datatypes_test.go
Normal file
@@ -0,0 +1,339 @@
|
|||||||
|
package pgsql
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestValidSQLType(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
sqltype string
|
||||||
|
want bool
|
||||||
|
}{
|
||||||
|
// PostgreSQL types
|
||||||
|
{"Valid PGSQL bigint", "bigint", true},
|
||||||
|
{"Valid PGSQL integer", "integer", true},
|
||||||
|
{"Valid PGSQL text", "text", true},
|
||||||
|
{"Valid PGSQL boolean", "boolean", true},
|
||||||
|
{"Valid PGSQL double precision", "double precision", true},
|
||||||
|
{"Valid PGSQL bytea", "bytea", true},
|
||||||
|
{"Valid PGSQL uuid", "uuid", true},
|
||||||
|
{"Valid PGSQL jsonb", "jsonb", true},
|
||||||
|
{"Valid PGSQL json", "json", true},
|
||||||
|
{"Valid PGSQL timestamp", "timestamp", true},
|
||||||
|
{"Valid PGSQL date", "date", true},
|
||||||
|
{"Valid PGSQL time", "time", true},
|
||||||
|
{"Valid PGSQL citext", "citext", true},
|
||||||
|
|
||||||
|
// Standard types
|
||||||
|
{"Valid std double", "double", true},
|
||||||
|
{"Valid std blob", "blob", true},
|
||||||
|
|
||||||
|
// Case insensitive
|
||||||
|
{"Case insensitive BIGINT", "BIGINT", true},
|
||||||
|
{"Case insensitive TeXt", "TeXt", true},
|
||||||
|
{"Case insensitive BoOlEaN", "BoOlEaN", true},
|
||||||
|
|
||||||
|
// Invalid types
|
||||||
|
{"Invalid type", "invalidtype", false},
|
||||||
|
{"Invalid type varchar", "varchar", false},
|
||||||
|
{"Empty string", "", false},
|
||||||
|
{"Random string", "foobar", false},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
got := ValidSQLType(tt.sqltype)
|
||||||
|
if got != tt.want {
|
||||||
|
t.Errorf("ValidSQLType(%q) = %v, want %v", tt.sqltype, got, tt.want)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestGetSQLType(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
anytype string
|
||||||
|
want string
|
||||||
|
}{
|
||||||
|
// Go types to PostgreSQL types
|
||||||
|
{"Go bool to boolean", "bool", "boolean"},
|
||||||
|
{"Go int64 to bigint", "int64", "bigint"},
|
||||||
|
{"Go int to integer", "int", "integer"},
|
||||||
|
{"Go string to text", "string", "text"},
|
||||||
|
{"Go float64 to double precision", "float64", "double precision"},
|
||||||
|
{"Go float32 to real", "float32", "real"},
|
||||||
|
{"Go []byte to bytea", "[]byte", "bytea"},
|
||||||
|
|
||||||
|
// SQL types remain SQL types
|
||||||
|
{"SQL bigint", "bigint", "bigint"},
|
||||||
|
{"SQL integer", "integer", "integer"},
|
||||||
|
{"SQL text", "text", "text"},
|
||||||
|
{"SQL boolean", "boolean", "boolean"},
|
||||||
|
{"SQL uuid", "uuid", "uuid"},
|
||||||
|
{"SQL jsonb", "jsonb", "jsonb"},
|
||||||
|
|
||||||
|
// Case insensitive Go types
|
||||||
|
{"Case insensitive BOOL", "BOOL", "boolean"},
|
||||||
|
{"Case insensitive InT64", "InT64", "bigint"},
|
||||||
|
{"Case insensitive STRING", "STRING", "text"},
|
||||||
|
|
||||||
|
// Case insensitive SQL types
|
||||||
|
{"Case insensitive BIGINT", "BIGINT", "bigint"},
|
||||||
|
{"Case insensitive TEXT", "TEXT", "text"},
|
||||||
|
|
||||||
|
// Custom types
|
||||||
|
{"Custom sqluuid", "sqluuid", "uuid"},
|
||||||
|
{"Custom sqljsonb", "sqljsonb", "jsonb"},
|
||||||
|
{"Custom sqlint64", "sqlint64", "bigint"},
|
||||||
|
|
||||||
|
// Unknown types default to text
|
||||||
|
{"Unknown type varchar", "varchar", "text"},
|
||||||
|
{"Unknown type foobar", "foobar", "text"},
|
||||||
|
{"Empty string", "", "text"},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
got := GetSQLType(tt.anytype)
|
||||||
|
if got != tt.want {
|
||||||
|
t.Errorf("GetSQLType(%q) = %q, want %q", tt.anytype, got, tt.want)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestConvertSQLType(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
anytype string
|
||||||
|
want string
|
||||||
|
}{
|
||||||
|
// Go types to PostgreSQL types
|
||||||
|
{"Go bool to boolean", "bool", "boolean"},
|
||||||
|
{"Go int64 to bigint", "int64", "bigint"},
|
||||||
|
{"Go int to integer", "int", "integer"},
|
||||||
|
{"Go string to text", "string", "text"},
|
||||||
|
{"Go float64 to double precision", "float64", "double precision"},
|
||||||
|
{"Go float32 to real", "float32", "real"},
|
||||||
|
{"Go []byte to bytea", "[]byte", "bytea"},
|
||||||
|
|
||||||
|
// SQL types remain SQL types
|
||||||
|
{"SQL bigint", "bigint", "bigint"},
|
||||||
|
{"SQL integer", "integer", "integer"},
|
||||||
|
{"SQL text", "text", "text"},
|
||||||
|
{"SQL boolean", "boolean", "boolean"},
|
||||||
|
|
||||||
|
// Case insensitive
|
||||||
|
{"Case insensitive BOOL", "BOOL", "boolean"},
|
||||||
|
{"Case insensitive InT64", "InT64", "bigint"},
|
||||||
|
|
||||||
|
// Unknown types remain unchanged (difference from GetSQLType)
|
||||||
|
{"Unknown type varchar", "varchar", "varchar"},
|
||||||
|
{"Unknown type foobar", "foobar", "foobar"},
|
||||||
|
{"Empty string", "", ""},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
got := ConvertSQLType(tt.anytype)
|
||||||
|
if got != tt.want {
|
||||||
|
t.Errorf("ConvertSQLType(%q) = %q, want %q", tt.anytype, got, tt.want)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestIsGoType(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
typeName string
|
||||||
|
want bool
|
||||||
|
}{
|
||||||
|
// Go basic types
|
||||||
|
{"Go bool", "bool", true},
|
||||||
|
{"Go int64", "int64", true},
|
||||||
|
{"Go int", "int", true},
|
||||||
|
{"Go int32", "int32", true},
|
||||||
|
{"Go int16", "int16", true},
|
||||||
|
{"Go int8", "int8", true},
|
||||||
|
{"Go uint", "uint", true},
|
||||||
|
{"Go uint64", "uint64", true},
|
||||||
|
{"Go uint32", "uint32", true},
|
||||||
|
{"Go uint16", "uint16", true},
|
||||||
|
{"Go uint8", "uint8", true},
|
||||||
|
{"Go float64", "float64", true},
|
||||||
|
{"Go float32", "float32", true},
|
||||||
|
{"Go string", "string", true},
|
||||||
|
{"Go []byte", "[]byte", true},
|
||||||
|
|
||||||
|
// Go custom types
|
||||||
|
{"Go complex64", "complex64", true},
|
||||||
|
{"Go complex128", "complex128", true},
|
||||||
|
{"Go uintptr", "uintptr", true},
|
||||||
|
{"Go Pointer", "Pointer", true},
|
||||||
|
|
||||||
|
// Custom SQL types
|
||||||
|
{"Custom sqluuid", "sqluuid", true},
|
||||||
|
{"Custom sqljsonb", "sqljsonb", true},
|
||||||
|
{"Custom sqlint64", "sqlint64", true},
|
||||||
|
{"Custom customdate", "customdate", true},
|
||||||
|
{"Custom customtime", "customtime", true},
|
||||||
|
|
||||||
|
// Case insensitive
|
||||||
|
{"Case insensitive BOOL", "BOOL", true},
|
||||||
|
{"Case insensitive InT64", "InT64", true},
|
||||||
|
{"Case insensitive STRING", "STRING", true},
|
||||||
|
|
||||||
|
// SQL types (not Go types)
|
||||||
|
{"SQL bigint", "bigint", false},
|
||||||
|
{"SQL integer", "integer", false},
|
||||||
|
{"SQL text", "text", false},
|
||||||
|
{"SQL boolean", "boolean", false},
|
||||||
|
|
||||||
|
// Invalid types
|
||||||
|
{"Invalid type", "invalidtype", false},
|
||||||
|
{"Empty string", "", false},
|
||||||
|
{"Random string", "foobar", false},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
got := IsGoType(tt.typeName)
|
||||||
|
if got != tt.want {
|
||||||
|
t.Errorf("IsGoType(%q) = %v, want %v", tt.typeName, got, tt.want)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestGetStdTypeFromGo(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
typeName string
|
||||||
|
want string
|
||||||
|
}{
|
||||||
|
// Go types to standard SQL types
|
||||||
|
{"Go bool to boolean", "bool", "boolean"},
|
||||||
|
{"Go int64 to bigint", "int64", "bigint"},
|
||||||
|
{"Go int to integer", "int", "integer"},
|
||||||
|
{"Go string to text", "string", "text"},
|
||||||
|
{"Go float64 to double", "float64", "double"},
|
||||||
|
{"Go float32 to double", "float32", "double"},
|
||||||
|
{"Go []byte to blob", "[]byte", "blob"},
|
||||||
|
{"Go int32 to integer", "int32", "integer"},
|
||||||
|
{"Go int16 to smallint", "int16", "smallint"},
|
||||||
|
|
||||||
|
// Custom types
|
||||||
|
{"Custom sqluuid to uuid", "sqluuid", "uuid"},
|
||||||
|
{"Custom sqljsonb to jsonb", "sqljsonb", "jsonb"},
|
||||||
|
{"Custom sqlint64 to bigint", "sqlint64", "bigint"},
|
||||||
|
{"Custom customdate to date", "customdate", "date"},
|
||||||
|
|
||||||
|
// Case insensitive
|
||||||
|
{"Case insensitive BOOL", "BOOL", "boolean"},
|
||||||
|
{"Case insensitive InT64", "InT64", "bigint"},
|
||||||
|
{"Case insensitive STRING", "STRING", "text"},
|
||||||
|
|
||||||
|
// Non-Go types remain unchanged
|
||||||
|
{"SQL bigint unchanged", "bigint", "bigint"},
|
||||||
|
{"SQL integer unchanged", "integer", "integer"},
|
||||||
|
{"Invalid type unchanged", "invalidtype", "invalidtype"},
|
||||||
|
{"Empty string unchanged", "", ""},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
got := GetStdTypeFromGo(tt.typeName)
|
||||||
|
if got != tt.want {
|
||||||
|
t.Errorf("GetStdTypeFromGo(%q) = %q, want %q", tt.typeName, got, tt.want)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestGoToStdTypesMap(t *testing.T) {
|
||||||
|
// Test that the map contains expected entries
|
||||||
|
expectedMappings := map[string]string{
|
||||||
|
"bool": "boolean",
|
||||||
|
"int64": "bigint",
|
||||||
|
"int": "integer",
|
||||||
|
"string": "text",
|
||||||
|
"float64": "double",
|
||||||
|
"[]byte": "blob",
|
||||||
|
}
|
||||||
|
|
||||||
|
for goType, expectedStd := range expectedMappings {
|
||||||
|
if stdType, ok := GoToStdTypes[goType]; !ok {
|
||||||
|
t.Errorf("GoToStdTypes missing entry for %q", goType)
|
||||||
|
} else if stdType != expectedStd {
|
||||||
|
t.Errorf("GoToStdTypes[%q] = %q, want %q", goType, stdType, expectedStd)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test that the map is not empty
|
||||||
|
if len(GoToStdTypes) == 0 {
|
||||||
|
t.Error("GoToStdTypes map is empty")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestGoToPGSQLTypesMap(t *testing.T) {
|
||||||
|
// Test that the map contains expected entries
|
||||||
|
expectedMappings := map[string]string{
|
||||||
|
"bool": "boolean",
|
||||||
|
"int64": "bigint",
|
||||||
|
"int": "integer",
|
||||||
|
"string": "text",
|
||||||
|
"float64": "double precision",
|
||||||
|
"float32": "real",
|
||||||
|
"[]byte": "bytea",
|
||||||
|
}
|
||||||
|
|
||||||
|
for goType, expectedPG := range expectedMappings {
|
||||||
|
if pgType, ok := GoToPGSQLTypes[goType]; !ok {
|
||||||
|
t.Errorf("GoToPGSQLTypes missing entry for %q", goType)
|
||||||
|
} else if pgType != expectedPG {
|
||||||
|
t.Errorf("GoToPGSQLTypes[%q] = %q, want %q", goType, pgType, expectedPG)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test that the map is not empty
|
||||||
|
if len(GoToPGSQLTypes) == 0 {
|
||||||
|
t.Error("GoToPGSQLTypes map is empty")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestTypeConversionConsistency(t *testing.T) {
|
||||||
|
// Test that GetSQLType and ConvertSQLType are consistent for known types
|
||||||
|
knownGoTypes := []string{"bool", "int64", "int", "string", "float64", "[]byte"}
|
||||||
|
|
||||||
|
for _, goType := range knownGoTypes {
|
||||||
|
getSQLResult := GetSQLType(goType)
|
||||||
|
convertResult := ConvertSQLType(goType)
|
||||||
|
|
||||||
|
if getSQLResult != convertResult {
|
||||||
|
t.Errorf("Inconsistent results for %q: GetSQLType=%q, ConvertSQLType=%q",
|
||||||
|
goType, getSQLResult, convertResult)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestGetSQLTypeVsConvertSQLTypeDifference(t *testing.T) {
|
||||||
|
// Test that GetSQLType returns "text" for unknown types
|
||||||
|
// while ConvertSQLType returns the input unchanged
|
||||||
|
unknownTypes := []string{"varchar", "char", "customtype", "unknowntype"}
|
||||||
|
|
||||||
|
for _, unknown := range unknownTypes {
|
||||||
|
getSQLResult := GetSQLType(unknown)
|
||||||
|
convertResult := ConvertSQLType(unknown)
|
||||||
|
|
||||||
|
if getSQLResult != "text" {
|
||||||
|
t.Errorf("GetSQLType(%q) = %q, want %q", unknown, getSQLResult, "text")
|
||||||
|
}
|
||||||
|
|
||||||
|
if convertResult != unknown {
|
||||||
|
t.Errorf("ConvertSQLType(%q) = %q, want %q", unknown, convertResult, unknown)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
136
pkg/pgsql/keywords_test.go
Normal file
136
pkg/pgsql/keywords_test.go
Normal file
@@ -0,0 +1,136 @@
|
|||||||
|
package pgsql
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestGetPostgresKeywords(t *testing.T) {
|
||||||
|
keywords := GetPostgresKeywords()
|
||||||
|
|
||||||
|
// Test that keywords are returned
|
||||||
|
if len(keywords) == 0 {
|
||||||
|
t.Fatal("Expected non-empty list of keywords")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test that we get all keywords from the map
|
||||||
|
expectedCount := len(postgresKeywords)
|
||||||
|
if len(keywords) != expectedCount {
|
||||||
|
t.Errorf("Expected %d keywords, got %d", expectedCount, len(keywords))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test that all returned keywords exist in the map
|
||||||
|
for _, keyword := range keywords {
|
||||||
|
if !postgresKeywords[keyword] {
|
||||||
|
t.Errorf("Keyword %q not found in postgresKeywords map", keyword)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test that no duplicate keywords are returned
|
||||||
|
seen := make(map[string]bool)
|
||||||
|
for _, keyword := range keywords {
|
||||||
|
if seen[keyword] {
|
||||||
|
t.Errorf("Duplicate keyword found: %q", keyword)
|
||||||
|
}
|
||||||
|
seen[keyword] = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestPostgresKeywordsMap(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
keyword string
|
||||||
|
want bool
|
||||||
|
}{
|
||||||
|
{"SELECT keyword", "select", true},
|
||||||
|
{"FROM keyword", "from", true},
|
||||||
|
{"WHERE keyword", "where", true},
|
||||||
|
{"TABLE keyword", "table", true},
|
||||||
|
{"PRIMARY keyword", "primary", true},
|
||||||
|
{"FOREIGN keyword", "foreign", true},
|
||||||
|
{"CREATE keyword", "create", true},
|
||||||
|
{"DROP keyword", "drop", true},
|
||||||
|
{"ALTER keyword", "alter", true},
|
||||||
|
{"INDEX keyword", "index", true},
|
||||||
|
{"NOT keyword", "not", true},
|
||||||
|
{"NULL keyword", "null", true},
|
||||||
|
{"TRUE keyword", "true", true},
|
||||||
|
{"FALSE keyword", "false", true},
|
||||||
|
{"Non-keyword lowercase", "notakeyword", false},
|
||||||
|
{"Non-keyword uppercase", "NOTAKEYWORD", false},
|
||||||
|
{"Empty string", "", false},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
got := postgresKeywords[tt.keyword]
|
||||||
|
if got != tt.want {
|
||||||
|
t.Errorf("postgresKeywords[%q] = %v, want %v", tt.keyword, got, tt.want)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestPostgresKeywordsMapContent(t *testing.T) {
|
||||||
|
// Test that the map contains expected common keywords
|
||||||
|
commonKeywords := []string{
|
||||||
|
"select", "insert", "update", "delete", "create", "drop", "alter",
|
||||||
|
"table", "index", "view", "schema", "function", "procedure",
|
||||||
|
"primary", "foreign", "key", "constraint", "unique", "check",
|
||||||
|
"null", "not", "and", "or", "like", "in", "between",
|
||||||
|
"join", "inner", "left", "right", "cross", "full", "outer",
|
||||||
|
"where", "having", "group", "order", "limit", "offset",
|
||||||
|
"union", "intersect", "except",
|
||||||
|
"begin", "commit", "rollback", "transaction",
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, keyword := range commonKeywords {
|
||||||
|
if !postgresKeywords[keyword] {
|
||||||
|
t.Errorf("Expected common keyword %q to be in postgresKeywords map", keyword)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestPostgresKeywordsMapSize(t *testing.T) {
|
||||||
|
// PostgreSQL has a substantial list of reserved keywords
|
||||||
|
// This test ensures the map has a reasonable number of entries
|
||||||
|
minExpectedKeywords := 200 // PostgreSQL 13+ has 400+ reserved words
|
||||||
|
|
||||||
|
if len(postgresKeywords) < minExpectedKeywords {
|
||||||
|
t.Errorf("Expected at least %d keywords, got %d. The map may be incomplete.",
|
||||||
|
minExpectedKeywords, len(postgresKeywords))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestGetPostgresKeywordsConsistency(t *testing.T) {
|
||||||
|
// Test that calling GetPostgresKeywords multiple times returns consistent results
|
||||||
|
keywords1 := GetPostgresKeywords()
|
||||||
|
keywords2 := GetPostgresKeywords()
|
||||||
|
|
||||||
|
if len(keywords1) != len(keywords2) {
|
||||||
|
t.Errorf("Inconsistent results: first call returned %d keywords, second call returned %d",
|
||||||
|
len(keywords1), len(keywords2))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create a map from both results to compare
|
||||||
|
map1 := make(map[string]bool)
|
||||||
|
map2 := make(map[string]bool)
|
||||||
|
|
||||||
|
for _, k := range keywords1 {
|
||||||
|
map1[k] = true
|
||||||
|
}
|
||||||
|
for _, k := range keywords2 {
|
||||||
|
map2[k] = true
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check that both contain the same keywords
|
||||||
|
for k := range map1 {
|
||||||
|
if !map2[k] {
|
||||||
|
t.Errorf("Keyword %q present in first call but not in second", k)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for k := range map2 {
|
||||||
|
if !map1[k] {
|
||||||
|
t.Errorf("Keyword %q present in second call but not in first", k)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -128,6 +128,46 @@ func (r *Reader) readDirectoryDBML(dirPath string) (*models.Database, error) {
|
|||||||
return db, nil
|
return db, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// splitIdentifier splits a dotted identifier while respecting quotes
|
||||||
|
// Handles cases like: "schema.with.dots"."table"."column"
|
||||||
|
func splitIdentifier(s string) []string {
|
||||||
|
var parts []string
|
||||||
|
var current strings.Builder
|
||||||
|
inQuote := false
|
||||||
|
quoteChar := byte(0)
|
||||||
|
|
||||||
|
for i := 0; i < len(s); i++ {
|
||||||
|
ch := s[i]
|
||||||
|
|
||||||
|
if !inQuote {
|
||||||
|
switch ch {
|
||||||
|
case '"', '\'':
|
||||||
|
inQuote = true
|
||||||
|
quoteChar = ch
|
||||||
|
current.WriteByte(ch)
|
||||||
|
case '.':
|
||||||
|
if current.Len() > 0 {
|
||||||
|
parts = append(parts, current.String())
|
||||||
|
current.Reset()
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
current.WriteByte(ch)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
current.WriteByte(ch)
|
||||||
|
if ch == quoteChar {
|
||||||
|
inQuote = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if current.Len() > 0 {
|
||||||
|
parts = append(parts, current.String())
|
||||||
|
}
|
||||||
|
|
||||||
|
return parts
|
||||||
|
}
|
||||||
|
|
||||||
// stripQuotes removes surrounding quotes and comments from an identifier
|
// stripQuotes removes surrounding quotes and comments from an identifier
|
||||||
func stripQuotes(s string) string {
|
func stripQuotes(s string) string {
|
||||||
s = strings.TrimSpace(s)
|
s = strings.TrimSpace(s)
|
||||||
@@ -409,7 +449,9 @@ func (r *Reader) parseDBML(content string) (*models.Database, error) {
|
|||||||
// Parse Table definition
|
// Parse Table definition
|
||||||
if matches := tableRegex.FindStringSubmatch(line); matches != nil {
|
if matches := tableRegex.FindStringSubmatch(line); matches != nil {
|
||||||
tableName := matches[1]
|
tableName := matches[1]
|
||||||
parts := strings.Split(tableName, ".")
|
// Strip comments/notes before parsing to avoid dots in notes
|
||||||
|
tableName = strings.TrimSpace(regexp.MustCompile(`\s*\[.*?\]\s*`).ReplaceAllString(tableName, ""))
|
||||||
|
parts := splitIdentifier(tableName)
|
||||||
|
|
||||||
if len(parts) == 2 {
|
if len(parts) == 2 {
|
||||||
currentSchema = stripQuotes(parts[0])
|
currentSchema = stripQuotes(parts[0])
|
||||||
@@ -561,8 +603,10 @@ func (r *Reader) parseColumn(line, tableName, schemaName string) (*models.Column
|
|||||||
column.Default = strings.Trim(defaultVal, "'\"")
|
column.Default = strings.Trim(defaultVal, "'\"")
|
||||||
} else if attr == "unique" {
|
} else if attr == "unique" {
|
||||||
// Create a unique constraint
|
// Create a unique constraint
|
||||||
|
// Clean table name by removing leading underscores to avoid double underscores
|
||||||
|
cleanTableName := strings.TrimLeft(tableName, "_")
|
||||||
uniqueConstraint := models.InitConstraint(
|
uniqueConstraint := models.InitConstraint(
|
||||||
fmt.Sprintf("uq_%s", columnName),
|
fmt.Sprintf("ukey_%s_%s", cleanTableName, columnName),
|
||||||
models.UniqueConstraint,
|
models.UniqueConstraint,
|
||||||
)
|
)
|
||||||
uniqueConstraint.Schema = schemaName
|
uniqueConstraint.Schema = schemaName
|
||||||
@@ -610,8 +654,8 @@ func (r *Reader) parseColumn(line, tableName, schemaName string) (*models.Column
|
|||||||
constraint.Table = tableName
|
constraint.Table = tableName
|
||||||
constraint.Columns = []string{columnName}
|
constraint.Columns = []string{columnName}
|
||||||
}
|
}
|
||||||
// Generate short constraint name based on the column
|
// Generate constraint name based on table and columns
|
||||||
constraint.Name = fmt.Sprintf("fk_%s", constraint.Columns[0])
|
constraint.Name = fmt.Sprintf("fk_%s_%s", constraint.Table, strings.Join(constraint.Columns, "_"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -695,7 +739,11 @@ func (r *Reader) parseIndex(line, tableName, schemaName string) *models.Index {
|
|||||||
|
|
||||||
// Generate name if not provided
|
// Generate name if not provided
|
||||||
if index.Name == "" {
|
if index.Name == "" {
|
||||||
index.Name = fmt.Sprintf("idx_%s_%s", tableName, strings.Join(columns, "_"))
|
prefix := "idx"
|
||||||
|
if index.Unique {
|
||||||
|
prefix = "uidx"
|
||||||
|
}
|
||||||
|
index.Name = fmt.Sprintf("%s_%s_%s", prefix, tableName, strings.Join(columns, "_"))
|
||||||
}
|
}
|
||||||
|
|
||||||
return index
|
return index
|
||||||
@@ -755,10 +803,10 @@ func (r *Reader) parseRef(refStr string) *models.Constraint {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generate short constraint name based on the source column
|
// Generate constraint name based on table and columns
|
||||||
constraintName := fmt.Sprintf("fk_%s_%s", fromTable, toTable)
|
constraintName := fmt.Sprintf("fk_%s_%s", fromTable, strings.Join(fromColumns, "_"))
|
||||||
if len(fromColumns) > 0 {
|
if len(fromColumns) == 0 {
|
||||||
constraintName = fmt.Sprintf("fk_%s", fromColumns[0])
|
constraintName = fmt.Sprintf("fk_%s_%s", fromTable, toTable)
|
||||||
}
|
}
|
||||||
|
|
||||||
constraint := models.InitConstraint(
|
constraint := models.InitConstraint(
|
||||||
@@ -814,7 +862,7 @@ func (r *Reader) parseTableRef(ref string) (schema, table string, columns []stri
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Parse schema, table, and optionally column
|
// Parse schema, table, and optionally column
|
||||||
parts := strings.Split(strings.TrimSpace(ref), ".")
|
parts := splitIdentifier(strings.TrimSpace(ref))
|
||||||
if len(parts) == 3 {
|
if len(parts) == 3 {
|
||||||
// Format: "schema"."table"."column"
|
// Format: "schema"."table"."column"
|
||||||
schema = stripQuotes(parts[0])
|
schema = stripQuotes(parts[0])
|
||||||
|
|||||||
@@ -777,6 +777,76 @@ func TestParseFilePrefix(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestConstraintNaming(t *testing.T) {
|
||||||
|
// Test that constraints are named with proper prefixes
|
||||||
|
opts := &readers.ReaderOptions{
|
||||||
|
FilePath: filepath.Join("..", "..", "..", "tests", "assets", "dbml", "complex.dbml"),
|
||||||
|
}
|
||||||
|
|
||||||
|
reader := NewReader(opts)
|
||||||
|
db, err := reader.ReadDatabase()
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("ReadDatabase() error = %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Find users table
|
||||||
|
var usersTable *models.Table
|
||||||
|
var postsTable *models.Table
|
||||||
|
for _, schema := range db.Schemas {
|
||||||
|
for _, table := range schema.Tables {
|
||||||
|
if table.Name == "users" {
|
||||||
|
usersTable = table
|
||||||
|
} else if table.Name == "posts" {
|
||||||
|
postsTable = table
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if usersTable == nil {
|
||||||
|
t.Fatal("Users table not found")
|
||||||
|
}
|
||||||
|
if postsTable == nil {
|
||||||
|
t.Fatal("Posts table not found")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test unique constraint naming: ukey_table_column
|
||||||
|
if _, exists := usersTable.Constraints["ukey_users_email"]; !exists {
|
||||||
|
t.Error("Expected unique constraint 'ukey_users_email' not found")
|
||||||
|
t.Logf("Available constraints: %v", getKeys(usersTable.Constraints))
|
||||||
|
}
|
||||||
|
|
||||||
|
if _, exists := postsTable.Constraints["ukey_posts_slug"]; !exists {
|
||||||
|
t.Error("Expected unique constraint 'ukey_posts_slug' not found")
|
||||||
|
t.Logf("Available constraints: %v", getKeys(postsTable.Constraints))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test foreign key naming: fk_table_column
|
||||||
|
if _, exists := postsTable.Constraints["fk_posts_user_id"]; !exists {
|
||||||
|
t.Error("Expected foreign key 'fk_posts_user_id' not found")
|
||||||
|
t.Logf("Available constraints: %v", getKeys(postsTable.Constraints))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test unique index naming: uidx_table_columns
|
||||||
|
if _, exists := postsTable.Indexes["uidx_posts_slug"]; !exists {
|
||||||
|
t.Error("Expected unique index 'uidx_posts_slug' not found")
|
||||||
|
t.Logf("Available indexes: %v", getKeys(postsTable.Indexes))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test regular index naming: idx_table_columns
|
||||||
|
if _, exists := postsTable.Indexes["idx_posts_user_id_published"]; !exists {
|
||||||
|
t.Error("Expected index 'idx_posts_user_id_published' not found")
|
||||||
|
t.Logf("Available indexes: %v", getKeys(postsTable.Indexes))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func getKeys[V any](m map[string]V) []string {
|
||||||
|
keys := make([]string, 0, len(m))
|
||||||
|
for k := range m {
|
||||||
|
keys = append(keys, k)
|
||||||
|
}
|
||||||
|
return keys
|
||||||
|
}
|
||||||
|
|
||||||
func TestHasCommentedRefs(t *testing.T) {
|
func TestHasCommentedRefs(t *testing.T) {
|
||||||
// Test with the actual multifile test fixtures
|
// Test with the actual multifile test fixtures
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
|
|||||||
@@ -93,6 +93,7 @@ fmt.Printf("Found %d scripts\n", len(schema.Scripts))
|
|||||||
## Features
|
## Features
|
||||||
|
|
||||||
- **Recursive Directory Scanning**: Automatically scans all subdirectories
|
- **Recursive Directory Scanning**: Automatically scans all subdirectories
|
||||||
|
- **Symlink Skipping**: Symbolic links are automatically skipped (prevents loops and duplicates)
|
||||||
- **Multiple Extensions**: Supports both `.sql` and `.pgsql` files
|
- **Multiple Extensions**: Supports both `.sql` and `.pgsql` files
|
||||||
- **Flexible Naming**: Extract metadata from filename patterns
|
- **Flexible Naming**: Extract metadata from filename patterns
|
||||||
- **Error Handling**: Validates directory existence and file accessibility
|
- **Error Handling**: Validates directory existence and file accessibility
|
||||||
@@ -153,8 +154,9 @@ go test ./pkg/readers/sqldir/
|
|||||||
```
|
```
|
||||||
|
|
||||||
Tests include:
|
Tests include:
|
||||||
- Valid file parsing
|
- Valid file parsing (underscore and hyphen formats)
|
||||||
- Recursive directory scanning
|
- Recursive directory scanning
|
||||||
|
- Symlink skipping
|
||||||
- Invalid filename handling
|
- Invalid filename handling
|
||||||
- Empty directory handling
|
- Empty directory handling
|
||||||
- Error conditions
|
- Error conditions
|
||||||
|
|||||||
@@ -107,11 +107,20 @@ func (r *Reader) readScripts() ([]*models.Script, error) {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Skip directories
|
// Don't process directories as files (WalkDir still descends into them recursively)
|
||||||
if d.IsDir() {
|
if d.IsDir() {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Skip symlinks
|
||||||
|
info, err := d.Info()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if info.Mode()&os.ModeSymlink != 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// Get filename
|
// Get filename
|
||||||
filename := d.Name()
|
filename := d.Name()
|
||||||
|
|
||||||
|
|||||||
@@ -373,3 +373,65 @@ func TestReader_MixedFormat(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestReader_SkipSymlinks(t *testing.T) {
|
||||||
|
// Create temporary test directory
|
||||||
|
tempDir, err := os.MkdirTemp("", "sqldir-test-symlink-*")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Failed to create temp directory: %v", err)
|
||||||
|
}
|
||||||
|
defer os.RemoveAll(tempDir)
|
||||||
|
|
||||||
|
// Create a real SQL file
|
||||||
|
realFile := filepath.Join(tempDir, "1_001_real_file.sql")
|
||||||
|
if err := os.WriteFile(realFile, []byte("SELECT 1;"), 0644); err != nil {
|
||||||
|
t.Fatalf("Failed to create real file: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create another file to link to
|
||||||
|
targetFile := filepath.Join(tempDir, "2_001_target.sql")
|
||||||
|
if err := os.WriteFile(targetFile, []byte("SELECT 2;"), 0644); err != nil {
|
||||||
|
t.Fatalf("Failed to create target file: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create a symlink to the target file (this should be skipped)
|
||||||
|
symlinkFile := filepath.Join(tempDir, "3_001_symlink.sql")
|
||||||
|
if err := os.Symlink(targetFile, symlinkFile); err != nil {
|
||||||
|
// Skip test on systems that don't support symlinks (e.g., Windows without admin)
|
||||||
|
t.Skipf("Symlink creation not supported: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create reader
|
||||||
|
reader := NewReader(&readers.ReaderOptions{
|
||||||
|
FilePath: tempDir,
|
||||||
|
})
|
||||||
|
|
||||||
|
// Read database
|
||||||
|
db, err := reader.ReadDatabase()
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("ReadDatabase failed: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
schema := db.Schemas[0]
|
||||||
|
|
||||||
|
// Should only have 2 scripts (real_file and target), symlink should be skipped
|
||||||
|
if len(schema.Scripts) != 2 {
|
||||||
|
t.Errorf("Expected 2 scripts (symlink should be skipped), got %d", len(schema.Scripts))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Verify the scripts are the real files, not the symlink
|
||||||
|
scriptNames := make(map[string]bool)
|
||||||
|
for _, script := range schema.Scripts {
|
||||||
|
scriptNames[script.Name] = true
|
||||||
|
}
|
||||||
|
|
||||||
|
if !scriptNames["real_file"] {
|
||||||
|
t.Error("Expected 'real_file' script to be present")
|
||||||
|
}
|
||||||
|
if !scriptNames["target"] {
|
||||||
|
t.Error("Expected 'target' script to be present")
|
||||||
|
}
|
||||||
|
if scriptNames["symlink"] {
|
||||||
|
t.Error("Symlink script should have been skipped but was found")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
490
pkg/reflectutil/helpers_test.go
Normal file
490
pkg/reflectutil/helpers_test.go
Normal file
@@ -0,0 +1,490 @@
|
|||||||
|
package reflectutil
|
||||||
|
|
||||||
|
import (
|
||||||
|
"reflect"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
type testStruct struct {
|
||||||
|
Name string
|
||||||
|
Age int
|
||||||
|
Active bool
|
||||||
|
Nested *nestedStruct
|
||||||
|
Private string
|
||||||
|
}
|
||||||
|
|
||||||
|
type nestedStruct struct {
|
||||||
|
Value string
|
||||||
|
Count int
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestDeref(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
input interface{}
|
||||||
|
wantValid bool
|
||||||
|
wantKind reflect.Kind
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "non-pointer int",
|
||||||
|
input: 42,
|
||||||
|
wantValid: true,
|
||||||
|
wantKind: reflect.Int,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "single pointer",
|
||||||
|
input: ptrInt(42),
|
||||||
|
wantValid: true,
|
||||||
|
wantKind: reflect.Int,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "double pointer",
|
||||||
|
input: ptrPtr(ptrInt(42)),
|
||||||
|
wantValid: true,
|
||||||
|
wantKind: reflect.Int,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "nil pointer",
|
||||||
|
input: (*int)(nil),
|
||||||
|
wantValid: false,
|
||||||
|
wantKind: reflect.Ptr,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "string",
|
||||||
|
input: "test",
|
||||||
|
wantValid: true,
|
||||||
|
wantKind: reflect.String,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "struct",
|
||||||
|
input: testStruct{Name: "test"},
|
||||||
|
wantValid: true,
|
||||||
|
wantKind: reflect.Struct,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
v := reflect.ValueOf(tt.input)
|
||||||
|
got, valid := Deref(v)
|
||||||
|
|
||||||
|
if valid != tt.wantValid {
|
||||||
|
t.Errorf("Deref() valid = %v, want %v", valid, tt.wantValid)
|
||||||
|
}
|
||||||
|
|
||||||
|
if got.Kind() != tt.wantKind {
|
||||||
|
t.Errorf("Deref() kind = %v, want %v", got.Kind(), tt.wantKind)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestDerefInterface(t *testing.T) {
|
||||||
|
i := 42
|
||||||
|
pi := &i
|
||||||
|
ppi := &pi
|
||||||
|
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
input interface{}
|
||||||
|
wantKind reflect.Kind
|
||||||
|
}{
|
||||||
|
{"int", 42, reflect.Int},
|
||||||
|
{"pointer to int", &i, reflect.Int},
|
||||||
|
{"double pointer to int", ppi, reflect.Int},
|
||||||
|
{"string", "test", reflect.String},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
got := DerefInterface(tt.input)
|
||||||
|
if got.Kind() != tt.wantKind {
|
||||||
|
t.Errorf("DerefInterface() kind = %v, want %v", got.Kind(), tt.wantKind)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestGetFieldValue(t *testing.T) {
|
||||||
|
ts := testStruct{
|
||||||
|
Name: "John",
|
||||||
|
Age: 30,
|
||||||
|
Active: true,
|
||||||
|
Nested: &nestedStruct{Value: "nested", Count: 5},
|
||||||
|
}
|
||||||
|
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
item interface{}
|
||||||
|
field string
|
||||||
|
want interface{}
|
||||||
|
}{
|
||||||
|
{"struct field Name", ts, "Name", "John"},
|
||||||
|
{"struct field Age", ts, "Age", 30},
|
||||||
|
{"struct field Active", ts, "Active", true},
|
||||||
|
{"struct non-existent field", ts, "NonExistent", nil},
|
||||||
|
{"pointer to struct", &ts, "Name", "John"},
|
||||||
|
{"map string key", map[string]string{"key": "value"}, "key", "value"},
|
||||||
|
{"map int key", map[string]int{"count": 42}, "count", 42},
|
||||||
|
{"map non-existent key", map[string]string{"key": "value"}, "missing", nil},
|
||||||
|
{"nil pointer", (*testStruct)(nil), "Name", nil},
|
||||||
|
{"non-struct non-map", 42, "field", nil},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
got := GetFieldValue(tt.item, tt.field)
|
||||||
|
if !reflect.DeepEqual(got, tt.want) {
|
||||||
|
t.Errorf("GetFieldValue() = %v, want %v", got, tt.want)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestIsSliceOrArray(t *testing.T) {
|
||||||
|
arr := [3]int{1, 2, 3}
|
||||||
|
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
input interface{}
|
||||||
|
want bool
|
||||||
|
}{
|
||||||
|
{"slice", []int{1, 2, 3}, true},
|
||||||
|
{"array", arr, true},
|
||||||
|
{"pointer to slice", &[]int{1, 2, 3}, true},
|
||||||
|
{"string", "test", false},
|
||||||
|
{"int", 42, false},
|
||||||
|
{"map", map[string]int{}, false},
|
||||||
|
{"nil slice", ([]int)(nil), true}, // nil slice is still Kind==Slice
|
||||||
|
{"nil pointer", (*[]int)(nil), false},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
got := IsSliceOrArray(tt.input)
|
||||||
|
if got != tt.want {
|
||||||
|
t.Errorf("IsSliceOrArray() = %v, want %v", got, tt.want)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestIsMap(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
input interface{}
|
||||||
|
want bool
|
||||||
|
}{
|
||||||
|
{"map[string]int", map[string]int{"a": 1}, true},
|
||||||
|
{"map[int]string", map[int]string{1: "a"}, true},
|
||||||
|
{"pointer to map", &map[string]int{"a": 1}, true},
|
||||||
|
{"slice", []int{1, 2, 3}, false},
|
||||||
|
{"string", "test", false},
|
||||||
|
{"int", 42, false},
|
||||||
|
{"nil map", (map[string]int)(nil), true}, // nil map is still Kind==Map
|
||||||
|
{"nil pointer", (*map[string]int)(nil), false},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
got := IsMap(tt.input)
|
||||||
|
if got != tt.want {
|
||||||
|
t.Errorf("IsMap() = %v, want %v", got, tt.want)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestSliceLen(t *testing.T) {
|
||||||
|
arr := [3]int{1, 2, 3}
|
||||||
|
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
input interface{}
|
||||||
|
want int
|
||||||
|
}{
|
||||||
|
{"slice length 3", []int{1, 2, 3}, 3},
|
||||||
|
{"empty slice", []int{}, 0},
|
||||||
|
{"array length 3", arr, 3},
|
||||||
|
{"pointer to slice", &[]int{1, 2, 3}, 3},
|
||||||
|
{"not a slice", "test", 0},
|
||||||
|
{"int", 42, 0},
|
||||||
|
{"nil slice", ([]int)(nil), 0},
|
||||||
|
{"nil pointer", (*[]int)(nil), 0},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
got := SliceLen(tt.input)
|
||||||
|
if got != tt.want {
|
||||||
|
t.Errorf("SliceLen() = %v, want %v", got, tt.want)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestMapLen(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
input interface{}
|
||||||
|
want int
|
||||||
|
}{
|
||||||
|
{"map length 2", map[string]int{"a": 1, "b": 2}, 2},
|
||||||
|
{"empty map", map[string]int{}, 0},
|
||||||
|
{"pointer to map", &map[string]int{"a": 1}, 1},
|
||||||
|
{"not a map", []int{1, 2, 3}, 0},
|
||||||
|
{"string", "test", 0},
|
||||||
|
{"nil map", (map[string]int)(nil), 0},
|
||||||
|
{"nil pointer", (*map[string]int)(nil), 0},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
got := MapLen(tt.input)
|
||||||
|
if got != tt.want {
|
||||||
|
t.Errorf("MapLen() = %v, want %v", got, tt.want)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestSliceToInterfaces(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
input interface{}
|
||||||
|
want []interface{}
|
||||||
|
}{
|
||||||
|
{"int slice", []int{1, 2, 3}, []interface{}{1, 2, 3}},
|
||||||
|
{"string slice", []string{"a", "b"}, []interface{}{"a", "b"}},
|
||||||
|
{"empty slice", []int{}, []interface{}{}},
|
||||||
|
{"pointer to slice", &[]int{1, 2}, []interface{}{1, 2}},
|
||||||
|
{"not a slice", "test", []interface{}{}},
|
||||||
|
{"nil slice", ([]int)(nil), []interface{}{}},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
got := SliceToInterfaces(tt.input)
|
||||||
|
if !reflect.DeepEqual(got, tt.want) {
|
||||||
|
t.Errorf("SliceToInterfaces() = %v, want %v", got, tt.want)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestMapKeys(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
input interface{}
|
||||||
|
want []interface{}
|
||||||
|
}{
|
||||||
|
{"map with keys", map[string]int{"a": 1, "b": 2}, []interface{}{"a", "b"}},
|
||||||
|
{"empty map", map[string]int{}, []interface{}{}},
|
||||||
|
{"not a map", []int{1, 2, 3}, []interface{}{}},
|
||||||
|
{"nil map", (map[string]int)(nil), []interface{}{}},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
got := MapKeys(tt.input)
|
||||||
|
if len(got) != len(tt.want) {
|
||||||
|
t.Errorf("MapKeys() length = %v, want %v", len(got), len(tt.want))
|
||||||
|
}
|
||||||
|
// For maps, order is not guaranteed, so just check length
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestMapValues(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
input interface{}
|
||||||
|
want int // length of values
|
||||||
|
}{
|
||||||
|
{"map with values", map[string]int{"a": 1, "b": 2}, 2},
|
||||||
|
{"empty map", map[string]int{}, 0},
|
||||||
|
{"not a map", []int{1, 2, 3}, 0},
|
||||||
|
{"nil map", (map[string]int)(nil), 0},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
got := MapValues(tt.input)
|
||||||
|
if len(got) != tt.want {
|
||||||
|
t.Errorf("MapValues() length = %v, want %v", len(got), tt.want)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestMapGet(t *testing.T) {
|
||||||
|
m := map[string]int{"a": 1, "b": 2}
|
||||||
|
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
input interface{}
|
||||||
|
key interface{}
|
||||||
|
want interface{}
|
||||||
|
}{
|
||||||
|
{"existing key", m, "a", 1},
|
||||||
|
{"existing key b", m, "b", 2},
|
||||||
|
{"non-existing key", m, "c", nil},
|
||||||
|
{"pointer to map", &m, "a", 1},
|
||||||
|
{"not a map", []int{1, 2}, 0, nil},
|
||||||
|
{"nil map", (map[string]int)(nil), "a", nil},
|
||||||
|
{"nil pointer", (*map[string]int)(nil), "a", nil},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
got := MapGet(tt.input, tt.key)
|
||||||
|
if !reflect.DeepEqual(got, tt.want) {
|
||||||
|
t.Errorf("MapGet() = %v, want %v", got, tt.want)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestSliceIndex(t *testing.T) {
|
||||||
|
s := []int{10, 20, 30}
|
||||||
|
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
slice interface{}
|
||||||
|
index int
|
||||||
|
want interface{}
|
||||||
|
}{
|
||||||
|
{"index 0", s, 0, 10},
|
||||||
|
{"index 1", s, 1, 20},
|
||||||
|
{"index 2", s, 2, 30},
|
||||||
|
{"negative index", s, -1, nil},
|
||||||
|
{"out of bounds", s, 5, nil},
|
||||||
|
{"pointer to slice", &s, 1, 20},
|
||||||
|
{"not a slice", "test", 0, nil},
|
||||||
|
{"nil slice", ([]int)(nil), 0, nil},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
got := SliceIndex(tt.slice, tt.index)
|
||||||
|
if !reflect.DeepEqual(got, tt.want) {
|
||||||
|
t.Errorf("SliceIndex() = %v, want %v", got, tt.want)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestCompareValues(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
a interface{}
|
||||||
|
b interface{}
|
||||||
|
want int
|
||||||
|
}{
|
||||||
|
{"both nil", nil, nil, 0},
|
||||||
|
{"a nil", nil, 5, -1},
|
||||||
|
{"b nil", 5, nil, 1},
|
||||||
|
{"equal strings", "abc", "abc", 0},
|
||||||
|
{"a less than b strings", "abc", "xyz", -1},
|
||||||
|
{"a greater than b strings", "xyz", "abc", 1},
|
||||||
|
{"equal ints", 5, 5, 0},
|
||||||
|
{"a less than b ints", 3, 7, -1},
|
||||||
|
{"a greater than b ints", 10, 5, 1},
|
||||||
|
{"equal floats", 3.14, 3.14, 0},
|
||||||
|
{"a less than b floats", 2.5, 5.5, -1},
|
||||||
|
{"a greater than b floats", 10.5, 5.5, 1},
|
||||||
|
{"equal uints", uint(5), uint(5), 0},
|
||||||
|
{"different types", "abc", 123, 0},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
got := CompareValues(tt.a, tt.b)
|
||||||
|
if got != tt.want {
|
||||||
|
t.Errorf("CompareValues(%v, %v) = %v, want %v", tt.a, tt.b, got, tt.want)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestGetNestedValue(t *testing.T) {
|
||||||
|
nested := map[string]interface{}{
|
||||||
|
"level1": map[string]interface{}{
|
||||||
|
"level2": map[string]interface{}{
|
||||||
|
"value": "deep",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
ts := testStruct{
|
||||||
|
Name: "John",
|
||||||
|
Nested: &nestedStruct{
|
||||||
|
Value: "nested value",
|
||||||
|
Count: 42,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
input interface{}
|
||||||
|
path string
|
||||||
|
want interface{}
|
||||||
|
}{
|
||||||
|
{"empty path", nested, "", nested},
|
||||||
|
{"single level map", nested, "level1", nested["level1"]},
|
||||||
|
{"nested map", nested, "level1.level2", map[string]interface{}{"value": "deep"}},
|
||||||
|
{"deep nested map", nested, "level1.level2.value", "deep"},
|
||||||
|
{"struct field", ts, "Name", "John"},
|
||||||
|
{"nested struct field", ts, "Nested", ts.Nested},
|
||||||
|
{"non-existent path", nested, "missing.path", nil},
|
||||||
|
{"nil input", nil, "path", nil},
|
||||||
|
{"partial missing path", nested, "level1.missing", nil},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
got := GetNestedValue(tt.input, tt.path)
|
||||||
|
if !reflect.DeepEqual(got, tt.want) {
|
||||||
|
t.Errorf("GetNestedValue() = %v, want %v", got, tt.want)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestDeepEqual(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
a interface{}
|
||||||
|
b interface{}
|
||||||
|
want bool
|
||||||
|
}{
|
||||||
|
{"equal ints", 42, 42, true},
|
||||||
|
{"different ints", 42, 43, false},
|
||||||
|
{"equal strings", "test", "test", true},
|
||||||
|
{"different strings", "test", "other", false},
|
||||||
|
{"equal slices", []int{1, 2, 3}, []int{1, 2, 3}, true},
|
||||||
|
{"different slices", []int{1, 2, 3}, []int{1, 2, 4}, false},
|
||||||
|
{"equal maps", map[string]int{"a": 1}, map[string]int{"a": 1}, true},
|
||||||
|
{"different maps", map[string]int{"a": 1}, map[string]int{"a": 2}, false},
|
||||||
|
{"both nil", nil, nil, true},
|
||||||
|
{"one nil", nil, 42, false},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
got := DeepEqual(tt.a, tt.b)
|
||||||
|
if got != tt.want {
|
||||||
|
t.Errorf("DeepEqual(%v, %v) = %v, want %v", tt.a, tt.b, got, tt.want)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Helper functions
|
||||||
|
func ptrInt(i int) *int {
|
||||||
|
return &i
|
||||||
|
}
|
||||||
|
|
||||||
|
func ptrPtr(p *int) **int {
|
||||||
|
return &p
|
||||||
|
}
|
||||||
@@ -106,11 +106,8 @@ func (td *TemplateData) FinalizeImports() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewModelData creates a new ModelData from a models.Table
|
// NewModelData creates a new ModelData from a models.Table
|
||||||
func NewModelData(table *models.Table, schema string, typeMapper *TypeMapper) *ModelData {
|
func NewModelData(table *models.Table, schema string, typeMapper *TypeMapper, flattenSchema bool) *ModelData {
|
||||||
tableName := table.Name
|
tableName := writers.QualifiedTableName(schema, table.Name, flattenSchema)
|
||||||
if schema != "" {
|
|
||||||
tableName = schema + "." + table.Name
|
|
||||||
}
|
|
||||||
|
|
||||||
// Generate model name: Model + Schema + Table (all PascalCase)
|
// Generate model name: Model + Schema + Table (all PascalCase)
|
||||||
singularTable := Singularize(table.Name)
|
singularTable := Singularize(table.Name)
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ func (w *Writer) writeSingleFile(db *models.Database) error {
|
|||||||
// Collect all models
|
// Collect all models
|
||||||
for _, schema := range db.Schemas {
|
for _, schema := range db.Schemas {
|
||||||
for _, table := range schema.Tables {
|
for _, table := range schema.Tables {
|
||||||
modelData := NewModelData(table, schema.Name, w.typeMapper)
|
modelData := NewModelData(table, schema.Name, w.typeMapper, w.options.FlattenSchema)
|
||||||
|
|
||||||
// Add relationship fields
|
// Add relationship fields
|
||||||
w.addRelationshipFields(modelData, table, schema, db)
|
w.addRelationshipFields(modelData, table, schema, db)
|
||||||
@@ -181,7 +181,7 @@ func (w *Writer) writeMultiFile(db *models.Database) error {
|
|||||||
templateData.AddImport(fmt.Sprintf("resolvespec_common \"%s\"", w.typeMapper.GetSQLTypesImport()))
|
templateData.AddImport(fmt.Sprintf("resolvespec_common \"%s\"", w.typeMapper.GetSQLTypesImport()))
|
||||||
|
|
||||||
// Create model data
|
// Create model data
|
||||||
modelData := NewModelData(table, schema.Name, w.typeMapper)
|
modelData := NewModelData(table, schema.Name, w.typeMapper, w.options.FlattenSchema)
|
||||||
|
|
||||||
// Add relationship fields
|
// Add relationship fields
|
||||||
w.addRelationshipFields(modelData, table, schema, db)
|
w.addRelationshipFields(modelData, table, schema, db)
|
||||||
|
|||||||
@@ -105,11 +105,8 @@ func (td *TemplateData) FinalizeImports() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewModelData creates a new ModelData from a models.Table
|
// NewModelData creates a new ModelData from a models.Table
|
||||||
func NewModelData(table *models.Table, schema string, typeMapper *TypeMapper) *ModelData {
|
func NewModelData(table *models.Table, schema string, typeMapper *TypeMapper, flattenSchema bool) *ModelData {
|
||||||
tableName := table.Name
|
tableName := writers.QualifiedTableName(schema, table.Name, flattenSchema)
|
||||||
if schema != "" {
|
|
||||||
tableName = schema + "." + table.Name
|
|
||||||
}
|
|
||||||
|
|
||||||
// Generate model name: Model + Schema + Table (all PascalCase)
|
// Generate model name: Model + Schema + Table (all PascalCase)
|
||||||
singularTable := Singularize(table.Name)
|
singularTable := Singularize(table.Name)
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ func (w *Writer) writeSingleFile(db *models.Database) error {
|
|||||||
// Collect all models
|
// Collect all models
|
||||||
for _, schema := range db.Schemas {
|
for _, schema := range db.Schemas {
|
||||||
for _, table := range schema.Tables {
|
for _, table := range schema.Tables {
|
||||||
modelData := NewModelData(table, schema.Name, w.typeMapper)
|
modelData := NewModelData(table, schema.Name, w.typeMapper, w.options.FlattenSchema)
|
||||||
|
|
||||||
// Add relationship fields
|
// Add relationship fields
|
||||||
w.addRelationshipFields(modelData, table, schema, db)
|
w.addRelationshipFields(modelData, table, schema, db)
|
||||||
@@ -175,7 +175,7 @@ func (w *Writer) writeMultiFile(db *models.Database) error {
|
|||||||
templateData.AddImport(fmt.Sprintf("sql_types \"%s\"", w.typeMapper.GetSQLTypesImport()))
|
templateData.AddImport(fmt.Sprintf("sql_types \"%s\"", w.typeMapper.GetSQLTypesImport()))
|
||||||
|
|
||||||
// Create model data
|
// Create model data
|
||||||
modelData := NewModelData(table, schema.Name, w.typeMapper)
|
modelData := NewModelData(table, schema.Name, w.typeMapper, w.options.FlattenSchema)
|
||||||
|
|
||||||
// Add relationship fields
|
// Add relationship fields
|
||||||
w.addRelationshipFields(modelData, table, schema, db)
|
w.addRelationshipFields(modelData, table, schema, db)
|
||||||
|
|||||||
217
pkg/writers/pgsql/NAMING_CONVENTIONS.md
Normal file
217
pkg/writers/pgsql/NAMING_CONVENTIONS.md
Normal file
@@ -0,0 +1,217 @@
|
|||||||
|
# PostgreSQL Naming Conventions
|
||||||
|
|
||||||
|
Standardized naming rules for all database objects in RelSpec PostgreSQL output.
|
||||||
|
|
||||||
|
## Quick Reference
|
||||||
|
|
||||||
|
| Object Type | Prefix | Format | Example |
|
||||||
|
| ----------------- | ----------- | ---------------------------------- | ------------------------ |
|
||||||
|
| Primary Key | `pk_` | `pk_<schema>_<table>` | `pk_public_users` |
|
||||||
|
| Foreign Key | `fk_` | `fk_<table>_<referenced_table>` | `fk_posts_users` |
|
||||||
|
| Unique Constraint | `uk_` | `uk_<table>_<column>` | `uk_users_email` |
|
||||||
|
| Unique Index | `uidx_` | `uidx_<table>_<column>` | `uidx_users_email` |
|
||||||
|
| Regular Index | `idx_` | `idx_<table>_<column>` | `idx_posts_user_id` |
|
||||||
|
| Check Constraint | `chk_` | `chk_<table>_<constraint_purpose>` | `chk_users_age_positive` |
|
||||||
|
| Sequence | `identity_` | `identity_<table>_<column>` | `identity_users_id` |
|
||||||
|
| Trigger | `t_` | `t_<purpose>_<table>` | `t_audit_users` |
|
||||||
|
| Trigger Function | `tf_` | `tf_<purpose>_<table>` | `tf_audit_users` |
|
||||||
|
|
||||||
|
## Naming Rules by Object Type
|
||||||
|
|
||||||
|
### Primary Keys
|
||||||
|
|
||||||
|
**Pattern:** `pk_<schema>_<table>`
|
||||||
|
|
||||||
|
- Include schema name to avoid collisions across schemas
|
||||||
|
- Use lowercase, snake_case format
|
||||||
|
- Examples:
|
||||||
|
- `pk_public_users`
|
||||||
|
- `pk_audit_audit_log`
|
||||||
|
- `pk_staging_temp_data`
|
||||||
|
|
||||||
|
### Foreign Keys
|
||||||
|
|
||||||
|
**Pattern:** `fk_<table>_<referenced_table>`
|
||||||
|
|
||||||
|
- Reference the table containing the FK followed by the referenced table
|
||||||
|
- Use lowercase, snake_case format
|
||||||
|
- Do NOT include column names in standard FK constraints
|
||||||
|
- Examples:
|
||||||
|
- `fk_posts_users` (posts.user_id → users.id)
|
||||||
|
- `fk_comments_posts` (comments.post_id → posts.id)
|
||||||
|
- `fk_order_items_orders` (order_items.order_id → orders.id)
|
||||||
|
|
||||||
|
### Unique Constraints
|
||||||
|
|
||||||
|
**Pattern:** `uk_<table>_<column>`
|
||||||
|
|
||||||
|
- Use `uk_` prefix strictly for database constraints (CONSTRAINT type)
|
||||||
|
- Include column name for clarity
|
||||||
|
- Examples:
|
||||||
|
- `uk_users_email`
|
||||||
|
- `uk_users_username`
|
||||||
|
- `uk_products_sku`
|
||||||
|
|
||||||
|
### Unique Indexes
|
||||||
|
|
||||||
|
**Pattern:** `uidx_<table>_<column>`
|
||||||
|
|
||||||
|
- Use `uidx_` prefix strictly for index type objects
|
||||||
|
- Distinguished from constraints for clarity and implementation flexibility
|
||||||
|
- Examples:
|
||||||
|
- `uidx_users_email`
|
||||||
|
- `uidx_sessions_token`
|
||||||
|
- `uidx_api_keys_key`
|
||||||
|
|
||||||
|
### Regular Indexes
|
||||||
|
|
||||||
|
**Pattern:** `idx_<table>_<column>`
|
||||||
|
|
||||||
|
- Standard indexes for query optimization
|
||||||
|
- Single column: `idx_<table>_<column>`
|
||||||
|
- Examples:
|
||||||
|
- `idx_posts_user_id`
|
||||||
|
- `idx_orders_created_at`
|
||||||
|
- `idx_users_status`
|
||||||
|
|
||||||
|
### Check Constraints
|
||||||
|
|
||||||
|
**Pattern:** `chk_<table>_<constraint_purpose>`
|
||||||
|
|
||||||
|
- Describe the constraint validation purpose
|
||||||
|
- Use lowercase, snake_case for the purpose
|
||||||
|
- Examples:
|
||||||
|
- `chk_users_age_positive` (CHECK (age > 0))
|
||||||
|
- `chk_orders_quantity_positive` (CHECK (quantity > 0))
|
||||||
|
- `chk_products_price_valid` (CHECK (price >= 0))
|
||||||
|
- `chk_users_status_enum` (CHECK (status IN ('active', 'inactive')))
|
||||||
|
|
||||||
|
### Sequences
|
||||||
|
|
||||||
|
**Pattern:** `identity_<table>_<column>`
|
||||||
|
|
||||||
|
- Used for SERIAL/IDENTITY columns
|
||||||
|
- Explicitly named for clarity and management
|
||||||
|
- Examples:
|
||||||
|
- `identity_users_id`
|
||||||
|
- `identity_posts_id`
|
||||||
|
- `identity_transactions_id`
|
||||||
|
|
||||||
|
### Triggers
|
||||||
|
|
||||||
|
**Pattern:** `t_<purpose>_<table>`
|
||||||
|
|
||||||
|
- Include purpose before table name
|
||||||
|
- Lowercase, snake_case format
|
||||||
|
- Examples:
|
||||||
|
- `t_audit_users` (audit trigger on users table)
|
||||||
|
- `t_update_timestamp_posts` (timestamp update trigger on posts)
|
||||||
|
- `t_validate_orders` (validation trigger on orders)
|
||||||
|
|
||||||
|
### Trigger Functions
|
||||||
|
|
||||||
|
**Pattern:** `tf_<purpose>_<table>`
|
||||||
|
|
||||||
|
- Pair with trigger naming convention
|
||||||
|
- Use `tf_` prefix to distinguish from triggers themselves
|
||||||
|
- Examples:
|
||||||
|
- `tf_audit_users` (function for t_audit_users)
|
||||||
|
- `tf_update_timestamp_posts` (function for t_update_timestamp_posts)
|
||||||
|
- `tf_validate_orders` (function for t_validate_orders)
|
||||||
|
|
||||||
|
## Multi-Column Objects
|
||||||
|
|
||||||
|
### Composite Primary Keys
|
||||||
|
|
||||||
|
**Pattern:** `pk_<schema>_<table>`
|
||||||
|
|
||||||
|
- Same as single-column PKs
|
||||||
|
- Example: `pk_public_order_items` (composite key on order_id + item_id)
|
||||||
|
|
||||||
|
### Composite Unique Constraints
|
||||||
|
|
||||||
|
**Pattern:** `uk_<table>_<column1>_<column2>_[...]`
|
||||||
|
|
||||||
|
- Append all column names in order
|
||||||
|
- Examples:
|
||||||
|
- `uk_users_email_domain` (UNIQUE(email, domain))
|
||||||
|
- `uk_inventory_warehouse_sku` (UNIQUE(warehouse_id, sku))
|
||||||
|
|
||||||
|
### Composite Unique Indexes
|
||||||
|
|
||||||
|
**Pattern:** `uidx_<table>_<column1>_<column2>_[...]`
|
||||||
|
|
||||||
|
- Append all column names in order
|
||||||
|
- Examples:
|
||||||
|
- `uidx_users_first_name_last_name` (UNIQUE INDEX on first_name, last_name)
|
||||||
|
- `uidx_sessions_user_id_device_id` (UNIQUE INDEX on user_id, device_id)
|
||||||
|
|
||||||
|
### Composite Regular Indexes
|
||||||
|
|
||||||
|
**Pattern:** `idx_<table>_<column1>_<column2>_[...]`
|
||||||
|
|
||||||
|
- Append all column names in order
|
||||||
|
- List columns in typical query filter order
|
||||||
|
- Examples:
|
||||||
|
- `idx_orders_user_id_created_at` (filter by user, then sort by created_at)
|
||||||
|
- `idx_logs_level_timestamp` (filter by level, then by timestamp)
|
||||||
|
|
||||||
|
## Special Cases & Conventions
|
||||||
|
|
||||||
|
### Audit Trail Tables
|
||||||
|
|
||||||
|
- Audit table naming: `<original_table>_audit` or `audit_<original_table>`
|
||||||
|
- Audit indexes follow standard pattern: `idx_<audit_table>_<column>`
|
||||||
|
- Examples:
|
||||||
|
- Users table audit: `users_audit` with `idx_users_audit_tablename`, `idx_users_audit_changedate`
|
||||||
|
- Posts table audit: `posts_audit` with `idx_posts_audit_tablename`, `idx_posts_audit_changedate`
|
||||||
|
|
||||||
|
### Temporal/Versioning Tables
|
||||||
|
|
||||||
|
- Use suffix `_history` or `_versions` if needed
|
||||||
|
- Apply standard naming rules with the full table name
|
||||||
|
- Examples:
|
||||||
|
- `idx_users_history_user_id`
|
||||||
|
- `uk_posts_versions_version_number`
|
||||||
|
|
||||||
|
### Schema-Specific Objects
|
||||||
|
|
||||||
|
- Always qualify with schema when needed: `pk_<schema>_<table>`
|
||||||
|
- Multiple schemas allowed: `pk_public_users`, `pk_staging_users`
|
||||||
|
|
||||||
|
### Reserved Words & Special Names
|
||||||
|
|
||||||
|
- Avoid PostgreSQL reserved keywords in object names
|
||||||
|
- If column/table names conflict, use quoted identifiers in DDL
|
||||||
|
- Naming convention rules still apply to the logical name
|
||||||
|
|
||||||
|
### Generated/Anonymous Indexes
|
||||||
|
|
||||||
|
- If an index lacks explicit naming, default to: `idx_<schema>_<table>`
|
||||||
|
- Should be replaced with explicit names following standards
|
||||||
|
- Examples (to be renamed):
|
||||||
|
- `idx_public_users` → should be `idx_users_<column>`
|
||||||
|
|
||||||
|
## Implementation Notes
|
||||||
|
|
||||||
|
### Code Generation
|
||||||
|
|
||||||
|
- Names are always lowercase in generated SQL
|
||||||
|
- Underscore separators are required
|
||||||
|
|
||||||
|
### Migration Safety
|
||||||
|
|
||||||
|
- Do NOT rename objects after creation without explicit migration
|
||||||
|
- Names should be consistent across all schema versions
|
||||||
|
- Test generated DDL against PostgreSQL before deployment
|
||||||
|
|
||||||
|
### Testing
|
||||||
|
|
||||||
|
- Ensure consistency across all table and constraint generation
|
||||||
|
- Test with reserved words to verify escaping
|
||||||
|
|
||||||
|
## Related Documentation
|
||||||
|
|
||||||
|
- PostgreSQL Identifier Rules: https://www.postgresql.org/docs/current/sql-syntax-lexical.html#SQL-IDENTIFIERS
|
||||||
|
- Constraint Documentation: https://www.postgresql.org/docs/current/ddl-constraints.html
|
||||||
|
- Index Documentation: https://www.postgresql.org/docs/current/indexes.html
|
||||||
@@ -8,6 +8,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"git.warky.dev/wdevs/relspecgo/pkg/models"
|
"git.warky.dev/wdevs/relspecgo/pkg/models"
|
||||||
|
"git.warky.dev/wdevs/relspecgo/pkg/pgsql"
|
||||||
"git.warky.dev/wdevs/relspecgo/pkg/writers"
|
"git.warky.dev/wdevs/relspecgo/pkg/writers"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -30,7 +31,7 @@ type MigrationWriter struct {
|
|||||||
|
|
||||||
// NewMigrationWriter creates a new templated migration writer
|
// NewMigrationWriter creates a new templated migration writer
|
||||||
func NewMigrationWriter(options *writers.WriterOptions) (*MigrationWriter, error) {
|
func NewMigrationWriter(options *writers.WriterOptions) (*MigrationWriter, error) {
|
||||||
executor, err := NewTemplateExecutor()
|
executor, err := NewTemplateExecutor(options.FlattenSchema)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to create template executor: %w", err)
|
return nil, fmt.Errorf("failed to create template executor: %w", err)
|
||||||
}
|
}
|
||||||
@@ -335,7 +336,7 @@ func (w *MigrationWriter) generateAlterTableScripts(schema *models.Schema, model
|
|||||||
SchemaName: schema.Name,
|
SchemaName: schema.Name,
|
||||||
TableName: modelTable.Name,
|
TableName: modelTable.Name,
|
||||||
ColumnName: modelCol.Name,
|
ColumnName: modelCol.Name,
|
||||||
ColumnType: modelCol.Type,
|
ColumnType: pgsql.ConvertSQLType(modelCol.Type),
|
||||||
Default: defaultVal,
|
Default: defaultVal,
|
||||||
NotNull: modelCol.NotNull,
|
NotNull: modelCol.NotNull,
|
||||||
})
|
})
|
||||||
@@ -359,7 +360,7 @@ func (w *MigrationWriter) generateAlterTableScripts(schema *models.Schema, model
|
|||||||
SchemaName: schema.Name,
|
SchemaName: schema.Name,
|
||||||
TableName: modelTable.Name,
|
TableName: modelTable.Name,
|
||||||
ColumnName: modelCol.Name,
|
ColumnName: modelCol.Name,
|
||||||
NewType: modelCol.Type,
|
NewType: pgsql.ConvertSQLType(modelCol.Type),
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -427,9 +428,11 @@ func (w *MigrationWriter) generateIndexScripts(model *models.Schema, current *mo
|
|||||||
for _, modelTable := range model.Tables {
|
for _, modelTable := range model.Tables {
|
||||||
currentTable := currentTables[strings.ToLower(modelTable.Name)]
|
currentTable := currentTables[strings.ToLower(modelTable.Name)]
|
||||||
|
|
||||||
// Process primary keys first
|
// Process primary keys first - check explicit constraints
|
||||||
|
foundExplicitPK := false
|
||||||
for constraintName, constraint := range modelTable.Constraints {
|
for constraintName, constraint := range modelTable.Constraints {
|
||||||
if constraint.Type == models.PrimaryKeyConstraint {
|
if constraint.Type == models.PrimaryKeyConstraint {
|
||||||
|
foundExplicitPK = true
|
||||||
shouldCreate := true
|
shouldCreate := true
|
||||||
|
|
||||||
if currentTable != nil {
|
if currentTable != nil {
|
||||||
@@ -464,6 +467,53 @@ func (w *MigrationWriter) generateIndexScripts(model *models.Schema, current *mo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If no explicit PK constraint, check for columns with IsPrimaryKey = true
|
||||||
|
if !foundExplicitPK {
|
||||||
|
pkColumns := []string{}
|
||||||
|
for _, col := range modelTable.Columns {
|
||||||
|
if col.IsPrimaryKey {
|
||||||
|
pkColumns = append(pkColumns, col.SQLName())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if len(pkColumns) > 0 {
|
||||||
|
sort.Strings(pkColumns)
|
||||||
|
constraintName := fmt.Sprintf("pk_%s_%s", model.SQLName(), modelTable.SQLName())
|
||||||
|
shouldCreate := true
|
||||||
|
|
||||||
|
if currentTable != nil {
|
||||||
|
// Check if a PK constraint already exists (by any name)
|
||||||
|
for _, constraint := range currentTable.Constraints {
|
||||||
|
if constraint.Type == models.PrimaryKeyConstraint {
|
||||||
|
shouldCreate = false
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if shouldCreate {
|
||||||
|
sql, err := w.executor.ExecuteCreatePrimaryKey(CreatePrimaryKeyData{
|
||||||
|
SchemaName: model.Name,
|
||||||
|
TableName: modelTable.Name,
|
||||||
|
ConstraintName: constraintName,
|
||||||
|
Columns: strings.Join(pkColumns, ", "),
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
script := MigrationScript{
|
||||||
|
ObjectName: fmt.Sprintf("%s.%s.%s", model.Name, modelTable.Name, constraintName),
|
||||||
|
ObjectType: "create primary key",
|
||||||
|
Schema: model.Name,
|
||||||
|
Priority: 160,
|
||||||
|
Sequence: len(scripts),
|
||||||
|
Body: sql,
|
||||||
|
}
|
||||||
|
scripts = append(scripts, script)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Process indexes
|
// Process indexes
|
||||||
for indexName, modelIndex := range modelTable.Indexes {
|
for indexName, modelIndex := range modelTable.Indexes {
|
||||||
// Skip primary key indexes
|
// Skip primary key indexes
|
||||||
@@ -703,7 +753,7 @@ func (w *MigrationWriter) generateAuditScripts(schema *models.Schema, auditConfi
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Generate audit function
|
// Generate audit function
|
||||||
funcName := fmt.Sprintf("ft_audit_%s", table.Name)
|
funcName := fmt.Sprintf("tf_audit_%s", table.Name)
|
||||||
funcData := BuildAuditFunctionData(schema.Name, table, pk, config, auditSchema, auditConfig.UserFunction)
|
funcData := BuildAuditFunctionData(schema.Name, table, pk, config, auditSchema, auditConfig.UserFunction)
|
||||||
|
|
||||||
funcSQL, err := w.executor.ExecuteAuditFunction(funcData)
|
funcSQL, err := w.executor.ExecuteAuditFunction(funcData)
|
||||||
|
|||||||
@@ -121,7 +121,7 @@ func TestWriteMigration_WithAudit(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Verify audit function
|
// Verify audit function
|
||||||
if !strings.Contains(output, "CREATE OR REPLACE FUNCTION public.ft_audit_users()") {
|
if !strings.Contains(output, "CREATE OR REPLACE FUNCTION public.tf_audit_users()") {
|
||||||
t.Error("Migration missing audit function")
|
t.Error("Migration missing audit function")
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -137,7 +137,7 @@ func TestWriteMigration_WithAudit(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestTemplateExecutor_CreateTable(t *testing.T) {
|
func TestTemplateExecutor_CreateTable(t *testing.T) {
|
||||||
executor, err := NewTemplateExecutor()
|
executor, err := NewTemplateExecutor(false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Failed to create executor: %v", err)
|
t.Fatalf("Failed to create executor: %v", err)
|
||||||
}
|
}
|
||||||
@@ -170,14 +170,14 @@ func TestTemplateExecutor_CreateTable(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestTemplateExecutor_AuditFunction(t *testing.T) {
|
func TestTemplateExecutor_AuditFunction(t *testing.T) {
|
||||||
executor, err := NewTemplateExecutor()
|
executor, err := NewTemplateExecutor(false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Failed to create executor: %v", err)
|
t.Fatalf("Failed to create executor: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
data := AuditFunctionData{
|
data := AuditFunctionData{
|
||||||
SchemaName: "public",
|
SchemaName: "public",
|
||||||
FunctionName: "ft_audit_users",
|
FunctionName: "tf_audit_users",
|
||||||
TableName: "users",
|
TableName: "users",
|
||||||
TablePrefix: "NULL",
|
TablePrefix: "NULL",
|
||||||
PrimaryKey: "id",
|
PrimaryKey: "id",
|
||||||
@@ -202,7 +202,7 @@ func TestTemplateExecutor_AuditFunction(t *testing.T) {
|
|||||||
|
|
||||||
t.Logf("Generated SQL:\n%s", sql)
|
t.Logf("Generated SQL:\n%s", sql)
|
||||||
|
|
||||||
if !strings.Contains(sql, "CREATE OR REPLACE FUNCTION public.ft_audit_users()") {
|
if !strings.Contains(sql, "CREATE OR REPLACE FUNCTION public.tf_audit_users()") {
|
||||||
t.Error("SQL missing function definition")
|
t.Error("SQL missing function definition")
|
||||||
}
|
}
|
||||||
if !strings.Contains(sql, "IF TG_OP = 'INSERT'") {
|
if !strings.Contains(sql, "IF TG_OP = 'INSERT'") {
|
||||||
@@ -215,3 +215,70 @@ func TestTemplateExecutor_AuditFunction(t *testing.T) {
|
|||||||
t.Error("SQL missing DELETE handling")
|
t.Error("SQL missing DELETE handling")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestWriteMigration_NumericConstraintNames(t *testing.T) {
|
||||||
|
// Current database (empty)
|
||||||
|
current := models.InitDatabase("testdb")
|
||||||
|
currentSchema := models.InitSchema("entity")
|
||||||
|
current.Schemas = append(current.Schemas, currentSchema)
|
||||||
|
|
||||||
|
// Model database (with constraint starting with number)
|
||||||
|
model := models.InitDatabase("testdb")
|
||||||
|
modelSchema := models.InitSchema("entity")
|
||||||
|
|
||||||
|
// Create individual_actor_relationship table
|
||||||
|
table := models.InitTable("individual_actor_relationship", "entity")
|
||||||
|
idCol := models.InitColumn("id", "individual_actor_relationship", "entity")
|
||||||
|
idCol.Type = "integer"
|
||||||
|
idCol.IsPrimaryKey = true
|
||||||
|
table.Columns["id"] = idCol
|
||||||
|
|
||||||
|
actorIDCol := models.InitColumn("actor_id", "individual_actor_relationship", "entity")
|
||||||
|
actorIDCol.Type = "integer"
|
||||||
|
table.Columns["actor_id"] = actorIDCol
|
||||||
|
|
||||||
|
// Add constraint with name starting with number
|
||||||
|
constraint := &models.Constraint{
|
||||||
|
Name: "215162_fk_actor",
|
||||||
|
Type: models.ForeignKeyConstraint,
|
||||||
|
Columns: []string{"actor_id"},
|
||||||
|
ReferencedSchema: "entity",
|
||||||
|
ReferencedTable: "actor",
|
||||||
|
ReferencedColumns: []string{"id"},
|
||||||
|
OnDelete: "CASCADE",
|
||||||
|
OnUpdate: "NO ACTION",
|
||||||
|
}
|
||||||
|
table.Constraints["215162_fk_actor"] = constraint
|
||||||
|
|
||||||
|
modelSchema.Tables = append(modelSchema.Tables, table)
|
||||||
|
model.Schemas = append(model.Schemas, modelSchema)
|
||||||
|
|
||||||
|
// Generate migration
|
||||||
|
var buf bytes.Buffer
|
||||||
|
writer, err := NewMigrationWriter(&writers.WriterOptions{})
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Failed to create writer: %v", err)
|
||||||
|
}
|
||||||
|
writer.writer = &buf
|
||||||
|
|
||||||
|
err = writer.WriteMigration(model, current)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("WriteMigration failed: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
output := buf.String()
|
||||||
|
t.Logf("Generated migration:\n%s", output)
|
||||||
|
|
||||||
|
// Verify constraint name is properly quoted
|
||||||
|
if !strings.Contains(output, `"215162_fk_actor"`) {
|
||||||
|
t.Error("Constraint name starting with number should be quoted")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Verify the SQL is syntactically correct (contains required keywords)
|
||||||
|
if !strings.Contains(output, "ADD CONSTRAINT") {
|
||||||
|
t.Error("Migration missing ADD CONSTRAINT")
|
||||||
|
}
|
||||||
|
if !strings.Contains(output, "FOREIGN KEY") {
|
||||||
|
t.Error("Migration missing FOREIGN KEY")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ func TemplateFunctions() map[string]interface{} {
|
|||||||
"quote": quote,
|
"quote": quote,
|
||||||
"escape": escape,
|
"escape": escape,
|
||||||
"safe_identifier": safeIdentifier,
|
"safe_identifier": safeIdentifier,
|
||||||
|
"quote_ident": quoteIdent,
|
||||||
|
|
||||||
// Type conversion
|
// Type conversion
|
||||||
"goTypeToSQL": goTypeToSQL,
|
"goTypeToSQL": goTypeToSQL,
|
||||||
@@ -122,6 +123,43 @@ func safeIdentifier(s string) string {
|
|||||||
return strings.ToLower(safe)
|
return strings.ToLower(safe)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// quoteIdent quotes a PostgreSQL identifier if necessary
|
||||||
|
// Identifiers need quoting if they:
|
||||||
|
// - Start with a digit
|
||||||
|
// - Contain special characters
|
||||||
|
// - Are reserved keywords
|
||||||
|
// - Contain uppercase letters (to preserve case)
|
||||||
|
func quoteIdent(s string) string {
|
||||||
|
if s == "" {
|
||||||
|
return `""`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if quoting is needed
|
||||||
|
needsQuoting := unicode.IsDigit(rune(s[0]))
|
||||||
|
|
||||||
|
// Starts with digit
|
||||||
|
|
||||||
|
// Contains uppercase letters or special characters
|
||||||
|
for _, r := range s {
|
||||||
|
if unicode.IsUpper(r) {
|
||||||
|
needsQuoting = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
if !unicode.IsLetter(r) && !unicode.IsDigit(r) && r != '_' {
|
||||||
|
needsQuoting = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if needsQuoting {
|
||||||
|
// Escape double quotes by doubling them
|
||||||
|
escaped := strings.ReplaceAll(s, `"`, `""`)
|
||||||
|
return `"` + escaped + `"`
|
||||||
|
}
|
||||||
|
|
||||||
|
return s
|
||||||
|
}
|
||||||
|
|
||||||
// Type conversion functions
|
// Type conversion functions
|
||||||
|
|
||||||
// goTypeToSQL converts Go type to PostgreSQL type
|
// goTypeToSQL converts Go type to PostgreSQL type
|
||||||
|
|||||||
@@ -101,6 +101,31 @@ func TestSafeIdentifier(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestQuoteIdent(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
input string
|
||||||
|
expected string
|
||||||
|
}{
|
||||||
|
{"valid_name", "valid_name"},
|
||||||
|
{"ValidName", `"ValidName"`},
|
||||||
|
{"123column", `"123column"`},
|
||||||
|
{"215162_fk_constraint", `"215162_fk_constraint"`},
|
||||||
|
{"user-id", `"user-id"`},
|
||||||
|
{"user@domain", `"user@domain"`},
|
||||||
|
{`"quoted"`, `"""quoted"""`},
|
||||||
|
{"", `""`},
|
||||||
|
{"lowercase", "lowercase"},
|
||||||
|
{"with_underscore", "with_underscore"},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
result := quoteIdent(tt.input)
|
||||||
|
if result != tt.expected {
|
||||||
|
t.Errorf("quoteIdent(%q) = %q, want %q", tt.input, result, tt.expected)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestGoTypeToSQL(t *testing.T) {
|
func TestGoTypeToSQL(t *testing.T) {
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
input string
|
input string
|
||||||
@@ -243,7 +268,7 @@ func TestTemplateFunctions(t *testing.T) {
|
|||||||
// Check that all expected functions are registered
|
// Check that all expected functions are registered
|
||||||
expectedFuncs := []string{
|
expectedFuncs := []string{
|
||||||
"upper", "lower", "snake_case", "camelCase",
|
"upper", "lower", "snake_case", "camelCase",
|
||||||
"indent", "quote", "escape", "safe_identifier",
|
"indent", "quote", "escape", "safe_identifier", "quote_ident",
|
||||||
"goTypeToSQL", "sqlTypeToGo", "isNumeric", "isText",
|
"goTypeToSQL", "sqlTypeToGo", "isNumeric", "isText",
|
||||||
"first", "last", "filter", "mapFunc", "join_with",
|
"first", "last", "filter", "mapFunc", "join_with",
|
||||||
"join",
|
"join",
|
||||||
@@ -289,7 +314,7 @@ func TestFormatType(t *testing.T) {
|
|||||||
|
|
||||||
// Test that template functions work in actual templates
|
// Test that template functions work in actual templates
|
||||||
func TestTemplateFunctionsInTemplate(t *testing.T) {
|
func TestTemplateFunctionsInTemplate(t *testing.T) {
|
||||||
executor, err := NewTemplateExecutor()
|
executor, err := NewTemplateExecutor(false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Failed to create executor: %v", err)
|
t.Fatalf("Failed to create executor: %v", err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,14 +18,39 @@ type TemplateExecutor struct {
|
|||||||
templates *template.Template
|
templates *template.Template
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewTemplateExecutor creates a new template executor
|
// NewTemplateExecutor creates a new template executor.
|
||||||
func NewTemplateExecutor() (*TemplateExecutor, error) {
|
// flattenSchema controls whether schema.table identifiers use dot or underscore separation.
|
||||||
|
func NewTemplateExecutor(flattenSchema bool) (*TemplateExecutor, error) {
|
||||||
// Create template with custom functions
|
// Create template with custom functions
|
||||||
funcMap := make(template.FuncMap)
|
funcMap := make(template.FuncMap)
|
||||||
for k, v := range TemplateFunctions() {
|
for k, v := range TemplateFunctions() {
|
||||||
funcMap[k] = v
|
funcMap[k] = v
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// qual_table returns a quoted, schema-qualified identifier.
|
||||||
|
// With flatten=false: "schema"."table" (or unquoted equivalents).
|
||||||
|
// With flatten=true: "schema_table".
|
||||||
|
funcMap["qual_table"] = func(schema, name string) string {
|
||||||
|
if schema == "" {
|
||||||
|
return quoteIdent(name)
|
||||||
|
}
|
||||||
|
if flattenSchema {
|
||||||
|
return quoteIdent(schema + "_" + name)
|
||||||
|
}
|
||||||
|
return quoteIdent(schema) + "." + quoteIdent(name)
|
||||||
|
}
|
||||||
|
|
||||||
|
// qual_table_raw is the same as qual_table but without identifier quoting.
|
||||||
|
funcMap["qual_table_raw"] = func(schema, name string) string {
|
||||||
|
if schema == "" {
|
||||||
|
return name
|
||||||
|
}
|
||||||
|
if flattenSchema {
|
||||||
|
return schema + "_" + name
|
||||||
|
}
|
||||||
|
return schema + "." + name
|
||||||
|
}
|
||||||
|
|
||||||
tmpl, err := template.New("").Funcs(funcMap).ParseFS(templateFS, "templates/*.tmpl")
|
tmpl, err := template.New("").Funcs(funcMap).ParseFS(templateFS, "templates/*.tmpl")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to parse templates: %w", err)
|
return nil, fmt.Errorf("failed to parse templates: %w", err)
|
||||||
@@ -177,6 +202,72 @@ type AuditTriggerData struct {
|
|||||||
Events string
|
Events string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CreateUniqueConstraintData contains data for create unique constraint template
|
||||||
|
type CreateUniqueConstraintData struct {
|
||||||
|
SchemaName string
|
||||||
|
TableName string
|
||||||
|
ConstraintName string
|
||||||
|
Columns string
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateCheckConstraintData contains data for create check constraint template
|
||||||
|
type CreateCheckConstraintData struct {
|
||||||
|
SchemaName string
|
||||||
|
TableName string
|
||||||
|
ConstraintName string
|
||||||
|
Expression string
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateForeignKeyWithCheckData contains data for create foreign key with existence check template
|
||||||
|
type CreateForeignKeyWithCheckData struct {
|
||||||
|
SchemaName string
|
||||||
|
TableName string
|
||||||
|
ConstraintName string
|
||||||
|
SourceColumns string
|
||||||
|
TargetSchema string
|
||||||
|
TargetTable string
|
||||||
|
TargetColumns string
|
||||||
|
OnDelete string
|
||||||
|
OnUpdate string
|
||||||
|
Deferrable bool
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetSequenceValueData contains data for set sequence value template
|
||||||
|
type SetSequenceValueData struct {
|
||||||
|
SchemaName string
|
||||||
|
TableName string
|
||||||
|
SequenceName string
|
||||||
|
ColumnName string
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateSequenceData contains data for create sequence template
|
||||||
|
type CreateSequenceData struct {
|
||||||
|
SchemaName string
|
||||||
|
SequenceName string
|
||||||
|
Increment int
|
||||||
|
MinValue int64
|
||||||
|
MaxValue int64
|
||||||
|
StartValue int64
|
||||||
|
CacheSize int
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddColumnWithCheckData contains data for add column with existence check template
|
||||||
|
type AddColumnWithCheckData struct {
|
||||||
|
SchemaName string
|
||||||
|
TableName string
|
||||||
|
ColumnName string
|
||||||
|
ColumnDefinition string
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreatePrimaryKeyWithAutoGenCheckData contains data for primary key with auto-generated key check template
|
||||||
|
type CreatePrimaryKeyWithAutoGenCheckData struct {
|
||||||
|
SchemaName string
|
||||||
|
TableName string
|
||||||
|
ConstraintName string
|
||||||
|
AutoGenNames string // Comma-separated list of names like "'name1', 'name2'"
|
||||||
|
Columns string
|
||||||
|
}
|
||||||
|
|
||||||
// Execute methods for each template
|
// Execute methods for each template
|
||||||
|
|
||||||
// ExecuteCreateTable executes the create table template
|
// ExecuteCreateTable executes the create table template
|
||||||
@@ -319,6 +410,76 @@ func (te *TemplateExecutor) ExecuteAuditTrigger(data AuditTriggerData) (string,
|
|||||||
return buf.String(), nil
|
return buf.String(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ExecuteCreateUniqueConstraint executes the create unique constraint template
|
||||||
|
func (te *TemplateExecutor) ExecuteCreateUniqueConstraint(data CreateUniqueConstraintData) (string, error) {
|
||||||
|
var buf bytes.Buffer
|
||||||
|
err := te.templates.ExecuteTemplate(&buf, "create_unique_constraint.tmpl", data)
|
||||||
|
if err != nil {
|
||||||
|
return "", fmt.Errorf("failed to execute create_unique_constraint template: %w", err)
|
||||||
|
}
|
||||||
|
return buf.String(), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExecuteCreateCheckConstraint executes the create check constraint template
|
||||||
|
func (te *TemplateExecutor) ExecuteCreateCheckConstraint(data CreateCheckConstraintData) (string, error) {
|
||||||
|
var buf bytes.Buffer
|
||||||
|
err := te.templates.ExecuteTemplate(&buf, "create_check_constraint.tmpl", data)
|
||||||
|
if err != nil {
|
||||||
|
return "", fmt.Errorf("failed to execute create_check_constraint template: %w", err)
|
||||||
|
}
|
||||||
|
return buf.String(), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExecuteCreateForeignKeyWithCheck executes the create foreign key with check template
|
||||||
|
func (te *TemplateExecutor) ExecuteCreateForeignKeyWithCheck(data CreateForeignKeyWithCheckData) (string, error) {
|
||||||
|
var buf bytes.Buffer
|
||||||
|
err := te.templates.ExecuteTemplate(&buf, "create_foreign_key_with_check.tmpl", data)
|
||||||
|
if err != nil {
|
||||||
|
return "", fmt.Errorf("failed to execute create_foreign_key_with_check template: %w", err)
|
||||||
|
}
|
||||||
|
return buf.String(), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExecuteSetSequenceValue executes the set sequence value template
|
||||||
|
func (te *TemplateExecutor) ExecuteSetSequenceValue(data SetSequenceValueData) (string, error) {
|
||||||
|
var buf bytes.Buffer
|
||||||
|
err := te.templates.ExecuteTemplate(&buf, "set_sequence_value.tmpl", data)
|
||||||
|
if err != nil {
|
||||||
|
return "", fmt.Errorf("failed to execute set_sequence_value template: %w", err)
|
||||||
|
}
|
||||||
|
return buf.String(), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExecuteCreateSequence executes the create sequence template
|
||||||
|
func (te *TemplateExecutor) ExecuteCreateSequence(data CreateSequenceData) (string, error) {
|
||||||
|
var buf bytes.Buffer
|
||||||
|
err := te.templates.ExecuteTemplate(&buf, "create_sequence.tmpl", data)
|
||||||
|
if err != nil {
|
||||||
|
return "", fmt.Errorf("failed to execute create_sequence template: %w", err)
|
||||||
|
}
|
||||||
|
return buf.String(), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExecuteAddColumnWithCheck executes the add column with check template
|
||||||
|
func (te *TemplateExecutor) ExecuteAddColumnWithCheck(data AddColumnWithCheckData) (string, error) {
|
||||||
|
var buf bytes.Buffer
|
||||||
|
err := te.templates.ExecuteTemplate(&buf, "add_column_with_check.tmpl", data)
|
||||||
|
if err != nil {
|
||||||
|
return "", fmt.Errorf("failed to execute add_column_with_check template: %w", err)
|
||||||
|
}
|
||||||
|
return buf.String(), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExecuteCreatePrimaryKeyWithAutoGenCheck executes the create primary key with auto-generated key check template
|
||||||
|
func (te *TemplateExecutor) ExecuteCreatePrimaryKeyWithAutoGenCheck(data CreatePrimaryKeyWithAutoGenCheckData) (string, error) {
|
||||||
|
var buf bytes.Buffer
|
||||||
|
err := te.templates.ExecuteTemplate(&buf, "create_primary_key_with_autogen_check.tmpl", data)
|
||||||
|
if err != nil {
|
||||||
|
return "", fmt.Errorf("failed to execute create_primary_key_with_autogen_check template: %w", err)
|
||||||
|
}
|
||||||
|
return buf.String(), nil
|
||||||
|
}
|
||||||
|
|
||||||
// Helper functions to build template data from models
|
// Helper functions to build template data from models
|
||||||
|
|
||||||
// BuildCreateTableData builds CreateTableData from a models.Table
|
// BuildCreateTableData builds CreateTableData from a models.Table
|
||||||
@@ -355,7 +516,7 @@ func BuildAuditFunctionData(
|
|||||||
auditSchema string,
|
auditSchema string,
|
||||||
userFunction string,
|
userFunction string,
|
||||||
) AuditFunctionData {
|
) AuditFunctionData {
|
||||||
funcName := fmt.Sprintf("ft_audit_%s", table.Name)
|
funcName := fmt.Sprintf("tf_audit_%s", table.Name)
|
||||||
|
|
||||||
// Build list of audited columns
|
// Build list of audited columns
|
||||||
auditedColumns := make([]*models.Column, 0)
|
auditedColumns := make([]*models.Column, 0)
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
ALTER TABLE {{.SchemaName}}.{{.TableName}}
|
ALTER TABLE {{qual_table .SchemaName .TableName}}
|
||||||
ADD COLUMN IF NOT EXISTS {{.ColumnName}} {{.ColumnType}}
|
ADD COLUMN IF NOT EXISTS {{quote_ident .ColumnName}} {{.ColumnType}}
|
||||||
{{- if .Default}} DEFAULT {{.Default}}{{end}}
|
{{- if .Default}} DEFAULT {{.Default}}{{end}}
|
||||||
{{- if .NotNull}} NOT NULL{{end}};
|
{{- if .NotNull}} NOT NULL{{end}};
|
||||||
12
pkg/writers/pgsql/templates/add_column_with_check.tmpl
Normal file
12
pkg/writers/pgsql/templates/add_column_with_check.tmpl
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
DO $$
|
||||||
|
BEGIN
|
||||||
|
IF NOT EXISTS (
|
||||||
|
SELECT 1 FROM information_schema.columns
|
||||||
|
WHERE table_schema = '{{.SchemaName}}'
|
||||||
|
AND table_name = '{{.TableName}}'
|
||||||
|
AND column_name = '{{.ColumnName}}'
|
||||||
|
) THEN
|
||||||
|
ALTER TABLE {{qual_table .SchemaName .TableName}} ADD COLUMN {{.ColumnDefinition}};
|
||||||
|
END IF;
|
||||||
|
END;
|
||||||
|
$$;
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
{{- if .SetDefault -}}
|
{{- if .SetDefault -}}
|
||||||
ALTER TABLE {{.SchemaName}}.{{.TableName}}
|
ALTER TABLE {{qual_table .SchemaName .TableName}}
|
||||||
ALTER COLUMN {{.ColumnName}} SET DEFAULT {{.DefaultValue}};
|
ALTER COLUMN {{quote_ident .ColumnName}} SET DEFAULT {{.DefaultValue}};
|
||||||
{{- else -}}
|
{{- else -}}
|
||||||
ALTER TABLE {{.SchemaName}}.{{.TableName}}
|
ALTER TABLE {{qual_table .SchemaName .TableName}}
|
||||||
ALTER COLUMN {{.ColumnName}} DROP DEFAULT;
|
ALTER COLUMN {{quote_ident .ColumnName}} DROP DEFAULT;
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
@@ -1,2 +1,2 @@
|
|||||||
ALTER TABLE {{.SchemaName}}.{{.TableName}}
|
ALTER TABLE {{qual_table .SchemaName .TableName}}
|
||||||
ALTER COLUMN {{.ColumnName}} TYPE {{.NewType}};
|
ALTER COLUMN {{quote_ident .ColumnName}} TYPE {{.NewType}};
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
CREATE OR REPLACE FUNCTION {{.SchemaName}}.{{.FunctionName}}()
|
CREATE OR REPLACE FUNCTION {{qual_table_raw .SchemaName .FunctionName}}()
|
||||||
RETURNS trigger AS
|
RETURNS trigger AS
|
||||||
$body$
|
$body$
|
||||||
DECLARE
|
DECLARE
|
||||||
@@ -81,4 +81,4 @@ LANGUAGE plpgsql
|
|||||||
VOLATILE
|
VOLATILE
|
||||||
SECURITY DEFINER;
|
SECURITY DEFINER;
|
||||||
|
|
||||||
COMMENT ON FUNCTION {{.SchemaName}}.{{.FunctionName}}() IS 'Audit trigger function for table {{.SchemaName}}.{{.TableName}}';
|
COMMENT ON FUNCTION {{qual_table_raw .SchemaName .FunctionName}}() IS 'Audit trigger function for table {{qual_table_raw .SchemaName .TableName}}';
|
||||||
@@ -4,13 +4,13 @@ BEGIN
|
|||||||
SELECT 1
|
SELECT 1
|
||||||
FROM pg_trigger
|
FROM pg_trigger
|
||||||
WHERE tgname = '{{.TriggerName}}'
|
WHERE tgname = '{{.TriggerName}}'
|
||||||
AND tgrelid = '{{.SchemaName}}.{{.TableName}}'::regclass
|
AND tgrelid = '{{qual_table_raw .SchemaName .TableName}}'::regclass
|
||||||
) THEN
|
) THEN
|
||||||
CREATE TRIGGER {{.TriggerName}}
|
CREATE TRIGGER {{.TriggerName}}
|
||||||
AFTER {{.Events}}
|
AFTER {{.Events}}
|
||||||
ON {{.SchemaName}}.{{.TableName}}
|
ON {{qual_table_raw .SchemaName .TableName}}
|
||||||
FOR EACH ROW
|
FOR EACH ROW
|
||||||
EXECUTE FUNCTION {{.SchemaName}}.{{.FunctionName}}();
|
EXECUTE FUNCTION {{qual_table_raw .SchemaName .FunctionName}}();
|
||||||
END IF;
|
END IF;
|
||||||
END;
|
END;
|
||||||
$$;
|
$$;
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
{{/* Base constraint template */}}
|
{{/* Base constraint template */}}
|
||||||
{{- define "constraint_base" -}}
|
{{- define "constraint_base" -}}
|
||||||
ALTER TABLE {{.SchemaName}}.{{.TableName}}
|
ALTER TABLE {{qual_table_raw .SchemaName .TableName}}
|
||||||
ADD CONSTRAINT {{.ConstraintName}}
|
ADD CONSTRAINT {{.ConstraintName}}
|
||||||
{{block "constraint_definition" .}}{{end}};
|
{{block "constraint_definition" .}}{{end}};
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
@@ -15,7 +15,7 @@ BEGIN
|
|||||||
AND table_name = '{{.TableName}}'
|
AND table_name = '{{.TableName}}'
|
||||||
AND constraint_name = '{{.ConstraintName}}'
|
AND constraint_name = '{{.ConstraintName}}'
|
||||||
) THEN
|
) THEN
|
||||||
ALTER TABLE {{.SchemaName}}.{{.TableName}}
|
ALTER TABLE {{qual_table_raw .SchemaName .TableName}}
|
||||||
DROP CONSTRAINT {{.ConstraintName}};
|
DROP CONSTRAINT {{.ConstraintName}};
|
||||||
END IF;
|
END IF;
|
||||||
END;
|
END;
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
{{/* Base ALTER TABLE structure */}}
|
{{/* Base ALTER TABLE structure */}}
|
||||||
{{- define "alter_table_base" -}}
|
{{- define "alter_table_base" -}}
|
||||||
ALTER TABLE {{.SchemaName}}.{{.TableName}}
|
ALTER TABLE {{qual_table_raw .SchemaName .TableName}}
|
||||||
{{block "alter_operation" .}}{{end}};
|
{{block "alter_operation" .}}{{end}};
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
|
|
||||||
@@ -30,5 +30,5 @@ $$;
|
|||||||
|
|
||||||
{{/* Common drop pattern */}}
|
{{/* Common drop pattern */}}
|
||||||
{{- define "drop_if_exists" -}}
|
{{- define "drop_if_exists" -}}
|
||||||
{{block "drop_type" .}}{{end}} IF EXISTS {{.SchemaName}}.{{.ObjectName}};
|
{{block "drop_type" .}}{{end}} IF EXISTS {{qual_table_raw .SchemaName .ObjectName}};
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
@@ -1 +1 @@
|
|||||||
COMMENT ON COLUMN {{.SchemaName}}.{{.TableName}}.{{.ColumnName}} IS '{{.Comment}}';
|
COMMENT ON COLUMN {{qual_table .SchemaName .TableName}}.{{quote_ident .ColumnName}} IS '{{.Comment}}';
|
||||||
@@ -1 +1 @@
|
|||||||
COMMENT ON TABLE {{.SchemaName}}.{{.TableName}} IS '{{.Comment}}';
|
COMMENT ON TABLE {{qual_table .SchemaName .TableName}} IS '{{.Comment}}';
|
||||||
12
pkg/writers/pgsql/templates/create_check_constraint.tmpl
Normal file
12
pkg/writers/pgsql/templates/create_check_constraint.tmpl
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
DO $$
|
||||||
|
BEGIN
|
||||||
|
IF NOT EXISTS (
|
||||||
|
SELECT 1 FROM information_schema.table_constraints
|
||||||
|
WHERE table_schema = '{{.SchemaName}}'
|
||||||
|
AND table_name = '{{.TableName}}'
|
||||||
|
AND constraint_name = '{{.ConstraintName}}'
|
||||||
|
) THEN
|
||||||
|
ALTER TABLE {{qual_table .SchemaName .TableName}} ADD CONSTRAINT {{quote_ident .ConstraintName}} CHECK ({{.Expression}});
|
||||||
|
END IF;
|
||||||
|
END;
|
||||||
|
$$;
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
ALTER TABLE {{.SchemaName}}.{{.TableName}}
|
ALTER TABLE {{qual_table .SchemaName .TableName}}
|
||||||
DROP CONSTRAINT IF EXISTS {{.ConstraintName}};
|
DROP CONSTRAINT IF EXISTS {{quote_ident .ConstraintName}};
|
||||||
|
|
||||||
ALTER TABLE {{.SchemaName}}.{{.TableName}}
|
ALTER TABLE {{qual_table .SchemaName .TableName}}
|
||||||
ADD CONSTRAINT {{.ConstraintName}}
|
ADD CONSTRAINT {{quote_ident .ConstraintName}}
|
||||||
FOREIGN KEY ({{.SourceColumns}})
|
FOREIGN KEY ({{.SourceColumns}})
|
||||||
REFERENCES {{.TargetSchema}}.{{.TargetTable}} ({{.TargetColumns}})
|
REFERENCES {{qual_table .TargetSchema .TargetTable}} ({{.TargetColumns}})
|
||||||
ON DELETE {{.OnDelete}}
|
ON DELETE {{.OnDelete}}
|
||||||
ON UPDATE {{.OnUpdate}}
|
ON UPDATE {{.OnUpdate}}
|
||||||
DEFERRABLE;
|
DEFERRABLE;
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
DO $$
|
||||||
|
BEGIN
|
||||||
|
IF NOT EXISTS (
|
||||||
|
SELECT 1 FROM information_schema.table_constraints
|
||||||
|
WHERE table_schema = '{{.SchemaName}}'
|
||||||
|
AND table_name = '{{.TableName}}'
|
||||||
|
AND constraint_name = '{{.ConstraintName}}'
|
||||||
|
) THEN
|
||||||
|
ALTER TABLE {{qual_table .SchemaName .TableName}}
|
||||||
|
ADD CONSTRAINT {{quote_ident .ConstraintName}}
|
||||||
|
FOREIGN KEY ({{.SourceColumns}})
|
||||||
|
REFERENCES {{qual_table .TargetSchema .TargetTable}} ({{.TargetColumns}})
|
||||||
|
ON DELETE {{.OnDelete}}
|
||||||
|
ON UPDATE {{.OnUpdate}}{{if .Deferrable}}
|
||||||
|
DEFERRABLE{{end}};
|
||||||
|
END IF;
|
||||||
|
END;
|
||||||
|
$$;
|
||||||
@@ -1,2 +1,2 @@
|
|||||||
CREATE {{if .Unique}}UNIQUE {{end}}INDEX IF NOT EXISTS {{.IndexName}}
|
CREATE {{if .Unique}}UNIQUE {{end}}INDEX IF NOT EXISTS {{quote_ident .IndexName}}
|
||||||
ON {{.SchemaName}}.{{.TableName}} USING {{.IndexType}} ({{.Columns}});
|
ON {{qual_table .SchemaName .TableName}} USING {{.IndexType}} ({{.Columns}});
|
||||||
@@ -6,8 +6,8 @@ BEGIN
|
|||||||
AND table_name = '{{.TableName}}'
|
AND table_name = '{{.TableName}}'
|
||||||
AND constraint_name = '{{.ConstraintName}}'
|
AND constraint_name = '{{.ConstraintName}}'
|
||||||
) THEN
|
) THEN
|
||||||
ALTER TABLE {{.SchemaName}}.{{.TableName}}
|
ALTER TABLE {{qual_table .SchemaName .TableName}}
|
||||||
ADD CONSTRAINT {{.ConstraintName}} PRIMARY KEY ({{.Columns}});
|
ADD CONSTRAINT {{quote_ident .ConstraintName}} PRIMARY KEY ({{.Columns}});
|
||||||
END IF;
|
END IF;
|
||||||
END;
|
END;
|
||||||
$$;
|
$$;
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
DO $$
|
||||||
|
DECLARE
|
||||||
|
auto_pk_name text;
|
||||||
|
BEGIN
|
||||||
|
-- Drop auto-generated primary key if it exists
|
||||||
|
SELECT constraint_name INTO auto_pk_name
|
||||||
|
FROM information_schema.table_constraints
|
||||||
|
WHERE table_schema = '{{.SchemaName}}'
|
||||||
|
AND table_name = '{{.TableName}}'
|
||||||
|
AND constraint_type = 'PRIMARY KEY'
|
||||||
|
AND constraint_name IN ({{.AutoGenNames}});
|
||||||
|
|
||||||
|
IF auto_pk_name IS NOT NULL THEN
|
||||||
|
EXECUTE 'ALTER TABLE {{qual_table .SchemaName .TableName}} DROP CONSTRAINT ' || quote_ident(auto_pk_name);
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
-- Add named primary key if it doesn't exist
|
||||||
|
IF NOT EXISTS (
|
||||||
|
SELECT 1 FROM information_schema.table_constraints
|
||||||
|
WHERE table_schema = '{{.SchemaName}}'
|
||||||
|
AND table_name = '{{.TableName}}'
|
||||||
|
AND constraint_name = '{{.ConstraintName}}'
|
||||||
|
) THEN
|
||||||
|
ALTER TABLE {{qual_table .SchemaName .TableName}} ADD CONSTRAINT {{quote_ident .ConstraintName}} PRIMARY KEY ({{.Columns}});
|
||||||
|
END IF;
|
||||||
|
END;
|
||||||
|
$$;
|
||||||
6
pkg/writers/pgsql/templates/create_sequence.tmpl
Normal file
6
pkg/writers/pgsql/templates/create_sequence.tmpl
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
CREATE SEQUENCE IF NOT EXISTS {{qual_table .SchemaName .SequenceName}}
|
||||||
|
INCREMENT {{.Increment}}
|
||||||
|
MINVALUE {{.MinValue}}
|
||||||
|
MAXVALUE {{.MaxValue}}
|
||||||
|
START {{.StartValue}}
|
||||||
|
CACHE {{.CacheSize}};
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
CREATE TABLE IF NOT EXISTS {{.SchemaName}}.{{.TableName}} (
|
CREATE TABLE IF NOT EXISTS {{qual_table .SchemaName .TableName}} (
|
||||||
{{- range $i, $col := .Columns}}
|
{{- range $i, $col := .Columns}}
|
||||||
{{- if $i}},{{end}}
|
{{- if $i}},{{end}}
|
||||||
{{$col.Name}} {{$col.Type}}
|
{{quote_ident $col.Name}} {{$col.Type}}
|
||||||
{{- if $col.Default}} DEFAULT {{$col.Default}}{{end}}
|
{{- if $col.Default}} DEFAULT {{$col.Default}}{{end}}
|
||||||
{{- if $col.NotNull}} NOT NULL{{end}}
|
{{- if $col.NotNull}} NOT NULL{{end}}
|
||||||
{{- end}}
|
{{- end}}
|
||||||
|
|||||||
12
pkg/writers/pgsql/templates/create_unique_constraint.tmpl
Normal file
12
pkg/writers/pgsql/templates/create_unique_constraint.tmpl
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
DO $$
|
||||||
|
BEGIN
|
||||||
|
IF NOT EXISTS (
|
||||||
|
SELECT 1 FROM information_schema.table_constraints
|
||||||
|
WHERE table_schema = '{{.SchemaName}}'
|
||||||
|
AND table_name = '{{.TableName}}'
|
||||||
|
AND constraint_name = '{{.ConstraintName}}'
|
||||||
|
) THEN
|
||||||
|
ALTER TABLE {{qual_table .SchemaName .TableName}} ADD CONSTRAINT {{quote_ident .ConstraintName}} UNIQUE ({{.Columns}});
|
||||||
|
END IF;
|
||||||
|
END;
|
||||||
|
$$;
|
||||||
@@ -1 +1 @@
|
|||||||
ALTER TABLE {{.SchemaName}}.{{.TableName}} DROP CONSTRAINT IF EXISTS {{.ConstraintName}};
|
ALTER TABLE {{qual_table .SchemaName .TableName}} DROP CONSTRAINT IF EXISTS {{quote_ident .ConstraintName}};
|
||||||
@@ -1 +1 @@
|
|||||||
DROP INDEX IF EXISTS {{.SchemaName}}.{{.IndexName}} CASCADE;
|
DROP INDEX IF EXISTS {{qual_table .SchemaName .IndexName}} CASCADE;
|
||||||
@@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
{{/* Qualified table name */}}
|
{{/* Qualified table name */}}
|
||||||
{{- define "qualified_table" -}}
|
{{- define "qualified_table" -}}
|
||||||
{{.SchemaName}}.{{.TableName}}
|
{{qual_table_raw .SchemaName .TableName}}
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
|
|
||||||
{{/* Index method clause */}}
|
{{/* Index method clause */}}
|
||||||
|
|||||||
19
pkg/writers/pgsql/templates/set_sequence_value.tmpl
Normal file
19
pkg/writers/pgsql/templates/set_sequence_value.tmpl
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
DO $$
|
||||||
|
DECLARE
|
||||||
|
m_cnt bigint;
|
||||||
|
BEGIN
|
||||||
|
IF EXISTS (
|
||||||
|
SELECT 1 FROM pg_class c
|
||||||
|
INNER JOIN pg_namespace n ON n.oid = c.relnamespace
|
||||||
|
WHERE c.relname = '{{.SequenceName}}'
|
||||||
|
AND n.nspname = '{{.SchemaName}}'
|
||||||
|
AND c.relkind = 'S'
|
||||||
|
) THEN
|
||||||
|
SELECT COALESCE(MAX({{quote_ident .ColumnName}}), 0) + 1
|
||||||
|
FROM {{qual_table .SchemaName .TableName}}
|
||||||
|
INTO m_cnt;
|
||||||
|
|
||||||
|
PERFORM setval('{{qual_table_raw .SchemaName .SequenceName}}'::regclass, m_cnt);
|
||||||
|
END IF;
|
||||||
|
END;
|
||||||
|
$$;
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -45,11 +45,11 @@ func TestWriteDatabase(t *testing.T) {
|
|||||||
|
|
||||||
// Add unique index
|
// Add unique index
|
||||||
uniqueEmailIndex := &models.Index{
|
uniqueEmailIndex := &models.Index{
|
||||||
Name: "uk_users_email",
|
Name: "uidx_users_email",
|
||||||
Unique: true,
|
Unique: true,
|
||||||
Columns: []string{"email"},
|
Columns: []string{"email"},
|
||||||
}
|
}
|
||||||
table.Indexes["uk_users_email"] = uniqueEmailIndex
|
table.Indexes["uidx_users_email"] = uniqueEmailIndex
|
||||||
|
|
||||||
schema.Tables = append(schema.Tables, table)
|
schema.Tables = append(schema.Tables, table)
|
||||||
db.Schemas = append(db.Schemas, schema)
|
db.Schemas = append(db.Schemas, schema)
|
||||||
@@ -164,6 +164,296 @@ func TestWriteForeignKeys(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestWriteUniqueConstraints(t *testing.T) {
|
||||||
|
// Create a test database with unique constraints
|
||||||
|
db := models.InitDatabase("testdb")
|
||||||
|
schema := models.InitSchema("public")
|
||||||
|
|
||||||
|
// Create table with unique constraints
|
||||||
|
table := models.InitTable("users", "public")
|
||||||
|
|
||||||
|
// Add columns
|
||||||
|
emailCol := models.InitColumn("email", "users", "public")
|
||||||
|
emailCol.Type = "varchar(255)"
|
||||||
|
emailCol.NotNull = true
|
||||||
|
table.Columns["email"] = emailCol
|
||||||
|
|
||||||
|
guidCol := models.InitColumn("guid", "users", "public")
|
||||||
|
guidCol.Type = "uuid"
|
||||||
|
guidCol.NotNull = true
|
||||||
|
table.Columns["guid"] = guidCol
|
||||||
|
|
||||||
|
// Add unique constraints
|
||||||
|
emailConstraint := &models.Constraint{
|
||||||
|
Name: "uq_email",
|
||||||
|
Type: models.UniqueConstraint,
|
||||||
|
Schema: "public",
|
||||||
|
Table: "users",
|
||||||
|
Columns: []string{"email"},
|
||||||
|
}
|
||||||
|
table.Constraints["uq_email"] = emailConstraint
|
||||||
|
|
||||||
|
guidConstraint := &models.Constraint{
|
||||||
|
Name: "uq_guid",
|
||||||
|
Type: models.UniqueConstraint,
|
||||||
|
Schema: "public",
|
||||||
|
Table: "users",
|
||||||
|
Columns: []string{"guid"},
|
||||||
|
}
|
||||||
|
table.Constraints["uq_guid"] = guidConstraint
|
||||||
|
|
||||||
|
schema.Tables = append(schema.Tables, table)
|
||||||
|
db.Schemas = append(db.Schemas, schema)
|
||||||
|
|
||||||
|
// Create writer with output to buffer
|
||||||
|
var buf bytes.Buffer
|
||||||
|
options := &writers.WriterOptions{}
|
||||||
|
writer := NewWriter(options)
|
||||||
|
writer.writer = &buf
|
||||||
|
|
||||||
|
// Write the database
|
||||||
|
err := writer.WriteDatabase(db)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("WriteDatabase failed: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
output := buf.String()
|
||||||
|
|
||||||
|
// Print output for debugging
|
||||||
|
t.Logf("Generated SQL:\n%s", output)
|
||||||
|
|
||||||
|
// Verify unique constraints are present
|
||||||
|
if !strings.Contains(output, "-- Unique constraints for schema: public") {
|
||||||
|
t.Errorf("Output missing unique constraints header")
|
||||||
|
}
|
||||||
|
if !strings.Contains(output, "ADD CONSTRAINT uq_email UNIQUE (email)") {
|
||||||
|
t.Errorf("Output missing uq_email unique constraint\nFull output:\n%s", output)
|
||||||
|
}
|
||||||
|
if !strings.Contains(output, "ADD CONSTRAINT uq_guid UNIQUE (guid)") {
|
||||||
|
t.Errorf("Output missing uq_guid unique constraint\nFull output:\n%s", output)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestWriteCheckConstraints(t *testing.T) {
|
||||||
|
// Create a test database with check constraints
|
||||||
|
db := models.InitDatabase("testdb")
|
||||||
|
schema := models.InitSchema("public")
|
||||||
|
|
||||||
|
// Create table with check constraints
|
||||||
|
table := models.InitTable("products", "public")
|
||||||
|
|
||||||
|
// Add columns
|
||||||
|
priceCol := models.InitColumn("price", "products", "public")
|
||||||
|
priceCol.Type = "numeric(10,2)"
|
||||||
|
table.Columns["price"] = priceCol
|
||||||
|
|
||||||
|
statusCol := models.InitColumn("status", "products", "public")
|
||||||
|
statusCol.Type = "varchar(20)"
|
||||||
|
table.Columns["status"] = statusCol
|
||||||
|
|
||||||
|
quantityCol := models.InitColumn("quantity", "products", "public")
|
||||||
|
quantityCol.Type = "integer"
|
||||||
|
table.Columns["quantity"] = quantityCol
|
||||||
|
|
||||||
|
// Add check constraints
|
||||||
|
priceConstraint := &models.Constraint{
|
||||||
|
Name: "ck_price_positive",
|
||||||
|
Type: models.CheckConstraint,
|
||||||
|
Schema: "public",
|
||||||
|
Table: "products",
|
||||||
|
Expression: "price >= 0",
|
||||||
|
}
|
||||||
|
table.Constraints["ck_price_positive"] = priceConstraint
|
||||||
|
|
||||||
|
statusConstraint := &models.Constraint{
|
||||||
|
Name: "ck_status_valid",
|
||||||
|
Type: models.CheckConstraint,
|
||||||
|
Schema: "public",
|
||||||
|
Table: "products",
|
||||||
|
Expression: "status IN ('active', 'inactive', 'discontinued')",
|
||||||
|
}
|
||||||
|
table.Constraints["ck_status_valid"] = statusConstraint
|
||||||
|
|
||||||
|
quantityConstraint := &models.Constraint{
|
||||||
|
Name: "ck_quantity_nonnegative",
|
||||||
|
Type: models.CheckConstraint,
|
||||||
|
Schema: "public",
|
||||||
|
Table: "products",
|
||||||
|
Expression: "quantity >= 0",
|
||||||
|
}
|
||||||
|
table.Constraints["ck_quantity_nonnegative"] = quantityConstraint
|
||||||
|
|
||||||
|
schema.Tables = append(schema.Tables, table)
|
||||||
|
db.Schemas = append(db.Schemas, schema)
|
||||||
|
|
||||||
|
// Create writer with output to buffer
|
||||||
|
var buf bytes.Buffer
|
||||||
|
options := &writers.WriterOptions{}
|
||||||
|
writer := NewWriter(options)
|
||||||
|
writer.writer = &buf
|
||||||
|
|
||||||
|
// Write the database
|
||||||
|
err := writer.WriteDatabase(db)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("WriteDatabase failed: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
output := buf.String()
|
||||||
|
|
||||||
|
// Print output for debugging
|
||||||
|
t.Logf("Generated SQL:\n%s", output)
|
||||||
|
|
||||||
|
// Verify check constraints are present
|
||||||
|
if !strings.Contains(output, "-- Check constraints for schema: public") {
|
||||||
|
t.Errorf("Output missing check constraints header")
|
||||||
|
}
|
||||||
|
if !strings.Contains(output, "ADD CONSTRAINT ck_price_positive CHECK (price >= 0)") {
|
||||||
|
t.Errorf("Output missing ck_price_positive check constraint\nFull output:\n%s", output)
|
||||||
|
}
|
||||||
|
if !strings.Contains(output, "ADD CONSTRAINT ck_status_valid CHECK (status IN ('active', 'inactive', 'discontinued'))") {
|
||||||
|
t.Errorf("Output missing ck_status_valid check constraint\nFull output:\n%s", output)
|
||||||
|
}
|
||||||
|
if !strings.Contains(output, "ADD CONSTRAINT ck_quantity_nonnegative CHECK (quantity >= 0)") {
|
||||||
|
t.Errorf("Output missing ck_quantity_nonnegative check constraint\nFull output:\n%s", output)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestWriteAllConstraintTypes(t *testing.T) {
|
||||||
|
// Create a comprehensive test with all constraint types
|
||||||
|
db := models.InitDatabase("testdb")
|
||||||
|
schema := models.InitSchema("public")
|
||||||
|
|
||||||
|
// Create orders table
|
||||||
|
ordersTable := models.InitTable("orders", "public")
|
||||||
|
|
||||||
|
// Add columns
|
||||||
|
idCol := models.InitColumn("id", "orders", "public")
|
||||||
|
idCol.Type = "integer"
|
||||||
|
idCol.IsPrimaryKey = true
|
||||||
|
ordersTable.Columns["id"] = idCol
|
||||||
|
|
||||||
|
userIDCol := models.InitColumn("user_id", "orders", "public")
|
||||||
|
userIDCol.Type = "integer"
|
||||||
|
userIDCol.NotNull = true
|
||||||
|
ordersTable.Columns["user_id"] = userIDCol
|
||||||
|
|
||||||
|
orderNumberCol := models.InitColumn("order_number", "orders", "public")
|
||||||
|
orderNumberCol.Type = "varchar(50)"
|
||||||
|
orderNumberCol.NotNull = true
|
||||||
|
ordersTable.Columns["order_number"] = orderNumberCol
|
||||||
|
|
||||||
|
totalCol := models.InitColumn("total", "orders", "public")
|
||||||
|
totalCol.Type = "numeric(10,2)"
|
||||||
|
ordersTable.Columns["total"] = totalCol
|
||||||
|
|
||||||
|
statusCol := models.InitColumn("status", "orders", "public")
|
||||||
|
statusCol.Type = "varchar(20)"
|
||||||
|
ordersTable.Columns["status"] = statusCol
|
||||||
|
|
||||||
|
// Add primary key constraint
|
||||||
|
pkConstraint := &models.Constraint{
|
||||||
|
Name: "pk_orders",
|
||||||
|
Type: models.PrimaryKeyConstraint,
|
||||||
|
Schema: "public",
|
||||||
|
Table: "orders",
|
||||||
|
Columns: []string{"id"},
|
||||||
|
}
|
||||||
|
ordersTable.Constraints["pk_orders"] = pkConstraint
|
||||||
|
|
||||||
|
// Add unique constraint
|
||||||
|
uniqueConstraint := &models.Constraint{
|
||||||
|
Name: "uq_order_number",
|
||||||
|
Type: models.UniqueConstraint,
|
||||||
|
Schema: "public",
|
||||||
|
Table: "orders",
|
||||||
|
Columns: []string{"order_number"},
|
||||||
|
}
|
||||||
|
ordersTable.Constraints["uq_order_number"] = uniqueConstraint
|
||||||
|
|
||||||
|
// Add check constraint
|
||||||
|
checkConstraint := &models.Constraint{
|
||||||
|
Name: "ck_total_positive",
|
||||||
|
Type: models.CheckConstraint,
|
||||||
|
Schema: "public",
|
||||||
|
Table: "orders",
|
||||||
|
Expression: "total > 0",
|
||||||
|
}
|
||||||
|
ordersTable.Constraints["ck_total_positive"] = checkConstraint
|
||||||
|
|
||||||
|
statusCheckConstraint := &models.Constraint{
|
||||||
|
Name: "ck_status_valid",
|
||||||
|
Type: models.CheckConstraint,
|
||||||
|
Schema: "public",
|
||||||
|
Table: "orders",
|
||||||
|
Expression: "status IN ('pending', 'completed', 'cancelled')",
|
||||||
|
}
|
||||||
|
ordersTable.Constraints["ck_status_valid"] = statusCheckConstraint
|
||||||
|
|
||||||
|
// Add foreign key constraint (referencing a users table)
|
||||||
|
fkConstraint := &models.Constraint{
|
||||||
|
Name: "fk_orders_user",
|
||||||
|
Type: models.ForeignKeyConstraint,
|
||||||
|
Schema: "public",
|
||||||
|
Table: "orders",
|
||||||
|
Columns: []string{"user_id"},
|
||||||
|
ReferencedSchema: "public",
|
||||||
|
ReferencedTable: "users",
|
||||||
|
ReferencedColumns: []string{"id"},
|
||||||
|
OnDelete: "CASCADE",
|
||||||
|
OnUpdate: "CASCADE",
|
||||||
|
}
|
||||||
|
ordersTable.Constraints["fk_orders_user"] = fkConstraint
|
||||||
|
|
||||||
|
schema.Tables = append(schema.Tables, ordersTable)
|
||||||
|
db.Schemas = append(db.Schemas, schema)
|
||||||
|
|
||||||
|
// Create writer with output to buffer
|
||||||
|
var buf bytes.Buffer
|
||||||
|
options := &writers.WriterOptions{}
|
||||||
|
writer := NewWriter(options)
|
||||||
|
writer.writer = &buf
|
||||||
|
|
||||||
|
// Write the database
|
||||||
|
err := writer.WriteDatabase(db)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("WriteDatabase failed: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
output := buf.String()
|
||||||
|
|
||||||
|
// Print output for debugging
|
||||||
|
t.Logf("Generated SQL:\n%s", output)
|
||||||
|
|
||||||
|
// Verify all constraint types are present
|
||||||
|
expectedConstraints := map[string]string{
|
||||||
|
"Primary Key": "PRIMARY KEY",
|
||||||
|
"Unique": "ADD CONSTRAINT uq_order_number UNIQUE (order_number)",
|
||||||
|
"Check (total)": "ADD CONSTRAINT ck_total_positive CHECK (total > 0)",
|
||||||
|
"Check (status)": "ADD CONSTRAINT ck_status_valid CHECK (status IN ('pending', 'completed', 'cancelled'))",
|
||||||
|
"Foreign Key": "FOREIGN KEY",
|
||||||
|
}
|
||||||
|
|
||||||
|
for name, expected := range expectedConstraints {
|
||||||
|
if !strings.Contains(output, expected) {
|
||||||
|
t.Errorf("Output missing %s constraint: %s\nFull output:\n%s", name, expected, output)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Verify section headers
|
||||||
|
sections := []string{
|
||||||
|
"-- Primary keys for schema: public",
|
||||||
|
"-- Unique constraints for schema: public",
|
||||||
|
"-- Check constraints for schema: public",
|
||||||
|
"-- Foreign keys for schema: public",
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, section := range sections {
|
||||||
|
if !strings.Contains(output, section) {
|
||||||
|
t.Errorf("Output missing section header: %s", section)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestWriteTable(t *testing.T) {
|
func TestWriteTable(t *testing.T) {
|
||||||
// Create a single table
|
// Create a single table
|
||||||
table := models.InitTable("products", "public")
|
table := models.InitTable("products", "public")
|
||||||
@@ -241,3 +531,327 @@ func TestIsIntegerType(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestTypeConversion(t *testing.T) {
|
||||||
|
// Test that invalid Go types are converted to valid PostgreSQL types
|
||||||
|
db := models.InitDatabase("testdb")
|
||||||
|
schema := models.InitSchema("public")
|
||||||
|
|
||||||
|
// Create a test table with Go types instead of SQL types
|
||||||
|
table := models.InitTable("test_types", "public")
|
||||||
|
|
||||||
|
// Add columns with Go types (invalid for PostgreSQL)
|
||||||
|
stringCol := models.InitColumn("name", "test_types", "public")
|
||||||
|
stringCol.Type = "string" // Should be converted to "text"
|
||||||
|
table.Columns["name"] = stringCol
|
||||||
|
|
||||||
|
int64Col := models.InitColumn("big_id", "test_types", "public")
|
||||||
|
int64Col.Type = "int64" // Should be converted to "bigint"
|
||||||
|
table.Columns["big_id"] = int64Col
|
||||||
|
|
||||||
|
int16Col := models.InitColumn("small_id", "test_types", "public")
|
||||||
|
int16Col.Type = "int16" // Should be converted to "smallint"
|
||||||
|
table.Columns["small_id"] = int16Col
|
||||||
|
|
||||||
|
schema.Tables = append(schema.Tables, table)
|
||||||
|
db.Schemas = append(db.Schemas, schema)
|
||||||
|
|
||||||
|
// Create writer with output to buffer
|
||||||
|
var buf bytes.Buffer
|
||||||
|
options := &writers.WriterOptions{}
|
||||||
|
writer := NewWriter(options)
|
||||||
|
writer.writer = &buf
|
||||||
|
|
||||||
|
// Write the database
|
||||||
|
err := writer.WriteDatabase(db)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("WriteDatabase failed: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
output := buf.String()
|
||||||
|
|
||||||
|
// Print output for debugging
|
||||||
|
t.Logf("Generated SQL:\n%s", output)
|
||||||
|
|
||||||
|
// Verify that Go types were converted to PostgreSQL types
|
||||||
|
if strings.Contains(output, "string") {
|
||||||
|
t.Errorf("Output contains 'string' type - should be converted to 'text'\nFull output:\n%s", output)
|
||||||
|
}
|
||||||
|
if strings.Contains(output, "int64") {
|
||||||
|
t.Errorf("Output contains 'int64' type - should be converted to 'bigint'\nFull output:\n%s", output)
|
||||||
|
}
|
||||||
|
if strings.Contains(output, "int16") {
|
||||||
|
t.Errorf("Output contains 'int16' type - should be converted to 'smallint'\nFull output:\n%s", output)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Verify correct PostgreSQL types are present
|
||||||
|
if !strings.Contains(output, "text") {
|
||||||
|
t.Errorf("Output missing 'text' type (converted from 'string')\nFull output:\n%s", output)
|
||||||
|
}
|
||||||
|
if !strings.Contains(output, "bigint") {
|
||||||
|
t.Errorf("Output missing 'bigint' type (converted from 'int64')\nFull output:\n%s", output)
|
||||||
|
}
|
||||||
|
if !strings.Contains(output, "smallint") {
|
||||||
|
t.Errorf("Output missing 'smallint' type (converted from 'int16')\nFull output:\n%s", output)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestPrimaryKeyExistenceCheck(t *testing.T) {
|
||||||
|
db := models.InitDatabase("testdb")
|
||||||
|
schema := models.InitSchema("public")
|
||||||
|
table := models.InitTable("products", "public")
|
||||||
|
|
||||||
|
idCol := models.InitColumn("id", "products", "public")
|
||||||
|
idCol.Type = "integer"
|
||||||
|
idCol.IsPrimaryKey = true
|
||||||
|
table.Columns["id"] = idCol
|
||||||
|
|
||||||
|
nameCol := models.InitColumn("name", "products", "public")
|
||||||
|
nameCol.Type = "text"
|
||||||
|
table.Columns["name"] = nameCol
|
||||||
|
|
||||||
|
schema.Tables = append(schema.Tables, table)
|
||||||
|
db.Schemas = append(db.Schemas, schema)
|
||||||
|
|
||||||
|
var buf bytes.Buffer
|
||||||
|
options := &writers.WriterOptions{}
|
||||||
|
writer := NewWriter(options)
|
||||||
|
writer.writer = &buf
|
||||||
|
|
||||||
|
err := writer.WriteDatabase(db)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("WriteDatabase failed: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
output := buf.String()
|
||||||
|
t.Logf("Generated SQL:\n%s", output)
|
||||||
|
|
||||||
|
// Verify our naming convention is used
|
||||||
|
if !strings.Contains(output, "pk_public_products") {
|
||||||
|
t.Errorf("Output missing expected primary key name 'pk_public_products'\nFull output:\n%s", output)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Verify it drops auto-generated primary keys
|
||||||
|
if !strings.Contains(output, "products_pkey") || !strings.Contains(output, "DROP CONSTRAINT") {
|
||||||
|
t.Errorf("Output missing logic to drop auto-generated primary key\nFull output:\n%s", output)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Verify it checks for our specific named constraint before adding it
|
||||||
|
if !strings.Contains(output, "constraint_name = 'pk_public_products'") {
|
||||||
|
t.Errorf("Output missing check for our named primary key constraint\nFull output:\n%s", output)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestColumnSizeSpecifiers(t *testing.T) {
|
||||||
|
db := models.InitDatabase("testdb")
|
||||||
|
schema := models.InitSchema("public")
|
||||||
|
table := models.InitTable("test_sizes", "public")
|
||||||
|
|
||||||
|
// Integer with invalid size specifier - should ignore size
|
||||||
|
integerCol := models.InitColumn("int_col", "test_sizes", "public")
|
||||||
|
integerCol.Type = "integer"
|
||||||
|
integerCol.Length = 32
|
||||||
|
table.Columns["int_col"] = integerCol
|
||||||
|
|
||||||
|
// Bigint with invalid size specifier - should ignore size
|
||||||
|
bigintCol := models.InitColumn("bigint_col", "test_sizes", "public")
|
||||||
|
bigintCol.Type = "bigint"
|
||||||
|
bigintCol.Length = 64
|
||||||
|
table.Columns["bigint_col"] = bigintCol
|
||||||
|
|
||||||
|
// Smallint with invalid size specifier - should ignore size
|
||||||
|
smallintCol := models.InitColumn("smallint_col", "test_sizes", "public")
|
||||||
|
smallintCol.Type = "smallint"
|
||||||
|
smallintCol.Length = 16
|
||||||
|
table.Columns["smallint_col"] = smallintCol
|
||||||
|
|
||||||
|
// Text with length - should convert to varchar
|
||||||
|
textCol := models.InitColumn("text_col", "test_sizes", "public")
|
||||||
|
textCol.Type = "text"
|
||||||
|
textCol.Length = 100
|
||||||
|
table.Columns["text_col"] = textCol
|
||||||
|
|
||||||
|
// Varchar with length - should keep varchar with length
|
||||||
|
varcharCol := models.InitColumn("varchar_col", "test_sizes", "public")
|
||||||
|
varcharCol.Type = "varchar"
|
||||||
|
varcharCol.Length = 50
|
||||||
|
table.Columns["varchar_col"] = varcharCol
|
||||||
|
|
||||||
|
// Decimal with precision and scale - should keep them
|
||||||
|
decimalCol := models.InitColumn("decimal_col", "test_sizes", "public")
|
||||||
|
decimalCol.Type = "decimal"
|
||||||
|
decimalCol.Precision = 19
|
||||||
|
decimalCol.Scale = 4
|
||||||
|
table.Columns["decimal_col"] = decimalCol
|
||||||
|
|
||||||
|
schema.Tables = append(schema.Tables, table)
|
||||||
|
db.Schemas = append(db.Schemas, schema)
|
||||||
|
|
||||||
|
var buf bytes.Buffer
|
||||||
|
options := &writers.WriterOptions{}
|
||||||
|
writer := NewWriter(options)
|
||||||
|
writer.writer = &buf
|
||||||
|
|
||||||
|
err := writer.WriteDatabase(db)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("WriteDatabase failed: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
output := buf.String()
|
||||||
|
t.Logf("Generated SQL:\n%s", output)
|
||||||
|
|
||||||
|
// Verify invalid size specifiers are NOT present
|
||||||
|
invalidPatterns := []string{
|
||||||
|
"integer(32)",
|
||||||
|
"bigint(64)",
|
||||||
|
"smallint(16)",
|
||||||
|
"text(100)",
|
||||||
|
}
|
||||||
|
for _, pattern := range invalidPatterns {
|
||||||
|
if strings.Contains(output, pattern) {
|
||||||
|
t.Errorf("Output contains invalid pattern '%s' - PostgreSQL doesn't support this\nFull output:\n%s", pattern, output)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Verify valid patterns ARE present
|
||||||
|
validPatterns := []string{
|
||||||
|
"integer", // without size
|
||||||
|
"bigint", // without size
|
||||||
|
"smallint", // without size
|
||||||
|
"varchar(100)", // text converted to varchar with length
|
||||||
|
"varchar(50)", // varchar with length
|
||||||
|
"decimal(19,4)", // decimal with precision and scale
|
||||||
|
}
|
||||||
|
for _, pattern := range validPatterns {
|
||||||
|
if !strings.Contains(output, pattern) {
|
||||||
|
t.Errorf("Output missing expected pattern '%s'\nFull output:\n%s", pattern, output)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestGenerateAddColumnStatements(t *testing.T) {
|
||||||
|
// Create a test database with tables that have new columns
|
||||||
|
db := models.InitDatabase("testdb")
|
||||||
|
schema := models.InitSchema("public")
|
||||||
|
|
||||||
|
// Create a table with columns
|
||||||
|
table := models.InitTable("users", "public")
|
||||||
|
|
||||||
|
// Existing column
|
||||||
|
idCol := models.InitColumn("id", "users", "public")
|
||||||
|
idCol.Type = "integer"
|
||||||
|
idCol.NotNull = true
|
||||||
|
idCol.Sequence = 1
|
||||||
|
table.Columns["id"] = idCol
|
||||||
|
|
||||||
|
// New column to be added
|
||||||
|
emailCol := models.InitColumn("email", "users", "public")
|
||||||
|
emailCol.Type = "varchar"
|
||||||
|
emailCol.Length = 255
|
||||||
|
emailCol.NotNull = true
|
||||||
|
emailCol.Sequence = 2
|
||||||
|
table.Columns["email"] = emailCol
|
||||||
|
|
||||||
|
// New column with default
|
||||||
|
statusCol := models.InitColumn("status", "users", "public")
|
||||||
|
statusCol.Type = "text"
|
||||||
|
statusCol.Default = "active"
|
||||||
|
statusCol.Sequence = 3
|
||||||
|
table.Columns["status"] = statusCol
|
||||||
|
|
||||||
|
schema.Tables = append(schema.Tables, table)
|
||||||
|
db.Schemas = append(db.Schemas, schema)
|
||||||
|
|
||||||
|
// Create writer
|
||||||
|
options := &writers.WriterOptions{}
|
||||||
|
writer := NewWriter(options)
|
||||||
|
|
||||||
|
// Generate ADD COLUMN statements
|
||||||
|
statements, err := writer.GenerateAddColumnsForDatabase(db)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("GenerateAddColumnsForDatabase failed: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Join all statements to verify content
|
||||||
|
output := strings.Join(statements, "\n")
|
||||||
|
t.Logf("Generated ADD COLUMN statements:\n%s", output)
|
||||||
|
|
||||||
|
// Verify expected elements
|
||||||
|
expectedStrings := []string{
|
||||||
|
"ALTER TABLE public.users ADD COLUMN id integer NOT NULL",
|
||||||
|
"ALTER TABLE public.users ADD COLUMN email varchar(255) NOT NULL",
|
||||||
|
"ALTER TABLE public.users ADD COLUMN status text DEFAULT 'active'",
|
||||||
|
"information_schema.columns",
|
||||||
|
"table_schema = 'public'",
|
||||||
|
"table_name = 'users'",
|
||||||
|
"column_name = 'id'",
|
||||||
|
"column_name = 'email'",
|
||||||
|
"column_name = 'status'",
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, expected := range expectedStrings {
|
||||||
|
if !strings.Contains(output, expected) {
|
||||||
|
t.Errorf("Output missing expected string: %s\nFull output:\n%s", expected, output)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Verify DO blocks are present for conditional adds
|
||||||
|
doBlockCount := strings.Count(output, "DO $$")
|
||||||
|
if doBlockCount < 3 {
|
||||||
|
t.Errorf("Expected at least 3 DO blocks (one per column), got %d", doBlockCount)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Verify IF NOT EXISTS logic
|
||||||
|
ifNotExistsCount := strings.Count(output, "IF NOT EXISTS")
|
||||||
|
if ifNotExistsCount < 3 {
|
||||||
|
t.Errorf("Expected at least 3 IF NOT EXISTS checks (one per column), got %d", ifNotExistsCount)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestWriteAddColumnStatements(t *testing.T) {
|
||||||
|
// Create a test database
|
||||||
|
db := models.InitDatabase("testdb")
|
||||||
|
schema := models.InitSchema("public")
|
||||||
|
|
||||||
|
// Create a table with a new column to be added
|
||||||
|
table := models.InitTable("products", "public")
|
||||||
|
|
||||||
|
idCol := models.InitColumn("id", "products", "public")
|
||||||
|
idCol.Type = "integer"
|
||||||
|
table.Columns["id"] = idCol
|
||||||
|
|
||||||
|
// New column with various properties
|
||||||
|
descCol := models.InitColumn("description", "products", "public")
|
||||||
|
descCol.Type = "text"
|
||||||
|
descCol.NotNull = false
|
||||||
|
table.Columns["description"] = descCol
|
||||||
|
|
||||||
|
schema.Tables = append(schema.Tables, table)
|
||||||
|
db.Schemas = append(db.Schemas, schema)
|
||||||
|
|
||||||
|
// Create writer with output to buffer
|
||||||
|
var buf bytes.Buffer
|
||||||
|
options := &writers.WriterOptions{}
|
||||||
|
writer := NewWriter(options)
|
||||||
|
writer.writer = &buf
|
||||||
|
|
||||||
|
// Write ADD COLUMN statements
|
||||||
|
err := writer.WriteAddColumnStatements(db)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("WriteAddColumnStatements failed: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
output := buf.String()
|
||||||
|
t.Logf("Generated output:\n%s", output)
|
||||||
|
|
||||||
|
// Verify output contains expected elements
|
||||||
|
if !strings.Contains(output, "ALTER TABLE public.products ADD COLUMN id integer") {
|
||||||
|
t.Errorf("Output missing ADD COLUMN for id\nFull output:\n%s", output)
|
||||||
|
}
|
||||||
|
if !strings.Contains(output, "ALTER TABLE public.products ADD COLUMN description text") {
|
||||||
|
t.Errorf("Output missing ADD COLUMN for description\nFull output:\n%s", output)
|
||||||
|
}
|
||||||
|
if !strings.Contains(output, "DO $$") {
|
||||||
|
t.Errorf("Output missing DO block\nFull output:\n%s", output)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ The SQL Executor Writer (`sqlexec`) executes SQL scripts from `models.Script` ob
|
|||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
|
||||||
- **Ordered Execution**: Scripts execute in Priority→Sequence order
|
- **Ordered Execution**: Scripts execute in Priority→Sequence→Name order
|
||||||
- **PostgreSQL Support**: Uses `pgx/v5` driver for robust PostgreSQL connectivity
|
- **PostgreSQL Support**: Uses `pgx/v5` driver for robust PostgreSQL connectivity
|
||||||
- **Stop on Error**: Execution halts immediately on first error (default behavior)
|
- **Stop on Error**: Execution halts immediately on first error (default behavior)
|
||||||
- **Progress Reporting**: Prints execution status to stdout
|
- **Progress Reporting**: Prints execution status to stdout
|
||||||
@@ -103,19 +103,40 @@ Scripts are sorted and executed based on:
|
|||||||
|
|
||||||
1. **Priority** (ascending): Lower priority values execute first
|
1. **Priority** (ascending): Lower priority values execute first
|
||||||
2. **Sequence** (ascending): Within same priority, lower sequence values execute first
|
2. **Sequence** (ascending): Within same priority, lower sequence values execute first
|
||||||
|
3. **Name** (ascending): Within same priority and sequence, alphabetical order by name
|
||||||
|
|
||||||
### Example Execution Order
|
### Example Execution Order
|
||||||
|
|
||||||
Given these scripts:
|
Given these scripts:
|
||||||
```
|
```
|
||||||
Script A: Priority=2, Sequence=1
|
Script A: Priority=2, Sequence=1, Name="zebra"
|
||||||
Script B: Priority=1, Sequence=3
|
Script B: Priority=1, Sequence=3, Name="script"
|
||||||
Script C: Priority=1, Sequence=1
|
Script C: Priority=1, Sequence=1, Name="apple"
|
||||||
Script D: Priority=1, Sequence=2
|
Script D: Priority=1, Sequence=1, Name="beta"
|
||||||
Script E: Priority=3, Sequence=1
|
Script E: Priority=3, Sequence=1, Name="script"
|
||||||
```
|
```
|
||||||
|
|
||||||
Execution order: **C → D → B → A → E**
|
Execution order: **C (apple) → D (beta) → B → A → E**
|
||||||
|
|
||||||
|
### Directory-based Sorting Example
|
||||||
|
|
||||||
|
Given these files:
|
||||||
|
```
|
||||||
|
1_001_create_schema.sql
|
||||||
|
1_001_create_users.sql ← Alphabetically before "drop_tables"
|
||||||
|
1_001_drop_tables.sql
|
||||||
|
1_002_add_indexes.sql
|
||||||
|
2_001_constraints.sql
|
||||||
|
```
|
||||||
|
|
||||||
|
Execution order (note alphabetical sorting at same priority/sequence):
|
||||||
|
```
|
||||||
|
1_001_create_schema.sql
|
||||||
|
1_001_create_users.sql
|
||||||
|
1_001_drop_tables.sql
|
||||||
|
1_002_add_indexes.sql
|
||||||
|
2_001_constraints.sql
|
||||||
|
```
|
||||||
|
|
||||||
## Output
|
## Output
|
||||||
|
|
||||||
|
|||||||
@@ -23,6 +23,11 @@ func NewWriter(options *writers.WriterOptions) *Writer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Options returns the writer options (useful for reading execution results)
|
||||||
|
func (w *Writer) Options() *writers.WriterOptions {
|
||||||
|
return w.options
|
||||||
|
}
|
||||||
|
|
||||||
// WriteDatabase executes all scripts from all schemas in the database
|
// WriteDatabase executes all scripts from all schemas in the database
|
||||||
func (w *Writer) WriteDatabase(db *models.Database) error {
|
func (w *Writer) WriteDatabase(db *models.Database) error {
|
||||||
if db == nil {
|
if db == nil {
|
||||||
@@ -86,20 +91,39 @@ func (w *Writer) WriteTable(table *models.Table) error {
|
|||||||
return fmt.Errorf("WriteTable is not supported for SQL script execution")
|
return fmt.Errorf("WriteTable is not supported for SQL script execution")
|
||||||
}
|
}
|
||||||
|
|
||||||
// executeScripts executes scripts in Priority then Sequence order
|
// executeScripts executes scripts in Priority, Sequence, then Name order
|
||||||
func (w *Writer) executeScripts(ctx context.Context, conn *pgx.Conn, scripts []*models.Script) error {
|
func (w *Writer) executeScripts(ctx context.Context, conn *pgx.Conn, scripts []*models.Script) error {
|
||||||
if len(scripts) == 0 {
|
if len(scripts) == 0 {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sort scripts by Priority (ascending) then Sequence (ascending)
|
// Check if we should ignore errors
|
||||||
|
ignoreErrors := false
|
||||||
|
if val, ok := w.options.Metadata["ignore_errors"].(bool); ok {
|
||||||
|
ignoreErrors = val
|
||||||
|
}
|
||||||
|
|
||||||
|
// Track failed scripts and execution counts
|
||||||
|
var failedScripts []struct {
|
||||||
|
name string
|
||||||
|
priority int
|
||||||
|
sequence uint
|
||||||
|
err error
|
||||||
|
}
|
||||||
|
successCount := 0
|
||||||
|
totalCount := 0
|
||||||
|
|
||||||
|
// Sort scripts by Priority (ascending), Sequence (ascending), then Name (ascending)
|
||||||
sortedScripts := make([]*models.Script, len(scripts))
|
sortedScripts := make([]*models.Script, len(scripts))
|
||||||
copy(sortedScripts, scripts)
|
copy(sortedScripts, scripts)
|
||||||
sort.Slice(sortedScripts, func(i, j int) bool {
|
sort.Slice(sortedScripts, func(i, j int) bool {
|
||||||
if sortedScripts[i].Priority != sortedScripts[j].Priority {
|
if sortedScripts[i].Priority != sortedScripts[j].Priority {
|
||||||
return sortedScripts[i].Priority < sortedScripts[j].Priority
|
return sortedScripts[i].Priority < sortedScripts[j].Priority
|
||||||
}
|
}
|
||||||
return sortedScripts[i].Sequence < sortedScripts[j].Sequence
|
if sortedScripts[i].Sequence != sortedScripts[j].Sequence {
|
||||||
|
return sortedScripts[i].Sequence < sortedScripts[j].Sequence
|
||||||
|
}
|
||||||
|
return sortedScripts[i].Name < sortedScripts[j].Name
|
||||||
})
|
})
|
||||||
|
|
||||||
// Execute each script in order
|
// Execute each script in order
|
||||||
@@ -108,18 +132,49 @@ func (w *Writer) executeScripts(ctx context.Context, conn *pgx.Conn, scripts []*
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
totalCount++
|
||||||
fmt.Printf("Executing script: %s (Priority=%d, Sequence=%d)\n",
|
fmt.Printf("Executing script: %s (Priority=%d, Sequence=%d)\n",
|
||||||
script.Name, script.Priority, script.Sequence)
|
script.Name, script.Priority, script.Sequence)
|
||||||
|
|
||||||
// Execute the SQL script
|
// Execute the SQL script
|
||||||
_, err := conn.Exec(ctx, script.SQL)
|
_, err := conn.Exec(ctx, script.SQL)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to execute script %s (Priority=%d, Sequence=%d): %w",
|
if ignoreErrors {
|
||||||
|
fmt.Printf("⚠ Error executing %s: %v (continuing due to --ignore-errors)\n", script.Name, err)
|
||||||
|
failedScripts = append(failedScripts, struct {
|
||||||
|
name string
|
||||||
|
priority int
|
||||||
|
sequence uint
|
||||||
|
err error
|
||||||
|
}{
|
||||||
|
name: script.Name,
|
||||||
|
priority: script.Priority,
|
||||||
|
sequence: script.Sequence,
|
||||||
|
err: err,
|
||||||
|
})
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
return fmt.Errorf("script %s (Priority=%d, Sequence=%d): %w",
|
||||||
script.Name, script.Priority, script.Sequence, err)
|
script.Name, script.Priority, script.Sequence, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
successCount++
|
||||||
fmt.Printf("✓ Successfully executed: %s\n", script.Name)
|
fmt.Printf("✓ Successfully executed: %s\n", script.Name)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Store execution results in metadata for caller
|
||||||
|
w.options.Metadata["execution_total"] = totalCount
|
||||||
|
w.options.Metadata["execution_success"] = successCount
|
||||||
|
w.options.Metadata["execution_failed"] = len(failedScripts)
|
||||||
|
|
||||||
|
// Print summary of failed scripts if any
|
||||||
|
if len(failedScripts) > 0 {
|
||||||
|
fmt.Printf("\n⚠ Failed Scripts Summary (%d failed):\n", len(failedScripts))
|
||||||
|
for i, failed := range failedScripts {
|
||||||
|
fmt.Printf(" %d. %s (Priority=%d, Sequence=%d)\n Error: %v\n",
|
||||||
|
i+1, failed.name, failed.priority, failed.sequence, failed.err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -99,13 +99,13 @@ func TestWriter_WriteTable(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TestScriptSorting verifies that scripts are sorted correctly by Priority then Sequence
|
// TestScriptSorting verifies that scripts are sorted correctly by Priority, Sequence, then Name
|
||||||
func TestScriptSorting(t *testing.T) {
|
func TestScriptSorting(t *testing.T) {
|
||||||
scripts := []*models.Script{
|
scripts := []*models.Script{
|
||||||
{Name: "script1", Priority: 2, Sequence: 1, SQL: "SELECT 1;"},
|
{Name: "z_script1", Priority: 2, Sequence: 1, SQL: "SELECT 1;"},
|
||||||
{Name: "script2", Priority: 1, Sequence: 3, SQL: "SELECT 2;"},
|
{Name: "script2", Priority: 1, Sequence: 3, SQL: "SELECT 2;"},
|
||||||
{Name: "script3", Priority: 1, Sequence: 1, SQL: "SELECT 3;"},
|
{Name: "a_script3", Priority: 1, Sequence: 1, SQL: "SELECT 3;"},
|
||||||
{Name: "script4", Priority: 1, Sequence: 2, SQL: "SELECT 4;"},
|
{Name: "b_script4", Priority: 1, Sequence: 1, SQL: "SELECT 4;"},
|
||||||
{Name: "script5", Priority: 3, Sequence: 1, SQL: "SELECT 5;"},
|
{Name: "script5", Priority: 3, Sequence: 1, SQL: "SELECT 5;"},
|
||||||
{Name: "script6", Priority: 2, Sequence: 2, SQL: "SELECT 6;"},
|
{Name: "script6", Priority: 2, Sequence: 2, SQL: "SELECT 6;"},
|
||||||
}
|
}
|
||||||
@@ -114,25 +114,35 @@ func TestScriptSorting(t *testing.T) {
|
|||||||
sortedScripts := make([]*models.Script, len(scripts))
|
sortedScripts := make([]*models.Script, len(scripts))
|
||||||
copy(sortedScripts, scripts)
|
copy(sortedScripts, scripts)
|
||||||
|
|
||||||
// Use the same sorting logic from executeScripts
|
// Sort by Priority, Sequence, then Name (matching executeScripts logic)
|
||||||
for i := 0; i < len(sortedScripts)-1; i++ {
|
for i := 0; i < len(sortedScripts)-1; i++ {
|
||||||
for j := i + 1; j < len(sortedScripts); j++ {
|
for j := i + 1; j < len(sortedScripts); j++ {
|
||||||
if sortedScripts[i].Priority > sortedScripts[j].Priority ||
|
si, sj := sortedScripts[i], sortedScripts[j]
|
||||||
(sortedScripts[i].Priority == sortedScripts[j].Priority &&
|
// Compare by priority first
|
||||||
sortedScripts[i].Sequence > sortedScripts[j].Sequence) {
|
if si.Priority > sj.Priority {
|
||||||
sortedScripts[i], sortedScripts[j] = sortedScripts[j], sortedScripts[i]
|
sortedScripts[i], sortedScripts[j] = sortedScripts[j], sortedScripts[i]
|
||||||
|
} else if si.Priority == sj.Priority {
|
||||||
|
// If same priority, compare by sequence
|
||||||
|
if si.Sequence > sj.Sequence {
|
||||||
|
sortedScripts[i], sortedScripts[j] = sortedScripts[j], sortedScripts[i]
|
||||||
|
} else if si.Sequence == sj.Sequence {
|
||||||
|
// If same sequence, compare by name
|
||||||
|
if si.Name > sj.Name {
|
||||||
|
sortedScripts[i], sortedScripts[j] = sortedScripts[j], sortedScripts[i]
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Expected order after sorting
|
// Expected order after sorting (Priority -> Sequence -> Name)
|
||||||
expectedOrder := []string{
|
expectedOrder := []string{
|
||||||
"script3", // Priority 1, Sequence 1
|
"a_script3", // Priority 1, Sequence 1, Name a_script3
|
||||||
"script4", // Priority 1, Sequence 2
|
"b_script4", // Priority 1, Sequence 1, Name b_script4
|
||||||
"script2", // Priority 1, Sequence 3
|
"script2", // Priority 1, Sequence 3
|
||||||
"script1", // Priority 2, Sequence 1
|
"z_script1", // Priority 2, Sequence 1
|
||||||
"script6", // Priority 2, Sequence 2
|
"script6", // Priority 2, Sequence 2
|
||||||
"script5", // Priority 3, Sequence 1
|
"script5", // Priority 3, Sequence 1
|
||||||
}
|
}
|
||||||
|
|
||||||
for i, expected := range expectedOrder {
|
for i, expected := range expectedOrder {
|
||||||
@@ -153,6 +163,13 @@ func TestScriptSorting(t *testing.T) {
|
|||||||
t.Errorf("Sequence not ascending at position %d with same priority %d: %d > %d",
|
t.Errorf("Sequence not ascending at position %d with same priority %d: %d > %d",
|
||||||
i, sortedScripts[i].Priority, sortedScripts[i].Sequence, sortedScripts[i+1].Sequence)
|
i, sortedScripts[i].Priority, sortedScripts[i].Sequence, sortedScripts[i+1].Sequence)
|
||||||
}
|
}
|
||||||
|
// Within same priority and sequence, names should be ascending
|
||||||
|
if sortedScripts[i].Priority == sortedScripts[i+1].Priority &&
|
||||||
|
sortedScripts[i].Sequence == sortedScripts[i+1].Sequence &&
|
||||||
|
sortedScripts[i].Name > sortedScripts[i+1].Name {
|
||||||
|
t.Errorf("Name not ascending at position %d with same priority/sequence: %s > %s",
|
||||||
|
i, sortedScripts[i].Name, sortedScripts[i+1].Name)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -28,10 +28,29 @@ type WriterOptions struct {
|
|||||||
// PackageName is the Go package name (for code generation)
|
// PackageName is the Go package name (for code generation)
|
||||||
PackageName string
|
PackageName string
|
||||||
|
|
||||||
|
// FlattenSchema disables schema.table dot notation and instead joins
|
||||||
|
// schema and table with an underscore (e.g., "public_users").
|
||||||
|
// Useful for databases like SQLite that do not support schemas.
|
||||||
|
FlattenSchema bool
|
||||||
|
|
||||||
// Additional options can be added here as needed
|
// Additional options can be added here as needed
|
||||||
Metadata map[string]interface{}
|
Metadata map[string]interface{}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// QualifiedTableName returns a schema-qualified table name.
|
||||||
|
// When flatten is true, schema and table are joined with underscore (e.g., "schema_table").
|
||||||
|
// When flatten is false, they are dot-separated (e.g., "schema.table").
|
||||||
|
// If schema is empty, just the table name is returned regardless of flatten.
|
||||||
|
func QualifiedTableName(schema, table string, flatten bool) string {
|
||||||
|
if schema == "" {
|
||||||
|
return table
|
||||||
|
}
|
||||||
|
if flatten {
|
||||||
|
return schema + "_" + table
|
||||||
|
}
|
||||||
|
return schema + "." + table
|
||||||
|
}
|
||||||
|
|
||||||
// SanitizeFilename removes quotes, comments, and invalid characters from identifiers
|
// SanitizeFilename removes quotes, comments, and invalid characters from identifiers
|
||||||
// to make them safe for use in filenames. This handles:
|
// to make them safe for use in filenames. This handles:
|
||||||
// - Double and single quotes: "table_name" or 'table_name' -> table_name
|
// - Double and single quotes: "table_name" or 'table_name' -> table_name
|
||||||
|
|||||||
Reference in New Issue
Block a user