Added database prefix of cache key. (#835)

This commit is contained in:
fangjianwei
2021-07-22 11:29:09 +08:00
committed by GitHub
parent 75952308f9
commit 476026e393
10 changed files with 60 additions and 49 deletions

View File

@@ -21,6 +21,7 @@ type (
// Table describes a mysql table
Table struct {
Name stringx.String
Db stringx.String
PrimaryKey Primary
UniqueIndex map[string][]*Field
Fields []*Field
@@ -46,7 +47,7 @@ type (
)
// Parse parses ddl into golang structure
func Parse(filename string) ([]*Table, error) {
func Parse(filename string, database string) ([]*Table, error) {
p := parser.NewParser()
tables, err := p.From(filename)
if err != nil {
@@ -145,6 +146,7 @@ func Parse(filename string) ([]*Table, error) {
list = append(list, &Table{
Name: stringx.From(e.Name),
Db: stringx.From(database),
PrimaryKey: primaryKey,
UniqueIndex: uniqueIndex,
Fields: fields,
@@ -243,6 +245,7 @@ func ConvertDataType(table *model.Table) (*Table, error) {
var reply Table
reply.UniqueIndex = map[string][]*Field{}
reply.Name = stringx.From(table.Table)
reply.Db = stringx.From(table.Db)
seqInIndex := 0
if table.PrimaryKey.Index != nil {
seqInIndex = table.PrimaryKey.Index.SeqInIndex