-
-
Notifications
You must be signed in to change notification settings - Fork 162
Add ability to skip cleaning the output directory #520
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Add ability to skip cleaning the output directory #520
Conversation
Codecov Report❌ Patch coverage is
❌ Your patch check has failed because the patch coverage (11.11%) is below the target coverage (90.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## master #520 +/- ##
==========================================
- Coverage 91.35% 90.95% -0.41%
==========================================
Files 136 136
Lines 8340 8380 +40
==========================================
+ Hits 7619 7622 +3
- Misses 545 581 +36
- Partials 176 177 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This shouldn't be the case. If you regenerate How are you invoking the generator? |
I'm invoking the generator using Go in a mage script. I only want to generate the SQL builders into this package. for _, schemaName := range store.SchemaNames {
err = postgres.Generate(db, schemaName,
[]template.Template{
template.Default(postgres2.Dialect).
UseSchema(func(schemaMetaData metadata.Schema) template.Schema {
var skipModel = template.DefaultModel()
skipModel.Skip = true
return template.DefaultSchema(schemaMetaData).
UsePath(filepath.Join("schema")).
UseModel(skipModel).
UseSQLBuilder(template.DefaultSQLBuilder().
UseEnum(func(enum metadata.Enum) template.EnumSQLBuilder {
skipEnum := template.DefaultEnumSQLBuilder(enum)
skipEnum.Skip = true
return skipEnum
}).
UseView(func(table metadata.Table) template.ViewSQLBuilder {
skipView := template.DefaultViewSQLBuilder(table)
skipView.Skip = true
return skipView
}).
UseTable(func(table metadata.Table) template.TableSQLBuilder {
skipTable := template.DefaultTableSQLBuilder(table)
skipTable.Skip = true
if slices.Contains(skipTables[:], table.Name) {
return skipTable
}
return template.DefaultTableSQLBuilder(table).
UsePath(schemaName).
UseFileName(fmt.Sprintf("%s%s.go", strman.SnakeLower(table.Name), genSuffix)).
UseColumn(func(column metadata.Column) template.TableSQLBuilderColumn {
return template.DefaultTableSQLBuilderColumn(column)
})
}),
)
}),
}
)
if err != nil {
return fmt.Errorf("failed to generate Jet code for schema %s: %w", schemaName, err)
}
} I had played around with calling |
func Generate(destDir string, dbConn DBConnection, genTemplate ...template.Template) (err error) {
There is also func GenerateDSN(dsn, schema, destDir string, templates ...template.Template) error { , and the destination directory to generate(and clean) is at |
I've run into a snag recently while using Jet's postgres generator. It completely cleans the output directory when it goes to process code generation on a database schema.
The way that my project is set up, I want to generate multiple schemas into the same directory while also having each schema be in its own subpackage:
Unfortunately I can't do this when I call
ProcessDB
multiple times, because it ends up clearing the/schema
folder of the files it just generated.I tried my best to make the proposed changes backwards compatible but I'm open to feedback. I'll maintain a fork of jet for now but I'd love to see this feature merged.
Thanks