-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathsql.parser.insert.go
More file actions
54 lines (49 loc) · 878 Bytes
/
sql.parser.insert.go
File metadata and controls
54 lines (49 loc) · 878 Bytes
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
51
52
53
54
package sqlparser
import (
"github.com/xwb1989/sqlparser"
)
//-------------------------------------
//
//
//
//-------------------------------------
type insertSql struct {
result *SQLParserResult
node *sqlparser.Insert
tableMap map[string]*DBTable
}
//
//
//
//
//
func newInsertSql(r *SQLParserResult, n *sqlparser.Insert) *insertSql {
return &insertSql{
r,
n,
map[string]*DBTable{},
}
}
//
//
//
//
//
func (ss *insertSql) doParser() error {
ss.visitSimpleTable(ss.node.Table, "")
for _, column := range ss.node.Columns {
newColumn(ss.result, column, ss.tableMap).doParser()
}
return nil
}
//
//
//
//
//
func (ss *insertSql) visitSimpleTable(table *sqlparser.TableName, alias string) {
dbOwner := string(table.Qualifier)
tableName := string(table.Name)
dbTable := ss.result.AddTable(dbOwner, tableName, alias)
ss.tableMap[alias] = dbTable
}