File tree Expand file tree Collapse file tree 2 files changed +20
-6
lines changed Expand file tree Collapse file tree 2 files changed +20
-6
lines changed Original file line number Diff line number Diff line change @@ -64,14 +64,18 @@ function filterQuery (resourceConfig, params) {
6464
6565 if ( ! joinedTables . some ( t => t === relationPath . join ( '.' ) ) ) {
6666 let [ relation ] = localResourceConfig . relationList . filter ( r => r . relation === relationName )
67- let table = getTable ( localResourceConfig )
68- let localId = `${ table } .${ relation . localKey } `
67+ if ( relation ) {
68+ let table = getTable ( localResourceConfig )
69+ let localId = `${ table } .${ relation . localKey } `
6970
70- let relationTable = getTable ( relationResourceConfig )
71- let foreignId = `${ relationTable } .${ relationResourceConfig . idAttribute } `
71+ let relationTable = getTable ( relationResourceConfig )
72+ let foreignId = `${ relationTable } .${ relationResourceConfig . idAttribute } `
7273
73- query = query . join ( relationTable , localId , foreignId )
74- joinedTables . push ( relationPath . join ( '.' ) )
74+ query = query . join ( relationTable , localId , foreignId )
75+ joinedTables . push ( relationPath . join ( '.' ) )
76+ } else {
77+ // local column
78+ }
7579 }
7680 localResourceConfig = relationResourceConfig
7781 }
Original file line number Diff line number Diff line change @@ -182,4 +182,14 @@ describe('DSSqlAdapter#findAll', function () {
182182 assert . isUndefined ( users [ 0 ] . email ) ;
183183 } ) ;
184184
185+ it ( 'should filter when relations have same column if column is qualified' , function * ( ) {
186+ var profile1 = yield adapter . create ( Profile , { email : 'foo@test.com' } ) ;
187+ var user1 = yield adapter . create ( User , { name : 'John' , profileId : profile1 . id } ) ;
188+
189+ // `id` column must be qualified with `user.`
190+ var users = yield adapter . findAll ( User , { 'user.id' : user1 . id , 'profile.email' : 'foo@test.com' } ) ;
191+ assert . equal ( users . length , 1 ) ;
192+ assert . equal ( users [ 0 ] . profileId , profile1 . id ) ;
193+ } ) ;
194+
185195} ) ;
You can’t perform that action at this time.
0 commit comments