A-3130 Always define a primary key column for master Interactive Grids.
Reason
In a master-detail setup the detail region is filtered by the primary key of the row selected in the master Interactive Grid. If the master grid has no primary key column, there is no key to pass to the detail, so the master-detail link cannot work.
Mark the key column of the master grid as Primary Key (Column > Source > Primary Key) and point the detail's Master Column to it.
Example
Non-Compliant Example
page 10 (
// ...
region customers (
name: Customers
type: interactiveGrid
// ...
advanced {
htmlDomId: customers
}
column CUSTOMER_ID (
type: hidden
// ...
source {
databaseColumn: CUSTOMER_ID
dataType: number
// no primaryKey
}
)
)
region orders (
name: Orders
type: interactiveGrid
// ...
masterDetail {
masterRegion: @customers
}
)
) | Line | Column | Message |
|---|---|---|
| 3 | 12 |
Compliant Solution - ★★★★★
page 10 (
// ...
region customers (
name: Customers
type: interactiveGrid
// ...
advanced {
htmlDomId: customers
}
column CUSTOMER_ID (
type: hidden
// ...
source {
databaseColumn: CUSTOMER_ID
dataType: number
primaryKey: true
}
)
)
region orders (
name: Orders
type: interactiveGrid
// ...
masterDetail {
masterRegion: @customers
}
)
) Tests
Test SQL query
select distinct aa.workspace || '.' || aa.alias || '.' || m.page_id || '.' || coalesce(m.static_id, to_char(m.region_id)) as identifier,
'Interactive Grid ' || m.region_name || ' on page ' || m.page_id || ' of app ' || aa.alias || ' in ' || aa.workspace
|| ' is the master of a detail region but has no primary key column.' as message
from apex_application_page_regions m
join apex_application_page_regions d
on d.application_id = m.application_id
and d.master_region_id = m.region_id
join apex_applications aa
on aa.application_id = m.application_id
and aa.workspace = m.workspace
where aa.workspace in (#ApexWorkspaces#)
and m.source_type_code = 'NATIVE_IG'
and not exists (select 1
from apex_appl_page_ig_columns c
where c.application_id = m.application_id
and c.region_id = m.region_id
and c.is_primary_key = 'Yes')Test results
| Identifier | Message | Migration |
|---|---|---|
| WORKSPACE.CUSTOMERS.10.customers | Interactive Grid Customers on page 10 of app CUSTOMERS in WORKSPACE is the master of a detail region but has no primary key column. | - |
Parameters
Use parameters to customize the rule to your needs.
| Parameter | Description | Default Value |
|---|---|---|
| ApexWorkspaces | Comma-separated List of APEX workspaces owning APEX applications to check. | dblinter, dbl_gui |
References
- same as UC-3130