hansva opened a new issue, #9288:
URL: https://github.com/apache/hop/issues/9288
### What needs to happen?
About 30 places in Hop parse text into a typed field: input transforms,
constants and default values, the Data Grid, the table and edit-rows dialogs,
and lazy storage metadata. Most build the String metadata they parse with in
one of two ways:
IRowMeta convertMeta = outputRowMeta.cloneToType(IValueMeta.TYPE_STRING);
IValueMeta stringMeta = ValueMetaFactory.cloneValueMeta(valueMeta,
IValueMeta.TYPE_STRING);
Both copy the field through `ValueMetaFactory.cloneInfo()`, which has two
gaps:
1. **The currency symbol is dropped.** If a field has a Currency and a mask
with `¤`, Hop cannot read back the text it writes. For example, with Currency
`€` and mask `¤#,##0.00`, the field writes `€1,234.50`. On an en_US machine,
parsing that same text fails, because the parse metadata falls back to the
machine's `$`.
2. **The storage type is kept.** For a lazy (binary string) field, the parse
metadata also gets binary string storage, so parsing a plain `String` with it
fails with a `ClassCastException`. Some callers work around this by resetting
the storage and length themselves, each in its own way.
**Proposed change**
Add one helper to core that builds the parse metadata the same way
everywhere:
- `ValueMetaFactory.createParseMeta(IValueMeta target)` returns a String
value meta that keeps everything that decides how text is parsed: the mask, the
decimal, grouping and currency symbols, trim type, encoding, date locale, time
zone and leniency. It always has normal storage, no storage metadata and no
length.
- `ValueMetaFactory.createParseRowMeta(IRowMeta target)` does the same for
every field in a row.
Use the helpers in every place that parses text into a field:
- Core: lazy storage metadata in `ValueMetaBase` and
`StandardJdbcTypeMapper`.
- Engine: debug session imports.
- Transforms: the base file input and Text file input, CSV input, JSON
input, JSON normalize, LDAP input, Property input, Get data from XML,
Salesforce input, Tika, Load file content, Data Grid, Split fields, Get
variables, If null, Regex evaluation, Generate rows, Add constants, Switch case
and Validator.
- GUI: `TableView`, the edit-rows dialog and the CSV import dialog.
Deprecate `IRowMeta.cloneToType(int)`. The Javadoc points to
`createParseRowMeta` for parsing.
**Behaviour change**
Fields with a Currency and a `¤` mask now parse the text they write. Fields
without a Currency, or whose mask has no `¤`, parse exactly as before. Lazy
fields now get normal-storage parse metadata in every place, instead of only
where the caller reset it by hand.
### Issue Priority
Priority: 2
### Issue Component
Component: API
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]