diff --git a/integrations/session_find_test.go b/integrations/session_find_test.go index cc6633c..a0e6c2e 100644 --- a/integrations/session_find_test.go +++ b/integrations/session_find_test.go @@ -708,6 +708,13 @@ func TestFindExtends(t *testing.T) { err = testEngine.Find(&results) assert.NoError(t, err) assert.EqualValues(t, 2, len(results)) + + results = make([]FindExtendsA, 0, 2) + err = testEngine.Find(&results, &FindExtendsB{ + ID: 1, + }) + assert.NoError(t, err) + assert.EqualValues(t, 1, len(results)) } func TestFindExtends3(t *testing.T) { diff --git a/internal/statements/pk.go b/internal/statements/pk.go index 7004597..f4474a4 100644 --- a/internal/statements/pk.go +++ b/internal/statements/pk.go @@ -64,7 +64,6 @@ func (statement *Statement) ProcessIDParam() error { } if len(statement.RefTable.PrimaryKeys) != len(statement.idParam) { - fmt.Println("=====", statement.RefTable.PrimaryKeys, statement.idParam) return fmt.Errorf("ID condition is error, expect %d primarykeys, there are %d", len(statement.RefTable.PrimaryKeys), len(statement.idParam), diff --git a/session_find.go b/session_find.go index 9426d90..471bf59 100644 --- a/session_find.go +++ b/session_find.go @@ -129,8 +129,11 @@ func (session *Session) find(rowsSlicePtr interface{}, condiBean ...interface{}) ) if tp == tpStruct { if !session.statement.NoAutoCondition && len(condiBean) > 0 { - var err error - autoCond, err = session.statement.BuildConds(table, condiBean[0], true, true, false, true, addedTableName) + condTable, err := session.engine.tagParser.Parse(reflect.ValueOf(condiBean[0])) + if err != nil { + return err + } + autoCond, err = session.statement.BuildConds(condTable, condiBean[0], true, true, false, true, addedTableName) if err != nil { return err } diff --git a/tags/parser.go b/tags/parser.go index eadedb8..c2df3a7 100644 --- a/tags/parser.go +++ b/tags/parser.go @@ -115,6 +115,7 @@ func (parser *Parser) Parse(v reflect.Value) (*schemas.Table, error) { t := v.Type() if t.Kind() == reflect.Ptr { t = t.Elem() + v = v.Elem() } if t.Kind() != reflect.Struct { return nil, ErrUnsupportedType diff --git a/xorm.go b/xorm.go index 169bbd5..9f77ff1 100644 --- a/xorm.go +++ b/xorm.go @@ -23,7 +23,7 @@ import ( const ( // Version show the xorm's version - Version string = "0.8.0.0330" + Version string = "1.0.1.0430" ) func close(engine *Engine) {