Skip to content

Commit bcf709c

Browse files
committed
cast as string bump version
1 parent 9e0d91c commit bcf709c

2 files changed

Lines changed: 20 additions & 3 deletions

File tree

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "libflatterer"
3-
version = "0.22.1"
3+
version = "0.23.0"
44
authors = ["David Raznick <kindly@gmail.com>"]
55
edition = "2021"
66
description = "Lib to make JSON flatterer"
@@ -28,7 +28,7 @@ lazy_static = "1"
2828
typed-builder = "0.18.0"
2929
num_cpus = "1.13.1"
3030
flate2 = "1.0.24"
31-
csvs_convert = { version = "0.11.1", default-features = false, features = ["converters"] }
31+
csvs_convert = { version = "0.12.0", default-features = false, features = ["converters"] }
3232
bytes = "1.4.0"
3333
url = "2.3.1"
3434
jsonpath-rust = "0.3.0"

src/lib.rs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1695,9 +1695,16 @@ impl FlatFiles {
16951695
None => table_metadata.field_titles.push(row.field_name.clone()),
16961696
}
16971697

1698+
let mut string_field = false;
1699+
16981700
match row.field_type {
16991701
Some(field_type) => {
17001702
table_metadata.supplied_types.push(field_type.clone());
1703+
match field_type.as_str() {
1704+
"string" => string_field = true,
1705+
"text" => string_field = true,
1706+
_ => {}
1707+
}
17011708
#[cfg(not(target_family = "wasm"))]
17021709
match field_type.as_str() {
17031710
"boolean" => table_metadata
@@ -1723,8 +1730,13 @@ impl FlatFiles {
17231730
}
17241731
}
17251732

1733+
let mut link_field = false;
1734+
if !self.options.no_link && row.field_name.starts_with("_link") {
1735+
link_field = true;
1736+
}
1737+
17261738
let options = DescriberOptions::builder()
1727-
.force_string(!self.options.no_link && row.field_name.starts_with("_link"))
1739+
.force_string(link_field || string_field)
17281740
.stats(self.options.stats && self.options.threads == 1)
17291741
.build();
17301742

@@ -4487,6 +4499,11 @@ mod tests {
44874499
test_output("fixtures/basic.json", vec![], json!({"all_strings": true}))
44884500
}
44894501

4502+
#[test]
4503+
fn test_only_null_field() {
4504+
test_output("fixtures/only_null_field.json", vec![], json!({"fields_only": false, "fields_csv": "fixtures/only_null_fields.csv"}))
4505+
}
4506+
44904507
#[test]
44914508
fn test_s3_input() {
44924509
if std::env::var("AWS_DEFAULT_REGION").is_ok() {

0 commit comments

Comments
 (0)