Skip to content

[Table] - Enforce Null and Empty fields #83

@clun

Description

@clun

When reading data from tables, for empty request column enforce null or empty

  • for collection
  • for set
  • for map
  • for udt
  • for any scalar
Object fallback = switch (type) {
                case LIST        -> new ArrayList<>();
                case SET         -> new LinkedHashSet<>();
                case MAP         -> new LinkedHashMap<>();
                case USERDEFINED -> buildNullUdt(entry.getValue().getDefinition());
                default -> null;
            };
            row.getColumnMap().put(columnName, fallback);

//....

    private Map<String, Object> buildNullUdt(TableUserDefinedTypeDefinition definition) {
        if (definition == null) return Collections.emptyMap();

        Map<String, Object> nullUdt = new HashMap<>();
        definition.getFields().keySet().forEach(field -> nullUdt.put(field, null));
        return nullUdt;
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions