IMPORT of a file with no rows keeps the data of the previous import: FIELDS ... DO repeats the old rows and ELSE is skipped
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 68/100
Research direction
Start with the IMPORT entry point and run the supplied two-file lsf reproducer, then compare the empty-file cases for flat, JSON/XML, and form imports. Done means a later empty import clears all writable imported properties and row or object marks, skips FIELDS ... DO, and executes ELSE.
Written by the indexing model from the issue text.
Description
Description
Before it writes the new data, IMPORT is documented to cancel the changes that the imported properties already have in the current session. In fact it does so only for the properties that received at least one value from the file. When the file — or one object group of it — contains no rows, some or all of what the previous IMPORT wrote in the same session stays in place, and the code that follows the import processes the rows of the previous file once more.
Minimal reproducer — one action that imports two files one after another in one session:
log = DATA LOCAL TEXT ();
importNames (CSVFILE f) {
IMPORT CSV HEADER FROM f FIELDS STRING name DO
log() <- CONCAT ' ', log(), name;
ELSE
log() <- CONCAT ' ', log(), 'EMPTY';
}
run () {
importNames(CSVFILE(r'name
A
B'));
importNames(CSVFILE(r'name
')); // a header and no rows
MESSAGE log(); // expected: A B EMPTY actual: A B A B
}
What survives depends on the format:
| Imported file | What stays from the previous import |
|---|---|
flat format (CSV, XLS, DBF) with no rows — imported with TO, with FIELDS or into a form |
everything: the imported values and the marks of the imported rows (imported[INTEGER], the WHERE property, the internal mark of FIELDS). FIELDS ... DO runs again for every row of the previous file with its old values, ELSE does not run |
JSON / XML with an empty array or without the expected key — imported with TO or FIELDS |
the marks of the imported rows; the values are reset. FOR imported(INTEGER i) and FIELDS ... DO go over the row numbers of the previous file with NULL values, ELSE does not run |
JSON / XML imported into a form, when one of its object groups gets no objects (empty array, no such key) |
the properties written through the FILTERS of that object group; the properties of the form are reset |
The last case covers the mark of the read objects (FILTERS imported(o)) and, which is worse, the link to the upper object:
rName = DATA LOCAL STRING (INTEGER);
lReceipt = DATA LOCAL INTEGER (INTEGER);
lName = DATA LOCAL STRING (INTEGER);
FORM receipts
OBJECTS receipts = INTEGER
PROPERTIES(receipts) rName EXTID 'name'
OBJECTS lines = INTEGER
PROPERTIES(lines) lName EXTID 'item'
FILTERS lReceipt(lines) = receipts
;
// 1st file: {"receipts":[{"name":"A","lines":[{"item":"a1"},{"item":"a2"}]}]}
// 2nd file: {"receipts":[{"name":"B","lines":[]}]}
// after the 2nd import lReceipt(0) and lReceipt(1) still point to receipt 0,
// so receipt B gets the two lines of receipt A, with NULL items
Verified on 7.0-SNAPSHOT; this is not a regression — 5.x and 6.x behave the same way.
Workaround until it is fixed: run every import in a session of its own (NEWSESSION), or, for TO, reset the mark and the imported properties before the import (imported(INTEGER i) <- NULL;).
Reason
Importing several files in one session is the ordinary shape of an integration: a loop over a directory or a mailbox, a polling action, an upload of several files. An empty file is an ordinary event there, and every time it happens the rows of the previous file are processed a second time — objects are created twice, a document without lines receives the lines of the previous one, and the ELSE branch that should report "nothing to import" never runs. Nothing signals it, and the outcome depends on what was imported earlier in the same session, so the cause is very hard to find. It also contradicts the documented behaviour ("before importing, any existing changes to the imported properties in the current session are canceled").
Fix
Every IMPORT cancels the previous session changes of all the properties it can write to — the imported properties, the property that marks the imported rows (imported[INTEGER], the WHERE property, the internal one of FIELDS) and the properties in the filters of the imported form — no matter how many rows or objects the file yields. After a file with no rows these properties are empty, FIELDS ... DO is not executed and ELSE is.
- Dominant language
- Java
- Stars
- 214
- Forks
- 46
- PR merge metrics
- No merged PRs in 30d
Getting set up
- Ships a Dockerfile or Docker Compose file
- No pull request template
- No contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from lsfusion/platform
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
-
bug
Difficulty 3/5 1-2 days Newbie friendliness 45/100
-
bug
Difficulty 4/5 3-5 days Newbie friendliness 30/100
-
Difficulty 3/5 1-2 days Newbie friendliness 62/100
All issues in lsfusion/platform
Similar issues
-
account assessment course feature lecture
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
Maintainers usually reply within 1 day
-
app:learninggoalhub enhancement good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
Maintainers usually reply within 1 day
-
Difficulty 1/5 1-3 hours Newbie friendliness 86/100
Maintainers usually reply within 1 day
-
PropertyResolver fails on JDK classes with a non-public field named like the propertyPossibly taken @vaibhavgupta443 claimed this today. Opengood first issue
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
apache/wicket#1991 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100