(core) Fix imports into reference columns, and support two ways to import Numeric as a reference.

Summary:
- When importing into a Ref column, use lookupOne() formula for correct previews.
- When selecting columns to import into a Ref column, now a Numeric column like
  'Order' will produce two options: "Order" and "Order (as row ID)".
- Fixes exports to correct the formatting of visible columns. This addresses multiple bugs:
  1. Formatting wasn't used, e.g. a Ref showing a custom-formatted date was still presented as YYYY-MM-DD in CSVs.
  2. Ref showing a Numeric column was formatted as if a row ID (e.g. `Table1[1.5]`), which is very wrong.
- If importing into a table that doesn't have a primary view, don't switch page after import.

Refactorings:
- Generalize GenImporterView to be usable in more cases; removed near-duplicated logic from node side
- Some other refactoring in importing code.
- Fix field/column option selection in ValueParser
- Add NUM() helper to turn integer-valued floats into ints, useful for "as row ID" lookups.

Test Plan: Added test cases for imports into reference columns, updated Exports test fixtures.

Reviewers: georgegevoian

Reviewed By: georgegevoian

Differential Revision: https://phab.getgrist.com/D3875
This commit is contained in:
Dmitry S
2023-04-25 17:11:25 -04:00
parent 7a12a8ef28
commit 65013331a3
17 changed files with 290 additions and 339 deletions

Binary file not shown.

Binary file not shown.

View File

@@ -1,4 +1,4 @@
Text Bar,Int Text,Text Formula
"the ""quote marks"" ?",Integer[500],a --- grist https://www.getgrist.com/
"b ,d",Integer[200],"b ,d --- https://www.getgrist.com/"
"the ""quote marks"" ?",,a --- grist https://www.getgrist.com/
Text Bar,Int Text,Text Formula,RowId
"the ""quote marks"" ?",500,a --- grist https://www.getgrist.com/,Text[3]
"b ,d",200,"b ,d --- https://www.getgrist.com/",Text[2]
"the ""quote marks"" ?",0,a --- grist https://www.getgrist.com/,
1 Text Bar Int Text Text Formula RowId
2 the "quote marks" ? Integer[500] 500 a --- grist https://www.getgrist.com/ Text[3]
3 b ,d Integer[200] 200 b ,d --- https://www.getgrist.com/ Text[2]
4 the "quote marks" ? 0 a --- grist https://www.getgrist.com/

Binary file not shown.

View File

@@ -0,0 +1,5 @@
Label,PName,PIndex,PIndex2,PDate,PRowID,PID
Foo2,Clean,1000,"1,000",27 Mar 2023,,0
Bar2,Wash,3000,"2,000",,Projects[2],2
Baz2,Build2,,2,20 Mar 2023,Projects[1],1
Zoo2,Clean,2000,"4,000",24 Apr 2023,Projects[3],3
1 Label PName PIndex PIndex2 PDate PRowID PID
2 Foo2 Clean 1000 1,000 27 Mar 2023 0
3 Bar2 Wash 3000 2,000 Projects[2] 2
4 Baz2 Build2 2 20 Mar 2023 Projects[1] 1
5 Zoo2 Clean 2000 4,000 24 Apr 2023 Projects[3] 3