Skip to content

Commit 477809b

Browse files
committed
clean package
1 parent 2a4ba85 commit 477809b

16 files changed

Lines changed: 77 additions & 80 deletions

File tree

.travis.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
language: go
22

33
go:
4-
- 1.13.x
5-
- 1.14.x
4+
- 1.25.x
65

76
env: GO111MODULE=on
87

element/column.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313
"github.com/pingcap/tidb/pkg/parser/format"
1414
"github.com/pingcap/tidb/pkg/parser/types"
1515
sqlite "github.com/rqlite/sql"
16-
sql_templates "github.com/sunary/sqlize/sql-templates"
16+
"github.com/sunary/sqlize/sqltemplates"
1717
)
1818

1919
const (
@@ -146,7 +146,7 @@ func (c Column) migrationUp(tbName, after string, ident int) []string {
146146
}
147147

148148
func (c Column) migrationCommentUp(tbName string) []string {
149-
if c.CurrentAttr.Comment == "" || sql.GetDialect() != sql_templates.PostgresDialect {
149+
if c.CurrentAttr.Comment == "" || sql.GetDialect() != sqltemplates.PostgresDialect {
150150
return nil
151151
}
152152

element/migration.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ import (
66
"strings"
77

88
"github.com/pingcap/tidb/pkg/parser/ast"
9-
sql_templates "github.com/sunary/sqlize/sql-templates"
9+
"github.com/sunary/sqlize/sqltemplates"
1010
"github.com/sunary/sqlize/utils"
1111
)
1212

1313
var (
14-
sql *sql_templates.Sql
14+
sql *sqltemplates.Sql
1515
ignoreFieldOrder bool
1616
)
1717

@@ -23,8 +23,8 @@ type Migration struct {
2323
}
2424

2525
// NewMigration ...
26-
func NewMigration(dialect sql_templates.SqlDialect, lowercase, ignoreOrder bool) Migration {
27-
sql = sql_templates.NewSql(dialect, lowercase)
26+
func NewMigration(dialect sqltemplates.SqlDialect, lowercase, ignoreOrder bool) Migration {
27+
sql = sqltemplates.NewSql(dialect, lowercase)
2828
ignoreFieldOrder = ignoreOrder
2929

3030
return Migration{

export/avro/builder.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ import (
99
"github.com/sunary/sqlize/element"
1010
)
1111

12-
// NewArvoSchema ...
13-
func NewArvoSchema(table element.Table) *RecordSchema {
12+
// NewAvroSchema ...
13+
func NewAvroSchema(table element.Table) *RecordSchema {
1414
fields := buildFieldsFromTable(table)
1515
record := newRecordSchema(table.Name, table.Name)
1616
record.Name = table.Name

options.go

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
package sqlize
22

3-
import (
4-
sql_templates "github.com/sunary/sqlize/sql-templates"
5-
)
3+
import "github.com/sunary/sqlize/sqltemplates"
64

75
type sqlizeOptions struct {
86
migrationFolder string
@@ -11,7 +9,7 @@ type sqlizeOptions struct {
119
migrationTable string
1210

1311
sqlTag string
14-
dialect sql_templates.SqlDialect
12+
dialect sqltemplates.SqlDialect
1513
lowercase bool
1614
pluralTableName bool
1715
generateComment bool
@@ -69,28 +67,28 @@ func WithSqlTag(sqlTag string) SqlizeOption {
6967
// WithMysql default
7068
func WithMysql() SqlizeOption {
7169
return newFuncSqlizeOption(func(o *sqlizeOptions) {
72-
o.dialect = sql_templates.MysqlDialect
70+
o.dialect = sqltemplates.MysqlDialect
7371
})
7472
}
7573

7674
// WithPostgresql ...
7775
func WithPostgresql() SqlizeOption {
7876
return newFuncSqlizeOption(func(o *sqlizeOptions) {
79-
o.dialect = sql_templates.PostgresDialect
77+
o.dialect = sqltemplates.PostgresDialect
8078
})
8179
}
8280

8381
// WithSqlserver ...
8482
func WithSqlserver() SqlizeOption {
8583
return newFuncSqlizeOption(func(o *sqlizeOptions) {
86-
o.dialect = sql_templates.SqlserverDialect
84+
o.dialect = sqltemplates.SqlserverDialect
8785
})
8886
}
8987

9088
// WithSqlite ...
9189
func WithSqlite() SqlizeOption {
9290
return newFuncSqlizeOption(func(o *sqlizeOptions) {
93-
o.dialect = sql_templates.SqliteDialect
91+
o.dialect = sqltemplates.SqliteDialect
9492
})
9593
}
9694

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package sql_builder
1+
package sqlbuilder
22

33
import (
44
"database/sql"
@@ -9,7 +9,7 @@ import (
99
"strings"
1010
"time"
1111

12-
sql_templates "github.com/sunary/sqlize/sql-templates"
12+
"github.com/sunary/sqlize/sqltemplates"
1313
"github.com/sunary/sqlize/utils"
1414
)
1515

@@ -78,9 +78,9 @@ var (
7878

7979
// SqlBuilder ...
8080
type SqlBuilder struct {
81-
sql *sql_templates.Sql
81+
sql *sqltemplates.Sql
8282
sqlTag string
83-
dialect sql_templates.SqlDialect
83+
dialect sqltemplates.SqlDialect
8484
generateComment bool
8585
pluralTableName bool
8686
tables map[string]string
@@ -89,7 +89,7 @@ type SqlBuilder struct {
8989
// NewSqlBuilder ...
9090
func NewSqlBuilder(opts ...SqlBuilderOption) *SqlBuilder {
9191
o := sqlBuilderOptions{
92-
dialect: sql_templates.MysqlDialect,
92+
dialect: sqltemplates.MysqlDialect,
9393
lowercase: false,
9494
pluralTableName: false,
9595
sqlTag: SqlTagDefault,
@@ -99,7 +99,7 @@ func NewSqlBuilder(opts ...SqlBuilderOption) *SqlBuilder {
9999
}
100100

101101
return &SqlBuilder{
102-
sql: sql_templates.NewSql(o.dialect, o.lowercase),
102+
sql: sqltemplates.NewSql(o.dialect, o.lowercase),
103103
dialect: o.dialect,
104104
sqlTag: o.sqlTag,
105105
pluralTableName: o.pluralTableName,
@@ -130,7 +130,7 @@ func (s SqlBuilder) AddTable(obj interface{}) string {
130130
comments := []string{}
131131
if s.generateComment {
132132
switch s.dialect {
133-
case sql_templates.PostgresDialect:
133+
case sqltemplates.PostgresDialect:
134134
comments = append(comments, fmt.Sprintf(s.sql.TableComment(), s.sql.EscapeSqlName(tableName), tableName))
135135

136136
default:
@@ -432,7 +432,7 @@ func (s SqlBuilder) parseStruct(tableName, prefix string, obj interface{}) ([]st
432432

433433
if at.Comment != "" {
434434
switch s.dialect {
435-
case sql_templates.PostgresDialect:
435+
case sqltemplates.PostgresDialect:
436436
comments = append(comments,
437437
fmt.Sprintf(s.sql.ColumnComment(), s.sql.EscapeSqlName(tableName), s.sql.EscapeSqlName(at.Name), at.Comment))
438438

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
package sql_builder
1+
package sqlbuilder
22

33
import (
4-
sql_templates "github.com/sunary/sqlize/sql-templates"
4+
"github.com/sunary/sqlize/sqltemplates"
55
)
66

77
type sqlBuilderOptions struct {
88
sqlTag string
9-
dialect sql_templates.SqlDialect
9+
dialect sqltemplates.SqlDialect
1010
lowercase bool
1111
generateComment bool
1212
pluralTableName bool
@@ -41,33 +41,33 @@ func WithSqlTag(sqlTag string) SqlBuilderOption {
4141
// WithMysql default
4242
func WithMysql() SqlBuilderOption {
4343
return newFuncSqlBuilderOption(func(o *sqlBuilderOptions) {
44-
o.dialect = sql_templates.MysqlDialect
44+
o.dialect = sqltemplates.MysqlDialect
4545
})
4646
}
4747

4848
// WithPostgresql ...
4949
func WithPostgresql() SqlBuilderOption {
5050
return newFuncSqlBuilderOption(func(o *sqlBuilderOptions) {
51-
o.dialect = sql_templates.PostgresDialect
51+
o.dialect = sqltemplates.PostgresDialect
5252
})
5353
}
5454

5555
// WithSqlserver ...
5656
func WithSqlserver() SqlBuilderOption {
5757
return newFuncSqlBuilderOption(func(o *sqlBuilderOptions) {
58-
o.dialect = sql_templates.SqlserverDialect
58+
o.dialect = sqltemplates.SqlserverDialect
5959
})
6060
}
6161

6262
// WithSqlite ...
6363
func WithSqlite() SqlBuilderOption {
6464
return newFuncSqlBuilderOption(func(o *sqlBuilderOptions) {
65-
o.dialect = sql_templates.SqliteDialect
65+
o.dialect = sqltemplates.SqliteDialect
6666
})
6767
}
6868

6969
// WithDialect ...
70-
func WithDialect(dialect sql_templates.SqlDialect) SqlBuilderOption {
70+
func WithDialect(dialect sqltemplates.SqlDialect) SqlBuilderOption {
7171
return newFuncSqlBuilderOption(func(o *sqlBuilderOptions) {
7272
o.dialect = dialect
7373
})

sqlize.go

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ import (
1010
"github.com/sunary/sqlize/element"
1111
"github.com/sunary/sqlize/export/avro"
1212
"github.com/sunary/sqlize/export/mermaidjs"
13-
sql_builder "github.com/sunary/sqlize/sql-builder"
14-
sql_parser "github.com/sunary/sqlize/sql-parser"
15-
sql_templates "github.com/sunary/sqlize/sql-templates"
13+
"github.com/sunary/sqlize/sqlbuilder"
14+
"github.com/sunary/sqlize/sqlparser"
15+
"github.com/sunary/sqlize/sqltemplates"
1616
"github.com/sunary/sqlize/utils"
1717
)
1818

@@ -27,11 +27,11 @@ type Sqlize struct {
2727
migrationUpSuffix string
2828
migrationDownSuffix string
2929
migrationTable string
30-
dialect sql_templates.SqlDialect
30+
dialect sqltemplates.SqlDialect
3131
lowercase bool
3232
pluralTableName bool
33-
sqlBuilder *sql_builder.SqlBuilder
34-
parser *sql_parser.Parser
33+
sqlBuilder *sqlbuilder.SqlBuilder
34+
parser *sqlparser.Parser
3535
}
3636

3737
// NewSqlize ...
@@ -42,9 +42,9 @@ func NewSqlize(opts ...SqlizeOption) *Sqlize {
4242
migrationDownSuffix: utils.DefaultMigrationDownSuffix,
4343
migrationTable: utils.DefaultMigrationTable,
4444

45-
dialect: sql_templates.MysqlDialect,
45+
dialect: sqltemplates.MysqlDialect,
4646
lowercase: false,
47-
sqlTag: sql_builder.SqlTagDefault,
47+
sqlTag: sqlbuilder.SqlTagDefault,
4848
pluralTableName: false,
4949
generateComment: false,
5050
ignoreFieldOrder: false,
@@ -53,21 +53,21 @@ func NewSqlize(opts ...SqlizeOption) *Sqlize {
5353
opts[i].apply(&o)
5454
}
5555

56-
opt := []sql_builder.SqlBuilderOption{sql_builder.WithSqlTag(o.sqlTag), sql_builder.WithDialect(o.dialect)}
56+
opt := []sqlbuilder.SqlBuilderOption{sqlbuilder.WithSqlTag(o.sqlTag), sqlbuilder.WithDialect(o.dialect)}
5757

5858
if o.lowercase {
59-
opt = append(opt, sql_builder.WithSqlLowercase())
59+
opt = append(opt, sqlbuilder.WithSqlLowercase())
6060
}
6161

6262
if o.generateComment {
63-
opt = append(opt, sql_builder.WithCommentGenerate())
63+
opt = append(opt, sqlbuilder.WithCommentGenerate())
6464
}
6565

6666
if o.pluralTableName {
67-
opt = append(opt, sql_builder.WithPluralTableName())
67+
opt = append(opt, sqlbuilder.WithPluralTableName())
6868
}
6969

70-
sb := sql_builder.NewSqlBuilder(opt...)
70+
sb := sqlbuilder.NewSqlBuilder(opt...)
7171

7272
return &Sqlize{
7373
migrationFolder: o.migrationFolder,
@@ -78,7 +78,7 @@ func NewSqlize(opts ...SqlizeOption) *Sqlize {
7878
lowercase: o.lowercase,
7979
pluralTableName: o.pluralTableName,
8080
sqlBuilder: sb,
81-
parser: sql_parser.NewParser(o.dialect, o.lowercase, o.ignoreFieldOrder),
81+
parser: sqlparser.NewParser(o.dialect, o.lowercase, o.ignoreFieldOrder),
8282
}
8383
}
8484

@@ -210,7 +210,7 @@ func (s Sqlize) WriteFilesWithVersion(name string, ver int64, dirty bool) error
210210
}
211211

212212
func (s Sqlize) migrationUpVersion(ver int64, dirty bool) string {
213-
tmp := sql_templates.NewSql(s.dialect, s.lowercase)
213+
tmp := sqltemplates.NewSql(s.dialect, s.lowercase)
214214
if ver == 0 {
215215
return fmt.Sprintf(tmp.CreateTableMigration(), s.migrationTable)
216216
}
@@ -219,7 +219,7 @@ func (s Sqlize) migrationUpVersion(ver int64, dirty bool) string {
219219
}
220220

221221
func (s Sqlize) migrationDownVersion(ver int64) string {
222-
tmp := sql_templates.NewSql(s.dialect, s.lowercase)
222+
tmp := sqltemplates.NewSql(s.dialect, s.lowercase)
223223
if ver == 0 {
224224
return fmt.Sprintf(tmp.DropTableMigration(), s.migrationTable)
225225
}
@@ -251,16 +251,16 @@ func (s Sqlize) MermaidJsLive(needTables ...string) string {
251251
return mm.Live()
252252
}
253253

254-
// ArvoSchema export arvo schema, support mysql only
255-
func (s Sqlize) ArvoSchema(needTables ...string) []string {
256-
if s.dialect != sql_templates.MysqlDialect {
254+
// AvroSchema export avro schema, support mysql only
255+
func (s Sqlize) AvroSchema(needTables ...string) []string {
256+
if s.dialect != sqltemplates.MysqlDialect {
257257
return nil
258258
}
259259

260260
tables := s.selectTable(needTables...)
261261
schemas := make([]string, 0, len(tables))
262262
for i := range tables {
263-
record := avro.NewArvoSchema(tables[i])
263+
record := avro.NewAvroSchema(tables[i])
264264
jsonData, _ := json.Marshal(record)
265265
schemas = append(schemas, string(jsonData))
266266
}

0 commit comments

Comments
 (0)