DbfDataReader icon indicating copy to clipboard operation
DbfDataReader copied to clipboard

columns of "Char" type in dbf are trimmed (ltrim) of space.

Open rajeshnandwani1969 opened this issue 1 year ago • 5 comments

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

rajeshnandwani1969 avatar Jul 24 '23 05:07 rajeshnandwani1969

How to implement this in nuget package please guide

grvhack avatar Sep 04 '23 06:09 grvhack

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: @.***>

rajeshnandwani1969 avatar Sep 04 '23 06:09 rajeshnandwani1969

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

grvhack avatar Sep 04 '23 07:09 grvhack

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?

chrisrichards avatar Sep 08 '23 13:09 chrisrichards

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: @.***>

rajeshnandwani1969 avatar Sep 08 '23 14:09 rajeshnandwani1969