Model sql tags.
This commit is contained in:
parent
367602757f
commit
c598978ba6
10 changed files with 110 additions and 67 deletions
|
|
@ -81,6 +81,20 @@ func (c ColumnInfo) GoModelType() string {
|
|||
return typeStr
|
||||
}
|
||||
|
||||
func (c ColumnInfo) GoModelTag(isPrimaryKey bool) string {
|
||||
tags := []string{}
|
||||
|
||||
if isPrimaryKey {
|
||||
tags = append(tags, "primary_key")
|
||||
}
|
||||
|
||||
if len(tags) > 0 {
|
||||
return "`sql:\"" + strings.Join(tags, ",") + "\"`"
|
||||
}
|
||||
|
||||
return ""
|
||||
}
|
||||
|
||||
func getColumnInfos(db *sql.DB, dbName, schemaName, tableName string) ([]ColumnInfo, error) {
|
||||
|
||||
query := `
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue