rules repository

A-3100 Avoid LOV items on single-column Interactive Grid primary keys.

Severity Warning SQL-based Test Free New

Reason

A primary key column identifies the row for updates and deletes. Showing it as a LOV item (Popup LOV, Select List, Radio Group, Combobox) lets users pick a different key for an existing row, which turns an update into a change of identity, and mixes a technical identifier with what users should see.

Make the key column Hidden (or Display Only) and add a separate column for the human-readable value. If the key is a natural key that users really choose from a list, keep the LOV but make sure updates of existing rows cannot change it, for example with a Read Only condition for existing rows (such a column is not reported). Grids with a composite primary key are not checked.

Example

Non-Compliant Example

page 10 (
    // ...
    region order-lines (
        name: Order lines
        // ...
        advanced {
            htmlDomId: order-lines
        }

        column PRODUCT_CODE (
            type: popupLov
            // ...
            source {
                databaseColumn: PRODUCT_CODE
                dataType: varchar2
                primaryKey: true
            }
        )
    )
)
Issues
LineColumnMessage
1119Primary key column is displayed as a Popup LOV.

Compliant Solution - ★★★★★

page 10 (
    // ...
    region order-lines (
        name: Order lines
        // ...
        advanced {
            htmlDomId: order-lines
        }

        column ORDER_LINE_ID (
            type: hidden
            // ...
            source {
                databaseColumn: ORDER_LINE_ID
                dataType: number
                primaryKey: true
            }
        )

        column PRODUCT_CODE (
            type: popupLov
            // ...
            source {
                databaseColumn: PRODUCT_CODE
                dataType: varchar2
            }
        )
    )
)

Tests

Test SQL query

select aa.workspace || '.' || aa.alias || '.' || c.page_id || '.' || coalesce(r.static_id, to_char(r.region_id)) || '.' || c.name as identifier,
       'Column ' || c.name || ' of Interactive Grid ' || c.region_name || ' on page ' || c.page_id || ' of app ' || aa.alias
         || ' in ' || aa.workspace || ' is the primary key of the grid and displayed as a LOV item that users can change.' as message
  from apex_appl_page_ig_columns c
  join apex_application_page_regions r
    on r.application_id = c.application_id
       and r.region_id = c.region_id
  join apex_applications aa
    on aa.application_id = c.application_id
       and aa.workspace = c.workspace
 where aa.workspace in (#ApexWorkspaces#)
   and c.is_primary_key = 'Yes'
   and c.item_type in ('NATIVE_POPUP_LOV', 'NATIVE_SELECT_LIST', 'NATIVE_RADIOGROUP', 'NATIVE_COMBOBOX')
   and c.is_query_only = 'No'
   and c.read_only_condition_type_code is null
   and (select count(*)
          from apex_appl_page_ig_columns k
         where k.application_id = c.application_id
           and k.region_id = c.region_id
           and k.is_primary_key = 'Yes') = 1
   and exists (select 1
                 from apex_appl_page_igs ig
                where ig.application_id = c.application_id
                  and ig.region_id = c.region_id
                  and ig.is_editable = 'Yes')

Test results

IdentifierMessageMigration
WORKSPACE.CUSTOMERS.10.order-lines.PRODUCT_CODEColumn PRODUCT_CODE of Interactive Grid Order lines on page 10 of app CUSTOMERS in WORKSPACE is the primary key of the grid and displayed as a LOV item that users can change.-

Parameters

Use parameters to customize the rule to your needs.

ParameterDescriptionDefault Value
ApexWorkspacesComma-separated List of APEX workspaces owning APEX applications to check.dblinter, dbl_gui

References