Deprecate QueryM2MWithCtx and QueryTableWithCtx

- Add methods with `WithCtx` suffix and remove ctx fileld from QueryStter
and QueryM2M.
- Deprecate QueryTableWithCtx and QueryM2MWithCtx.

Signed-off-by: Penghui Liao <liaoishere@gmail.com>
This commit is contained in:
Penghui Liao
2021-01-10 13:59:01 +08:00
parent 21777d3143
commit ef227bf467
13 changed files with 130 additions and 68 deletions

View File

@@ -77,7 +77,6 @@ func RunCommand() {
// sync database struct command interface.
type commandSyncDb struct {
ctx context.Context
al *alias
force bool
verbose bool
@@ -143,6 +142,7 @@ func (d *commandSyncDb) Run() error {
fmt.Printf(" %s\n", err.Error())
}
ctx := context.Background()
for i, mi := range modelCache.allOrdered() {
if !isApplicableTableForDB(mi.addrField, d.al.Name) {
@@ -156,7 +156,7 @@ func (d *commandSyncDb) Run() error {
}
var fields []*fieldInfo
columns, err := d.al.DbBaser.GetColumns(d.ctx, db, mi.table)
columns, err := d.al.DbBaser.GetColumns(ctx, db, mi.table)
if err != nil {
if d.rtOnError {
return err
@@ -190,7 +190,7 @@ func (d *commandSyncDb) Run() error {
}
for _, idx := range indexes[mi.table] {
if !d.al.DbBaser.IndexExists(d.ctx, db, idx.Table, idx.Name) {
if !d.al.DbBaser.IndexExists(ctx, db, idx.Table, idx.Name) {
if !d.noInfo {
fmt.Printf("create index `%s` for table `%s`\n", idx.Name, idx.Table)
}
@@ -292,7 +292,6 @@ func RunSyncdb(name string, force bool, verbose bool) error {
al := getDbAlias(name)
cmd := new(commandSyncDb)
cmd.ctx = context.TODO()
cmd.al = al
cmd.force = force
cmd.noInfo = !verbose