You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
When you use a FixedLengthTypeMapper with ComplexProperty for a given window length, it seems to trim the value of that window prior to pass it to the ComplexProperty's mapper and thus throwing an exception saying the record length does not match the schema.
To Reproduce
Steps to reproduce the behaviour:
class Person
{
public string Name { get; set; }
public Pet Pet1 { get; set; }
public Pet Pet2 { get; set; }
}
class Pet
{
public string Name { get; set; }
public string UniversalPetIdentifier { get; set; }
}
[Fact]
void Test()
{
var personMapper = FixedLengthTypeMapper.Define<Person>();
personMapper.Property(f => f.Name, new Window(10));
personMapper.Ignored(new Window(1));
var petMapper = FixedLengthTypeMapper.Define<Pet>();
petMapper.Property(pet => pet.Name, new Window(10));
petMapper.Property(pet => pet.UniversalPetIdentifier, new Window(5));
petMapper.Ignored(new Window(2));
personMapper.ComplexProperty(p => p.Pet1, petMapper, new Window(17));
personMapper.ComplexProperty(p => p.Pet2, petMapper, new Window(17));
var line = "John Doggy dog01 Rain cat01 ";
var reader = personMapper.GetReader(new StringReader(line));
var persons = reader.ReadAll().ToList();
// Throws The record did not meet the length requirements specified in the schema. Record 1.
// The ColumnValue that is throwing the exception is: Doggy dog01
// It has a length of 15 instead of 17.
}
Expected behaviour
I expect that the value is not trimmed prior to pass it to the ComplexProperty's mapper and that the length match the schema.
Version:
4.16
The text was updated successfully, but these errors were encountered:
There were actually several bugs causing this. I had to mark the FixedLengthComplexColumn to not trim, like I mentioned above. I was also trimming inside of the outer fixed length reader because it always trims leading or trailing white space depending on what you set FixedLengthOptions.FillCharacter to. I now only trim off the fill character for normal columns, not complex columns. Finally, unrelated to your reported issue, the CSV parser would also trim trailing white space off text unless you explicitly told it not to - I updated the CSV parser to never strip white space off since none of my tests seemed to care (another piece of code does this already as part of parsing CSV files).
I debated going back to my current 4.x tag, branch off that, and doing a release off that; however, I decided it's too much of a pain have separate 4.x changes along side my master branch. I created a 5.0.0 release off the master branch with these bug fixes incorporated: https://www.nuget.org/packages/FlatFiles/. There are several breaking changes in 5.0.0, primary that SeparatedValue* classes were renamed to Delimited*. Hopefully this is not too much a pain.
Please let me know if you encounter any issues. If I don't hear back after a while, I will just close the ticket.
Describe the bug
When you use a FixedLengthTypeMapper with ComplexProperty for a given window length, it seems to trim the value of that window prior to pass it to the ComplexProperty's mapper and thus throwing an exception saying the record length does not match the schema.
To Reproduce
Steps to reproduce the behaviour:
Expected behaviour
I expect that the value is not trimmed prior to pass it to the ComplexProperty's mapper and that the length match the schema.
Version:
4.16
The text was updated successfully, but these errors were encountered: