feat(dbml): support multiline table notes in DBML
* Add parsing for triple-quoted table notes in DBML * Update writer to format multiline notes correctly * Enhance tests for multiline table notes handling
This commit is contained in:
@@ -59,6 +59,23 @@ func TestWriter_WriteTable(t *testing.T) {
|
||||
assert.Contains(t, output, "Note: 'User accounts table'")
|
||||
}
|
||||
|
||||
func TestWriter_WriteTable_MultilineNote(t *testing.T) {
|
||||
table := models.InitTable("cities", "info")
|
||||
table.Description = "Cities and municipalities worldwide.\n\nSPATIAL:\nProximity queries use a GiST index."
|
||||
|
||||
outputPath := filepath.Join(t.TempDir(), "cities.dbml")
|
||||
writer := NewWriter(&writers.WriterOptions{OutputPath: outputPath})
|
||||
if err := writer.WriteTable(table); err != nil {
|
||||
t.Fatalf("WriteTable() error = %v", err)
|
||||
}
|
||||
|
||||
output, err := os.ReadFile(outputPath)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to read generated DBML: %v", err)
|
||||
}
|
||||
assert.Contains(t, string(output), "Note: '''\nCities and municipalities worldwide.\n\nSPATIAL:\nProximity queries use a GiST index.\n '''")
|
||||
}
|
||||
|
||||
func TestWriter_WriteDatabase_WithRelationships(t *testing.T) {
|
||||
db := models.InitDatabase("test_db")
|
||||
schema := models.InitSchema("public")
|
||||
|
||||
Reference in New Issue
Block a user