-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from ColdWaterLW/support-1746
Support 1746
- Loading branch information
Showing
28 changed files
with
6,202 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package ast | ||
|
||
import ( | ||
"errors" | ||
"fmt" | ||
) | ||
|
||
type Mappers struct { | ||
mappers []*Mapper | ||
} | ||
|
||
func NewMappers() *Mappers { | ||
return &Mappers{} | ||
} | ||
|
||
func (s *Mappers) AddMapper(ms ...*Mapper) error { | ||
for _, m := range ms { | ||
if m == nil { | ||
return errors.New("can not add null mapper to mappers") | ||
} | ||
s.mappers = append(s.mappers, m) | ||
} | ||
return nil | ||
} | ||
|
||
func (s *Mappers) GetStmts(skipErrorQuery bool) ([]string, error) { | ||
ctx := NewContext() | ||
stmts := []string{} | ||
for _, m := range s.mappers { | ||
for id, node := range m.SqlNodes { | ||
ctx.Sqls[fmt.Sprintf("%v.%v", m.NameSpace, id)] = node | ||
} | ||
} | ||
|
||
for _, m := range s.mappers { | ||
ctx.DefaultNamespace = m.NameSpace | ||
stmt, err := m.GetStmts(ctx, skipErrorQuery) | ||
if err != nil { | ||
return nil, fmt.Errorf("get sqls from mapper failed, namespace: %v, err: %v", m.NameSpace, err) | ||
} | ||
stmts = append(stmts, stmt...) | ||
} | ||
return stmts, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.