MCPcopy
hub / github.com/sqldef/sqldef / parseGeneratorConfigFromBytes

Function parseGeneratorConfigFromBytes

database/database.go:357–429  ·  view source on GitHub ↗
(buf []byte, defaults GeneratorConfig)

Source from the content-addressed store, hash-verified

355}
356
357func parseGeneratorConfigFromBytes(buf []byte, defaults GeneratorConfig) GeneratorConfig {
358 var config struct {
359 TargetTables string `yaml:"target_tables"`
360 SkipTables string `yaml:"skip_tables"`
361 SkipViews string `yaml:"skip_views"`
362 TargetSchema string `yaml:"target_schema"`
363 Algorithm string `yaml:"algorithm"`
364 Lock string `yaml:"lock"`
365 DumpConcurrency int `yaml:"dump_concurrency"`
366 ManagedRoles []string `yaml:"managed_roles"`
367 EnableDrop bool `yaml:"enable_drop"`
368 CreateIndexConcurrently bool `yaml:"create_index_concurrently"`
369 DisableDdlTransaction bool `yaml:"disable_ddl_transaction"`
370 LegacyIgnoreQuotes *bool `yaml:"legacy_ignore_quotes"`
371 }
372
373 dec := yaml.NewDecoder(bytes.NewReader(buf), yaml.DisallowUnknownField())
374 err := dec.Decode(&config)
375 if err != nil {
376 log.Fatal(err)
377 }
378
379 var targetTables []string
380 if config.TargetTables != "" {
381 targetTables = strings.Split(strings.Trim(config.TargetTables, "\n"), "\n")
382 }
383
384 var skipTables []string
385 if config.SkipTables != "" {
386 skipTables = strings.Split(strings.Trim(config.SkipTables, "\n"), "\n")
387 }
388
389 var skipViews []string
390 if config.SkipViews != "" {
391 skipViews = strings.Split(strings.Trim(config.SkipViews, "\n"), "\n")
392 }
393
394 var targetSchema []string
395 if config.TargetSchema != "" {
396 targetSchema = strings.Split(strings.Trim(config.TargetSchema, "\n"), "\n")
397 }
398
399 var algorithm string
400 if config.Algorithm != "" {
401 algorithm = strings.Trim(config.Algorithm, "\n")
402 }
403
404 var lock string
405 if config.Lock != "" {
406 lock = strings.Trim(config.Lock, "\n")
407 }
408
409 // Use the provided default, override if explicitly set in config
410 legacyIgnoreQuotes := defaults.LegacyIgnoreQuotes
411 if config.LegacyIgnoreQuotes != nil {
412 legacyIgnoreQuotes = *config.LegacyIgnoreQuotes
413 }
414

Callers 2

ParseGeneratorConfigFunction · 0.85

Calls 1

FatalMethod · 0.65

Tested by

no test coverage detected