columns of "Char" type in dbf are trimmed (ltrim) of space.
Describe the bug columns of "Char" type in dbf are trimmed (ltrim) of space.
To Reproduce Steps to reproduce the behavior: take a dbf with a "C" data type and add value in that column as " Hi there" Read it using DbfTable dbfrecord you will get the value of that column as "Hi There". the string values are TRIMED.
Solution suggested: following is LINE NO 26 in DbfValueString.cs Value = value.Trim(NullChar,' '); Can change it to Value = value.Trim(NullChar,' '); if(string.IsNullOrWhiteSpace(Value) Value=null; // this is the behaviour when we use ODBC
How to implement this in nuget package please guide
I think that authors can do. And May do in future updates. i pulled, modified and built the dll
On Mon, 4 Sep 2023 at 11:45 AM, grvhack @.***> wrote:
How to implement this is nuget package please guide
— Reply to this email directly, view it on GitHub https://github.com/yellowfeather/DbfDataReader/issues/201#issuecomment-1704672800, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANSHRDDEQCMEUPHLC5GNR63XYVWYTANCNFSM6AAAAAA2VBYSCM . You are receiving this because you authored the thread.Message ID: @.***>
Ok thnx replacing line 26 with: Value = value; if (string.IsNullOrWhiteSpace(Value)) { Value = null; } worked for me instead of Value = value.Trim(NullChar,' '); if(string.IsNullOrWhiteSpace(Value) Value=null; // this is the behaviour when we use ODBC
Looks like there are two separate issues here:
- string values that have whites space at the beginning are being trimmed
- if the string is whitespace only an empty string is returned rather than null
Instead of replacing the current behavior, I'm thinking of adding a couple of options to DbfDataReaderOptions that control the string trimming (e.g. don't trim, trim start, trim end, trim both) and a separate option to control the returning of nulls for empty strings.
Would that work?
That would be great indeed! Thanks 🙏
On Fri, 8 Sep 2023 at 7:20 PM, Chris Richards @.***> wrote:
Looks like there are two separate issues here:
- string values that have whites space at the beginning are being trimmed
- if the string is whitespace only an empty string is returned rather than null
Instead of replacing the current behavior, I'm thinking of adding a couple of options to DbfDataReaderOptions that control the string trimming (e.g. don't trim, trim start, trim end, trim both) and a separate option to control the returning of nulls for empty strings.
Would that work?
— Reply to this email directly, view it on GitHub https://github.com/yellowfeather/DbfDataReader/issues/201#issuecomment-1711707749, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANSHRDF7J45D45WEPSP452TXZMPDVANCNFSM6AAAAAA2VBYSCM . You are receiving this because you authored the thread.Message ID: @.***>