fix args length error.

This commit is contained in:
kvii2202 2022-03-16 20:44:43 +08:00
parent 825bbf35ec
commit c2d084a788

View File

@ -124,6 +124,12 @@ func (db *DB) with(name string, recursive bool, args ...interface{}) (tx *DB) {
} }
} }
case []string: case []string:
switch len(args) {
case 1:
tx.AddError(fmt.Errorf("unsupported with subquery type %T", arg))
return
case 2:
// arg[0] is columns ans arg[1] is subquery
for _, col := range arg { for _, col := range arg {
if strings.Contains(col, ",") { if strings.Contains(col, ",") {
tx.AddError(fmt.Errorf("unsupported mixed string type")) tx.AddError(fmt.Errorf("unsupported mixed string type"))
@ -131,6 +137,10 @@ func (db *DB) with(name string, recursive bool, args ...interface{}) (tx *DB) {
} }
} }
columns = arg columns = arg
default:
tx.AddError(fmt.Errorf("unsupported multiple columns %v", args[1:len(args)-1]))
return
}
default: default:
// specify optional columns field with a wrong type // specify optional columns field with a wrong type
if len(args) > 1 { if len(args) > 1 {