Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func QualifiedTableName ¶ added in v1.0.30
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 SanitizeFilename ¶ added in v1.0.7
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 - DBML comments: table [note: 'description'] -> table - Invalid filename characters: replaced with underscores
func SanitizeStructTagValue ¶ added in v1.0.8
SanitizeStructTagValue sanitizes a value to be safely used inside Go struct tags. Go struct tags are delimited by backticks, so any backtick in the value would break the syntax. This function: - Removes DBML/DCTX comments in brackets - Removes all quotes (double, single, and backticks) - Returns a clean identifier safe for use in struct tags and field names
Types ¶
type Writer ¶
type Writer interface {
// WriteDatabase takes a Database model and writes it to the desired format
WriteDatabase(db *models.Database) error
// WriteSchema takes a Schema model and writes it to the desired format
WriteSchema(schema *models.Schema) error
// WriteTable takes a Table model and writes it to the desired format
WriteTable(table *models.Table) error
}
Writer defines the interface for writing database specifications to various output formats at different granularity levels
type WriterOptions ¶
type WriterOptions struct {
// OutputPath is the path where the output should be written
OutputPath string
// 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{}
}
WriterOptions contains common options for writers