Schema rename support
- Support for renaming table schemas * Table support for renaming schema * Empty schema name is left out (using default schema for the database connection) * Generated code support for obtaining a version of the table with renamed schema, similarly as the `AS` function works * Unit tests for setting and clearing the schema name
This commit is contained in:
parent
7bafa1ffef
commit
1e511654fd
3 changed files with 76 additions and 2 deletions
|
|
@ -41,6 +41,15 @@ type {{.GoStructName}} struct {
|
|||
func (a *{{.GoStructName}}) AS(alias string) {{.GoStructName}} {
|
||||
aliasTable := new{{.GoStructName}}()
|
||||
aliasTable.Table.AS(alias)
|
||||
aliasTable.Table.Schema(a.Table.SchemaName())
|
||||
return aliasTable
|
||||
}
|
||||
|
||||
// Schema creates new {{.GoStructName}} with assigned schema name
|
||||
func (a *{{.GoStructName}}) Schema(schemaName string) {{.GoStructName}} {
|
||||
aliasTable := new{{.GoStructName}}()
|
||||
aliasTable.Table.AS(a.Table.Alias())
|
||||
aliasTable.Table.Schema(schemaName)
|
||||
return aliasTable
|
||||
}
|
||||
|
||||
|
|
@ -104,6 +113,15 @@ type {{.GoStructName}} struct {
|
|||
func (a *{{.GoStructName}}) AS(alias string) *{{.GoStructName}} {
|
||||
aliasTable := new{{.GoStructName}}()
|
||||
aliasTable.Table.AS(alias)
|
||||
aliasTable.Table.Schema(a.Table.SchemaName())
|
||||
return aliasTable
|
||||
}
|
||||
|
||||
// Schema creates new {{.GoStructName}} with assigned schema name
|
||||
func (a *{{.GoStructName}}) Schema(schemaName string) *{{.GoStructName}} {
|
||||
aliasTable := new{{.GoStructName}}()
|
||||
aliasTable.Table.AS(a.Table.Alias())
|
||||
aliasTable.Table.Schema(schemaName)
|
||||
return aliasTable
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue