-
Notifications
You must be signed in to change notification settings - Fork 714
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Contact Details
No response
What happened?
On a project I'm working on, I have 3 tables:
Account, Metrics, and AccountMetrics
In a resource, I have the ManyToMany relation, which automatically fetches in Account, all the Metrics for that account, through AccountMetrics
I found a bug with this pattern:
- for an account with e.g
account_id = 1
, it also finds metrics foraccount_id = 10
,100
- also, for
account_id = 10
, it finds metrics foraccount_id = 100
- also, for
- similar for
account_id
2
/20
/200
etc
While the bug appears in the ManyToMany relation, it also reproduces in the find
method from adminJs.
Expected result:
When finding metrics for account_id = 1
, it shouldn't also return metrics for account_id = 10
, or account_id = 100
Bug prevalence
Everytime I load a page for this case.
AdminJS dependencies version
"@adminjs/express": "^6.1.1",
"@adminjs/nestjs": "^6.1.0",
"@adminjs/relations": "^1.1.2",
"@adminjs/themes": "^1.0.1",
"@adminjs/typeorm": "^5.0.1",
"adminjs": "^7.8.16",
What browsers do you see the problem on?
Firefox
Relevant log output
records: [
{
params: [Object],
populated: {},
baseError: null,
errors: {},
id: '4397595e-bbb6-3928-88e2-c17632f23200',
title: 'Net Profit',
recordActions: [Array],
bulkActions: []
},
{
params: [Object],
populated: {},
baseError: null,
errors: {},
id: '3fec6582-305b-429d-b47b-2d0352asf9edb',
title: 'adfasdf',
recordActions: [Array],
bulkActions: []
}
],
record: {
params: {
id: '1',
name: 'Demo',
is_active: 1,
created: 2021-04-27T16:02:42.217Z,
modified: 2025-05-07T05:03:12.081Z,
slug: 'demo',
preset_team_id: '',
preset_workspace_id: '',
account_type: 'LMD'
},
populated: {},
baseError: null,
errors: {},
id: '1',
title: 'Demo',
recordActions: [ [Object] ],
bulkActions: []
}
the 'Net Profit' metric is from account_id 100
the 'adfasdf' metric is from account_id 10
In the database there's no metric for account_id 1
Relevant code that's giving you issues
features: [
owningRelationSettings({
componentLoader,
licenseKey: process.env.ADMINJS_RELATIONS_LICENSE_KEY!,
relations: {
account_metrics: {
type: AdminJSRelationType.ManyToMany,
target: {
resourceId: 'Metric',
},
junction: {
joinKey: 'account_id',
inverseJoinKey: 'metric_id',
throughResourceId: 'AccountMetric',
},
},
},
}),
],
matei-pruteanu-vitamin and onisimromanVSmatei-pruteanu-vitamin, onisimromanVS and gilangmlr
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working