Skip to content

Conversation

@labkey-matthewb
Copy link
Contributor

Rationale

For Array type required does not mean "IS NOT NULL" it means "cardinality() > 0".
Also for Multiple-choice text we prefer that null/"" converts to [] not to null.

To help implement this we consolidate column conversion into ColumnInfo.convert() and required/non-empty checking into JdbcType.isEmpty().

Related Pull Requests

Changes

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request consolidates column value conversion and required/non-empty validation logic across the codebase. The primary goals are to handle Array type validation correctly (where required means "cardinality() > 0" rather than "IS NOT NULL") and to ensure consistent conversion behavior for Multiple-choice text fields (converting null/"" to [] rather than null).

Changes:

  • Introduces the SimpleConvert interface to unify conversion logic across JdbcType, PropertyType, Unit, and ColumnInfo
  • Consolidates conversion logic into ColumnInfo.convert() instead of scattered ConvertUtils.convert() calls
  • Adds JdbcType.isEmpty() method to properly validate required fields based on type-specific semantics
  • Adds array_is_empty() SQL function for PostgreSQL to check array emptiness using cardinality

Reviewed changes

Copilot reviewed 43 out of 43 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
api/src/org/labkey/api/data/SimpleConvert.java New interface defining conversion contract with optional performance optimization method
api/src/org/labkey/api/data/JdbcType.java Implements SimpleConvert, adds isEmpty() method with Array-specific logic, refactors convert() methods
api/src/org/labkey/api/exp/PropertyType.java Implements SimpleConvert, updates STRING/MULTI_LINE/XML_TEXT to convert empty strings to null
api/src/org/labkey/api/ontology/Unit.java Implements SimpleConvert for Quantity conversion
api/src/org/labkey/api/data/ColumnRenderProperties.java Adds SimpleConvert interface, refactors getConvertFn() to use new pattern
api/src/org/labkey/api/data/BaseColumnInfo.java Implements getConvertFn() using ColumnRenderProperties.getDefaultConvertFn()
api/src/org/labkey/api/data/AbstractWrappedColumnInfo.java Implements getConvertFn() delegation
api/src/org/labkey/api/exp/PropertyDescriptor.java Implements getConvertFn() delegation
api/src/org/labkey/api/data/validator/RequiredValidator.java Updated to use JdbcType parameter and isEmpty() method for validation
api/src/org/labkey/api/data/validator/ColumnValidators.java Updated createRequiredValidator to pass JdbcType to RequiredValidator
api/src/org/labkey/api/dataiterator/SimpleTranslator.java Refactored conversion columns to use ColumnInfo.convert(), removed PropertyConvertColumn classes
api/src/org/labkey/api/dataiterator/StandardDataIteratorBuilder.java Updated to use simplified addConvertColumn signature
api/src/org/labkey/api/data/ConvertHelper.java Added getSimpleConvert() factory method, updated DateFriendlyStringConverter to handle empty strings
api/src/org/labkey/api/data/TableViewForm.java Refactored to use col.convert() instead of ConvertUtils.convert()
api/src/org/labkey/api/data/MultiChoice.java Updated DisplayColumn to implement IMultiValuedDisplayColumn, improved rendering
api/src/org/labkey/api/query/*.java Multiple query service classes updated to use col.convert()
experiment/src/org/labkey/experiment/api/*.java Multiple experiment classes updated to use col.convert() or type.convert()
query/src/org/labkey/query/sql/Method.java Added ArrayIsEmptyMethod for array_is_empty SQL function
api/src/org/labkey/api/webdav/WebdavResource.java Added getSpringResource() helper method
api/webapp/WEB-INF/web.xml Updated to Servlet 3.0 spec, added async-supported to filters
api/src/org/labkey/api/data/ColumnInfoTests.jsp New test file for ColumnInfo.convert() integration testing
api/src/messages/Validation.properties Fixed typo: "tyepMismatch" -> "typeMismatch"
core/src/org/labkey/core/CoreModule.java Added ColumnInfoTests.jsp as integration test

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Override
public URI getURI() throws IOException
{
// Nnot sure why getExceuteHref() takes a view context. We ay not need for the moment.
Copy link

Copilot AI Jan 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are spelling errors in the comment. "Nnot" should be "Not", "getExceuteHref" should be "getExecuteHref", and "We ay" should be "We may".

Copilot uses AI. Check for mistakes.
@Override
public InputStream getInputStream() throws IOException
{
// FileSTream.openInputStream() enforces one stream per instance, so don't use 'fs'
Copy link

Copilot AI Jan 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a typo in the comment. "FileSTream" should be "FileStream".

Copilot uses AI. Check for mistakes.
Comment on lines +112 to +117
* A lot of this testing is redunant with lower-level unit testing,
* however, his till servers as a basic conversion smoke test.
* <p></p>
* In particualr, the PropertyType conversions are pretty
* redundant with ConvertHelper.convert() and JdbcType.convert()
* (PropertyType predates JdbcType), but there are some differenes
Copy link

Copilot AI Jan 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are multiple spelling errors in the comment: "redunant" should be "redundant", "his till servers" should be "this still serves", "particualr" should be "particular", and "differenes" should be "differences".

Suggested change
* A lot of this testing is redunant with lower-level unit testing,
* however, his till servers as a basic conversion smoke test.
* <p></p>
* In particualr, the PropertyType conversions are pretty
* redundant with ConvertHelper.convert() and JdbcType.convert()
* (PropertyType predates JdbcType), but there are some differenes
* A lot of this testing is redundant with lower-level unit testing,
* however, this still serves as a basic conversion smoke test.
* <p></p>
* In particular, the PropertyType conversions are pretty
* redundant with ConvertHelper.convert() and JdbcType.convert()
* (PropertyType predates JdbcType), but there are some differences

Copilot uses AI. Check for mistakes.
Comment on lines +1347 to 1350
} final String name = col.getName();



Copy link

Copilot AI Jan 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There appears to be orphaned code on line 1347. The variable declaration final String name = col.getName(); is defined but never used in this scope, and appears to be a remnant from refactoring. This dead code should be removed.

Suggested change
} final String name = col.getName();
}

Copilot uses AI. Check for mistakes.
* use getConvertFn() e.g.
* var fn = col.getConvertFn();
* while (...)
* var converted = fb.convert(val);
Copy link

Copilot AI Jan 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a typo in the example code comment. Line 16 shows fb.convert(val) but should be fn.convert(val) to match the variable name defined on line 14.

Suggested change
* var converted = fb.convert(val);
* var converted = fn.convert(val);

Copilot uses AI. Check for mistakes.
@Override
public URL getURL() throws IOException
{
// Nnot sure why getExceuteHref() takes a view context. We ay not need for the moment.
Copy link

Copilot AI Jan 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are spelling errors in the comment. "Nnot" should be "Not", "getExceuteHref" should be "getExecuteHref", and "We ay" should be "We may".

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants