Skip to content

[Bug]: DynamicTable.addRow helper assumes id column is always present if table has columns #813

@ehennestad

Description

@ehennestad

What happened?

if ~isempty(DynamicTable.colnames)
tableHeight = types.util.dynamictable.getColumnHeight(DynamicTable.id);
end

This computes tableHeight from DynamicTable.id whenever colnames is non-empty. If a table has existing columns but no id (which is possible), tableHeight becomes 0 and new columns will incorrectly fail height validation. Consider inferring height via types.util.dynamictable.internal.getTableHeight(DynamicTable) (and/or initializing id when missing) rather than assuming id is present.

Steps to Reproduce

dynamicTable = types.core.TimeIntervals();
dynamicTable.start_time = types.hdmf_common.VectorData('data', 1:10);
dynamicTable.colnames = {'start_time'};
dynamicTable.addColumn('trial_outcome', types.hdmf_common.VectorData('data', randi(4,[1,10])))

Error Message

Error using types.util.dynamictable.addVarargColumn>validateColumnHeight (line 87)
Column `trial_outcome` has detected height 10, but the table height is 0.

Error in types.util.dynamictable.addVarargColumn (line 58)
        validateColumnHeight(new_cn, currentColumnHeight, tableHeight)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error in types.util.dynamictable.addColumn (line 37)
    types.util.dynamictable.addVarargColumn(DynamicTable, varargin{:});
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error in types.hdmf_common.DynamicTable/addColumn (line 119)
        types.util.dynamictable.addColumn(obj, varargin{:});
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Operating System

macOS

Matlab Version

R2024b

Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions