Skip to content

Commit

Permalink
rename go moudle name, fix unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
sjjian committed Apr 21, 2021
1 parent f3737bb commit c0aa1ca
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 127 deletions.
2 changes: 1 addition & 1 deletion ast/mapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,5 @@ func (m *Mapper) GetStmt(ctx *Context) (string, error) {
}
buff.WriteString("\n")
}
return buff.String(), nil
return strings.TrimSuffix(buff.String(), "\n"), nil
}
3 changes: 2 additions & 1 deletion ast/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ package ast
import (
"bytes"
"encoding/xml"
"mybatis_mapper_2_sql/sqlfmt"

"github.com/sjjian/mybatis-mapper-2-sql/sqlfmt"
)

type QueryNode struct {
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
module mybatis_mapper_2_sql
module github.com/sjjian/mybatis-mapper-2-sql

go 1.14

require (
github.com/pingcap/parser v0.0.0-20201112065012-c9380f220ff9
github.com/pingcap/tidb v1.1.0-beta.0.20201113172225-f9f44d0a492a
)
)
120 changes: 0 additions & 120 deletions go.sum

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ package main
import (
"encoding/xml"
"io"
"mybatis_mapper_2_sql/ast"
"strings"

"github.com/sjjian/mybatis-mapper-2-sql/ast"
)

func ParseXML(data string) (string, error) {
Expand Down
2 changes: 1 addition & 1 deletion parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,6 @@ func TestParserFullFile(t *testing.T) {
"SELECT `name`,`category`,`price` FROM `fruits` WHERE `name`=? AND `category`=? AND `price`=? AND `category`=\"apple\";\n"+
"SELECT `name`,`category`,`price` FROM `fruits` WHERE `category`=\"apple\" AND (`name`=? OR `name`=?);\n"+
"INSERT INTO `fruits` (`name`,`category`,`price`) VALUES (?,?,?),(?,?,?);\n"+
"SELECT `name`,`category`,`price` FROM `fruits` WHERE `name` LIKE ?;\n",
"SELECT `name`,`category`,`price` FROM `fruits` WHERE `name` LIKE ?;",
)
}
3 changes: 2 additions & 1 deletion sqlfmt/sqlfmt.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
package sqlfmt

import (
"strings"

"github.com/pingcap/parser"
"github.com/pingcap/parser/ast"
"github.com/pingcap/parser/format"
_ "github.com/pingcap/tidb/types/parser_driver"
driver "github.com/pingcap/tidb/types/parser_driver"
"strings"
)

func FormatSQL(sql string) string {
Expand Down

0 comments on commit c0aa1ca

Please sign in to comment.