@@ -40,7 +40,7 @@ func Generate(dir string, stderr io.Writer) (map[string]string, error) {
4040 return nil , err
4141 }
4242
43- settings , err := config .ParseConfig (bytes .NewReader (blob ))
43+ conf , err := config .ParseConfig (bytes .NewReader (blob ))
4444 if err != nil {
4545 switch err {
4646 case config .ErrMissingVersion :
@@ -57,20 +57,19 @@ func Generate(dir string, stderr io.Writer) (map[string]string, error) {
5757 output := map [string ]string {}
5858 errored := false
5959
60- for _ , pkg := range settings . Packages {
61- name := pkg . Name
62- combo := config . Combine ( settings , pkg )
60+ for _ , sql := range conf . SQL {
61+ combo := config . Combine ( conf , sql )
62+ name := combo . Go . Package
6363 var result dinosql.Generateable
6464
6565 // TODO: This feels like a hack that will bite us later
66- pkg .Schema = filepath .Join (dir , pkg .Schema )
67- pkg .Queries = filepath .Join (dir , pkg .Queries )
68-
69- switch pkg .Engine {
66+ sql .Schema = filepath .Join (dir , sql .Schema )
67+ sql .Queries = filepath .Join (dir , sql .Queries )
7068
69+ switch sql .Engine {
7170 case config .EngineMySQL :
7271 // Experimental MySQL support
73- q , err := mysql .GeneratePkg (name , pkg .Schema , pkg .Queries , combo )
72+ q , err := mysql .GeneratePkg (name , sql .Schema , sql .Queries , combo )
7473 if err != nil {
7574 fmt .Fprintf (stderr , "# package %s\n " , name )
7675 if parserErr , ok := err .(* dinosql.ParserErr ); ok {
@@ -86,7 +85,7 @@ func Generate(dir string, stderr io.Writer) (map[string]string, error) {
8685 result = q
8786
8887 case config .EnginePostgreSQL :
89- c , err := dinosql .ParseCatalog (pkg .Schema )
88+ c , err := dinosql .ParseCatalog (sql .Schema )
9089 if err != nil {
9190 fmt .Fprintf (stderr , "# package %s\n " , name )
9291 if parserErr , ok := err .(* dinosql.ParserErr ); ok {
@@ -100,7 +99,7 @@ func Generate(dir string, stderr io.Writer) (map[string]string, error) {
10099 continue
101100 }
102101
103- q , err := dinosql .ParseQueries (c , pkg )
102+ q , err := dinosql .ParseQueries (c , sql )
104103 if err != nil {
105104 fmt .Fprintf (stderr , "# package %s\n " , name )
106105 if parserErr , ok := err .(* dinosql.ParserErr ); ok {
@@ -126,7 +125,7 @@ func Generate(dir string, stderr io.Writer) (map[string]string, error) {
126125 }
127126
128127 for n , source := range files {
129- filename := filepath .Join (dir , pkg . Path , n )
128+ filename := filepath .Join (dir , combo . Go . Out , n )
130129 output [filename ] = source
131130 }
132131 }
0 commit comments