alfateam / orange-orm

The ultimate ORM for Node and Typescript
https://orange-orm.io
ISC License
694 stars 20 forks source link

Composite key on hasMany relation gives error #106

Closed lroal closed 5 months ago

lroal commented 5 months ago

orange Version

4.1.1

Database

None

Database Version

No response

Operating System

No response

Description

TypeError: Cannot read properties of undefined (reading '_primaryColumns') ❯ primaryKeyFilter ../src/table/newPrimaryKeyFilter.js:2:29 ❯ createCompositeFilter ../src/getManyDto.js:220:36 ❯ createOneFilter ../src/getManyDto.js:217:10

 const map = orange.map(x => ({
    compositeOrder: x.table('compositeOrder').map(({ column }) => ({
        companyId: column('companyId').string().primary().notNullExceptInsert(),
        orderNo: column('orderNo').numeric().primary().notNullExceptInsert(),
    })),

    compositeOrderLine: x.table('compositeOrderLine').map(({ column }) => ({
        companyId: column('companyId').string().primary().notNullExceptInsert(),
        orderNo: column('orderNo').numeric().primary().notNullExceptInsert(),
        lineNo: column('lineNo').numeric().primary().notNullExceptInsert(),
        product: column('product').string(),
    }))
})).map(x => ({ 
    compositeOrder: x.compositeOrder.map(({ hasMany }) => ({
        lines: hasMany(x.compositeOrderLine).by('companyId', 'orderNo')
    }))

}));

export default map;

Expected Behavior

No response