table is now required

This commit is contained in:
Simon Vieille 2024-03-18 09:01:50 +01:00
commit c493ad89da
Signed by untrusted user: deblan
GPG key ID: 579388D585F70417

View file

@ -19,12 +19,14 @@ type App struct {
func (a *App) ApplyRule(c config.SchemaConfigData, globalColumns map[string]string, generators map[string][]string) error { func (a *App) ApplyRule(c config.SchemaConfigData, globalColumns map[string]string, generators map[string][]string) error {
var query string var query string
if c.Table == "" {
return errors.New("Table must be defined")
}
if c.Query != "" { if c.Query != "" {
query = c.Query query = c.Query
} else if c.Table != "" {
query = fmt.Sprintf("SELECT * FROM %s", c.Table)
} else { } else {
return errors.New("No query and no table defined") query = fmt.Sprintf("SELECT * FROM %s", c.Table)
} }
if len(c.PrimaryKey) == 0 { if len(c.PrimaryKey) == 0 {