Skip to content

Commit

Permalink
Revert "wip: added --no-schema option scaffolding, needs tests"
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenafamo authored Nov 13, 2024
1 parent dafaf41 commit cf52ee2
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 35 deletions.
1 change: 0 additions & 1 deletion boilingcore/templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ type templateData struct {
RQ string

// Control various generation features
// NoOutputSchema, which is also used for generation, is defined in the drivers configuration
AddGlobal bool
AddPanic bool
AddSoftDeletes bool
Expand Down
15 changes: 0 additions & 15 deletions drivers/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,21 +93,6 @@ func (c Config) DefaultString(key, def string) string {
return str
}

// DefaultBool retrieves a non-empty bool or the default value provided.
func (c Config) DefaultBool(key string, def bool) bool {
b, ok := c[key]
if !ok {
return def
}

bul, ok := b.(bool)
if !ok {
return def
}

return bul
}

// Int retrieves an int, the bool says if it exists, is of the appropriate type,
// and is non-zero. Coerces float64 to int because JSON and Javascript kinda suck.
func (c Config) Int(key string) (int, bool) {
Expand Down
1 change: 0 additions & 1 deletion drivers/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ const (
ConfigBlacklist = "blacklist"
ConfigWhitelist = "whitelist"
ConfigSchema = "schema"
ConfigNoOutputSchema = "no-output-schema" // Determine if templates/output include a schema, even if we used one to gather info
ConfigAddEnumTypes = "add-enum-types"
ConfigEnumNullPrefix = "enum-null-prefix"
ConfigConcurrency = "concurrency"
Expand Down
13 changes: 2 additions & 11 deletions drivers/sqlboiler-psql/driver/psql.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,20 +97,11 @@ func (p *PostgresDriver) Assemble(config drivers.Config) (dbinfo *drivers.DBInfo
port := config.DefaultInt(drivers.ConfigPort, 5432)
sslmode := config.DefaultString(drivers.ConfigSSLMode, "require")
schema := config.DefaultString(drivers.ConfigSchema, "public")
noOutputSchema := config.DefaultBool(drivers.ConfigNoOutputSchema, false)
whitelist, _ := config.StringSlice(drivers.ConfigWhitelist)
blacklist, _ := config.StringSlice(drivers.ConfigBlacklist)
concurrency := config.DefaultInt(drivers.ConfigConcurrency, drivers.DefaultConcurrency)

switch {
case noOutputSchema:
break
case schema == "public":
noOutputSchema = true
default:
// just to be explicit, even though it's the default in the getter
noOutputSchema = false
}
useSchema := schema != "public"

p.addEnumTypes, _ = config[drivers.ConfigAddEnumTypes].(bool)
p.enumNullPrefix = strmangle.TitleCase(config.DefaultString(drivers.ConfigEnumNullPrefix, "Null"))
Expand Down Expand Up @@ -144,7 +135,7 @@ func (p *PostgresDriver) Assemble(config drivers.Config) (dbinfo *drivers.DBInfo
RQ: '"',

UseIndexPlaceholders: true,
UseSchema: !noOutputSchema,
UseSchema: useSchema,
UseDefaultKeyword: true,
},
}
Expand Down
12 changes: 5 additions & 7 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ func main() {
rootCmd.PersistentFlags().BoolP("no-auto-timestamps", "", false, "Disable automatic timestamps for created_at/updated_at")
rootCmd.PersistentFlags().BoolP("no-driver-templates", "", false, "Disable parsing of templates defined by the database driver")
rootCmd.PersistentFlags().BoolP("no-back-referencing", "", false, "Disable back referencing in the loaded relationship structs")
rootCmd.PersistentFlags().BoolP("no-schema", "", false, "Disable generating a schema in the output")
rootCmd.PersistentFlags().BoolP("always-wrap-errors", "", false, "Wrap all returned errors with stacktraces, also sql.ErrNoRows")
rootCmd.PersistentFlags().BoolP("add-global-variants", "", false, "Enable generation for global variants")
rootCmd.PersistentFlags().BoolP("add-panic-variants", "", false, "Enable generation for panic variants")
Expand Down Expand Up @@ -214,12 +213,11 @@ func preRun(cmd *cobra.Command, args []string) error {

// Configure the driver
cmdConfig.DriverConfig = map[string]interface{}{
"whitelist": viper.GetStringSlice(driverName + ".whitelist"),
"blacklist": viper.GetStringSlice(driverName + ".blacklist"),
drivers.ConfigNoOutputSchema: viper.GetBool("no-schema"),
"add-enum-types": cmdConfig.AddEnumTypes,
"enum-null-prefix": cmdConfig.EnumNullPrefix,
"foreign-keys": cmdConfig.ForeignKeys,
"whitelist": viper.GetStringSlice(driverName + ".whitelist"),
"blacklist": viper.GetStringSlice(driverName + ".blacklist"),
"add-enum-types": cmdConfig.AddEnumTypes,
"enum-null-prefix": cmdConfig.EnumNullPrefix,
"foreign-keys": cmdConfig.ForeignKeys,
}

keys := allKeys(driverName)
Expand Down

0 comments on commit cf52ee2

Please sign in to comment.