dresende / node-orm2

Object Relational Mapping
http://github.com/dresende/node-orm2
MIT License
3.07k stars 379 forks source link

findByAssociation has problems with auto generated coloumn by `.hasOne` method with `mapsTo` option. #817

Open reumia opened 6 years ago

reumia commented 6 years ago
// Defining Model
LikesCut.hasOne('target', Cuts, {reverse: 'likes', field: 'targetId', mapsTo: 'target_id', required: true})

// CASE 1 : ER_BAD_FIELD_ERROR: Unknown column 't1.targetId' in 'on clause'
LikesCut.findByTarget({}).runAsync()
// CASE 2 : ER_BAD_FIELD_ERROR: Unknown column 't2.targetId' in 'on clause'
Cuts.findByLikes({}).runAsync()

it seems to tying join with wrong column name. is there something wrong in my codes or isn't it prepared yet?