-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathtable.go
50 lines (41 loc) · 1003 Bytes
/
table.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package ddlmaker
import (
"github.com/kayac/ddl-maker/dialect"
)
// Table is mapping struct info
type table struct {
name string
primaryKey dialect.PrimaryKey
foreignKeys dialect.ForeignKeys
columns []dialect.Column
indexes dialect.Indexes
dialect dialect.Dialect
}
func newTable(name string, pk dialect.PrimaryKey, fks dialect.ForeignKeys, columns []dialect.Column, indexes dialect.Indexes, d dialect.Dialect) table {
return table{
name: name,
primaryKey: pk,
foreignKeys: fks,
columns: columns,
indexes: indexes,
dialect: d,
}
}
func (t table) Name() string {
return t.dialect.Quote(t.name)
}
func (t table) PrimaryKey() dialect.PrimaryKey {
return t.primaryKey
}
func (t table) ForeignKeys() dialect.ForeignKeys {
return t.foreignKeys
}
func (t table) Columns() []dialect.Column {
return t.columns
}
func (t table) Indexes() dialect.Indexes {
return t.indexes
}
func (t table) Dialect() dialect.Dialect {
return t.dialect
}