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) {
64
64
65
65
if ( ! joinedTables . some ( t => t === relationPath . join ( '.' ) ) ) {
66
66
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 } `
69
70
70
- let relationTable = getTable ( relationResourceConfig )
71
- let foreignId = `${ relationTable } .${ relationResourceConfig . idAttribute } `
71
+ let relationTable = getTable ( relationResourceConfig )
72
+ let foreignId = `${ relationTable } .${ relationResourceConfig . idAttribute } `
72
73
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
+ }
75
79
}
76
80
localResourceConfig = relationResourceConfig
77
81
}
Original file line number Diff line number Diff line change @@ -182,4 +182,14 @@ describe('DSSqlAdapter#findAll', function () {
182
182
assert . isUndefined ( users [ 0 ] . email ) ;
183
183
} ) ;
184
184
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
+
185
195
} ) ;
You can’t perform that action at this time.
0 commit comments