* fix: make interpreter methods discoverable by runtime When generating an interface wrapper, lookup existing wrappers by method to get the one with the biggest set of methods implemented by interpreter. A string method is also added to wrappers, in order to provide a string representation of the interpreter value rather than the wrapper itself (at least for %s and %v verbs). This allows the runtime to pickup an interpreter method automatically even if the conversion to the interface is not specified in the script. As in Go spec, it is enough for the type to implement the required methods. A current limitation is that only single wrappers can be instantiated, not allowing to compose interfaces. This limitation can be removed when the Go reflect issue https://github.com/golang/go/issues/15924 is fixed. Fixes #435. * test: add a simpler test
83 lines
3.4 KiB
Go
83 lines
3.4 KiB
Go
// Code generated by 'goexports database/sql'. DO NOT EDIT.
|
|
|
|
// +build go1.14,!go1.15
|
|
|
|
package stdlib
|
|
|
|
import (
|
|
"database/sql"
|
|
"fmt"
|
|
"reflect"
|
|
)
|
|
|
|
func init() {
|
|
Symbols["database/sql"] = map[string]reflect.Value{
|
|
// function, constant and variable definitions
|
|
"Drivers": reflect.ValueOf(sql.Drivers),
|
|
"ErrConnDone": reflect.ValueOf(&sql.ErrConnDone).Elem(),
|
|
"ErrNoRows": reflect.ValueOf(&sql.ErrNoRows).Elem(),
|
|
"ErrTxDone": reflect.ValueOf(&sql.ErrTxDone).Elem(),
|
|
"LevelDefault": reflect.ValueOf(sql.LevelDefault),
|
|
"LevelLinearizable": reflect.ValueOf(sql.LevelLinearizable),
|
|
"LevelReadCommitted": reflect.ValueOf(sql.LevelReadCommitted),
|
|
"LevelReadUncommitted": reflect.ValueOf(sql.LevelReadUncommitted),
|
|
"LevelRepeatableRead": reflect.ValueOf(sql.LevelRepeatableRead),
|
|
"LevelSerializable": reflect.ValueOf(sql.LevelSerializable),
|
|
"LevelSnapshot": reflect.ValueOf(sql.LevelSnapshot),
|
|
"LevelWriteCommitted": reflect.ValueOf(sql.LevelWriteCommitted),
|
|
"Named": reflect.ValueOf(sql.Named),
|
|
"Open": reflect.ValueOf(sql.Open),
|
|
"OpenDB": reflect.ValueOf(sql.OpenDB),
|
|
"Register": reflect.ValueOf(sql.Register),
|
|
|
|
// type definitions
|
|
"ColumnType": reflect.ValueOf((*sql.ColumnType)(nil)),
|
|
"Conn": reflect.ValueOf((*sql.Conn)(nil)),
|
|
"DB": reflect.ValueOf((*sql.DB)(nil)),
|
|
"DBStats": reflect.ValueOf((*sql.DBStats)(nil)),
|
|
"IsolationLevel": reflect.ValueOf((*sql.IsolationLevel)(nil)),
|
|
"NamedArg": reflect.ValueOf((*sql.NamedArg)(nil)),
|
|
"NullBool": reflect.ValueOf((*sql.NullBool)(nil)),
|
|
"NullFloat64": reflect.ValueOf((*sql.NullFloat64)(nil)),
|
|
"NullInt32": reflect.ValueOf((*sql.NullInt32)(nil)),
|
|
"NullInt64": reflect.ValueOf((*sql.NullInt64)(nil)),
|
|
"NullString": reflect.ValueOf((*sql.NullString)(nil)),
|
|
"NullTime": reflect.ValueOf((*sql.NullTime)(nil)),
|
|
"Out": reflect.ValueOf((*sql.Out)(nil)),
|
|
"RawBytes": reflect.ValueOf((*sql.RawBytes)(nil)),
|
|
"Result": reflect.ValueOf((*sql.Result)(nil)),
|
|
"Row": reflect.ValueOf((*sql.Row)(nil)),
|
|
"Rows": reflect.ValueOf((*sql.Rows)(nil)),
|
|
"Scanner": reflect.ValueOf((*sql.Scanner)(nil)),
|
|
"Stmt": reflect.ValueOf((*sql.Stmt)(nil)),
|
|
"Tx": reflect.ValueOf((*sql.Tx)(nil)),
|
|
"TxOptions": reflect.ValueOf((*sql.TxOptions)(nil)),
|
|
|
|
// interface wrapper definitions
|
|
"_Result": reflect.ValueOf((*_database_sql_Result)(nil)),
|
|
"_Scanner": reflect.ValueOf((*_database_sql_Scanner)(nil)),
|
|
}
|
|
}
|
|
|
|
// _database_sql_Result is an interface wrapper for Result type
|
|
type _database_sql_Result struct {
|
|
Val interface{}
|
|
WLastInsertId func() (int64, error)
|
|
WRowsAffected func() (int64, error)
|
|
}
|
|
|
|
func (W _database_sql_Result) String() string { return fmt.Sprint(W.Val) }
|
|
|
|
func (W _database_sql_Result) LastInsertId() (int64, error) { return W.WLastInsertId() }
|
|
func (W _database_sql_Result) RowsAffected() (int64, error) { return W.WRowsAffected() }
|
|
|
|
// _database_sql_Scanner is an interface wrapper for Scanner type
|
|
type _database_sql_Scanner struct {
|
|
Val interface{}
|
|
WScan func(src interface{}) error
|
|
}
|
|
|
|
func (W _database_sql_Scanner) String() string { return fmt.Sprint(W.Val) }
|
|
|
|
func (W _database_sql_Scanner) Scan(src interface{}) error { return W.WScan(src) }
|