feat(relations): 🎉 add flatten schema option for output
All checks were successful
CI / Test (1.24) (push) Successful in -25m5s
CI / Test (1.25) (push) Successful in -24m57s
CI / Build (push) Successful in -26m5s
CI / Lint (push) Successful in -25m51s
Integration Tests / Integration Tests (push) Successful in -25m42s
Release / Build and Release (push) Successful in -24m39s
All checks were successful
CI / Test (1.24) (push) Successful in -25m5s
CI / Test (1.25) (push) Successful in -24m57s
CI / Build (push) Successful in -26m5s
CI / Lint (push) Successful in -25m51s
Integration Tests / Integration Tests (push) Successful in -25m42s
Release / Build and Release (push) Successful in -24m39s
* Introduce `--flatten-schema` flag to convert, merge, and split commands. * Modify database writing functions to support flattened schema names. * Update template functions to handle schema.table naming convention. * Enhance PostgreSQL writer to utilize flattened schema in generated SQL. * Update tests to ensure compatibility with new flattening feature. * Dependencies updated for improved functionality.
This commit is contained in:
@@ -28,10 +28,29 @@ type WriterOptions struct {
|
||||
// PackageName is the Go package name (for code generation)
|
||||
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
|
||||
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
|
||||
// to make them safe for use in filenames. This handles:
|
||||
// - Double and single quotes: "table_name" or 'table_name' -> table_name
|
||||
|
||||
Reference in New Issue
Block a user