add columntype method for table
This commit is contained in:
parent
833d5b7beb
commit
6759548865
11
table.go
11
table.go
|
@ -65,13 +65,18 @@ func (table *Table) GetColumnIdx(name string, idx int) *Column {
|
||||||
|
|
||||||
// if has primary key, return column
|
// if has primary key, return column
|
||||||
func (table *Table) PKColumns() []*Column {
|
func (table *Table) PKColumns() []*Column {
|
||||||
columns := make([]*Column, 0)
|
columns := make([]*Column, len(table.PrimaryKeys))
|
||||||
for _, name := range table.PrimaryKeys {
|
for i, name := range table.PrimaryKeys {
|
||||||
columns = append(columns, table.GetColumn(name))
|
columns[i] = table.GetColumn(name)
|
||||||
}
|
}
|
||||||
return columns
|
return columns
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (table *Table) ColumnType(name string) reflect.Type {
|
||||||
|
t, _ := table.Type.FieldByName(name)
|
||||||
|
return t.Type
|
||||||
|
}
|
||||||
|
|
||||||
func (table *Table) AutoIncrColumn() *Column {
|
func (table *Table) AutoIncrColumn() *Column {
|
||||||
return table.GetColumn(table.AutoIncrement)
|
return table.GetColumn(table.AutoIncrement)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue