Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parsing Memo Incomplete #41

Closed
FourShore opened this issue Oct 27, 2022 · 6 comments · Fixed by #42
Closed

Parsing Memo Incomplete #41

FourShore opened this issue Oct 27, 2022 · 6 comments · Fixed by #42
Assignees
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@FourShore
Copy link

FourShore commented Oct 27, 2022

Hi All

I'm getting an error when trying to write and then read a memo field.

Write call seems to succeed with no error thrown:

newNote := Note{
	Text: "zHdVIxu2TuBmm/nY9CDbLotel+ToRIxApggFvFSCjsvU//uZXDjbXBfliSpkSubmzu/Imn7NTs6Y1zD7Q2rZHg==",
}

newRow, err := table.RowFromStruct(newD)
if err != nil {
	panic(dbase.GetErrorTrace(err))
}

Add the new row to the database table.
err = newRow.Write()
if err != nil {
	panic(dbase.GetErrorTrace(err))
}

But when I try to read the row I get:

panic: dbase-table-bytestorow-3:dbase-interpreter-parsememo-1:dbase-io-readmemo-5:parsing memo failed at column field: TEXT failed with error: INCOMPLETE

Here's my read code:

row, err := table.Row()
if err != nil {
	panic(dbase.GetErrorTrace(err))
}

Full log

[dbase] [DEBUG] 2022/10/27 17:28:35 Reading row: 21 at offset: 1139
[dbase] [DEBUG] 2022/10/27 17:28:35 Converting row data (31 bytes) to row struct...
[dbase] [DEBUG] 2022/10/27 17:28:35 Reading memo block 367 at position 23488
[dbase] [DEBUG] 2022/10/27 17:28:35 Memo block header => text: true, length: 88
[dbase] [ERROR] 2022/10/27 17:28:35 dbase-io-readmemo-5:INCOMPLETE
[dbase] [ERROR] 2022/10/27 17:28:35 dbase-interpreter-parsememo-1:parsing memo failed at column field: TEXT failed with error: INCOMPLETE
[dbase] [ERROR] 2022/10/27 17:28:35 dbase-table-bytestorow-3:parsing memo failed at column field: TEXT failed with error: INCOMPLETE
[dbase] [DEBUG] 2022/10/27 17:28:35 Closing file: ./files/AAQBX.DBF
[dbase] [DEBUG] 2022/10/27 17:28:35 Closing related file: ./files/AAQBX.DBF
panic: dbase-table-bytestorow-3:dbase-interpreter-parsememo-1:dbase-io-readmemo-5:parsing memo failed at column field: TEXT failed with error: INCOMPLETE

I noticed that this only happens when "Text" is greater than 56 characters.

Thanks for all the work you guys do.

@Valentin-Kaiser Valentin-Kaiser self-assigned this Oct 28, 2022
@Valentin-Kaiser
Copy link
Owner

Hello FourShour,

Thank you for the issue and your kind words.
I will take a closer look at the problem and try to find a solution. But I already suspect what the problem is.

I noticed that this only happens when "Text" is greater than 56 characters.

A record of a memo file is limited by the block size specified in the header. When writing, I do not yet check whether this limitation is exceeded by the data.

@Valentin-Kaiser Valentin-Kaiser added the bug Something isn't working label Oct 28, 2022
@FourShore
Copy link
Author

Thanks for the quick response! I'll try out the fix when I can at the beginning of the week.

I'm migrating/integrating with an old FoxPro application so dbase is new to me. Do I need to do something special in order to write a a memo value greater than the block size? I see in the DBF file that there are values that are larger than 56 characters.

@Valentin-Kaiser
Copy link
Owner

It is not possible to write a record to a memo file that is larger than the block size. If you still want to save this data, you have to change the database schema and increase the size.

Can you send me the files so I can take a closer look?

@FourShore
Copy link
Author

FourShore commented Oct 31, 2022

files.zip

I attached the dbf and fpt files. I'm new to this tech stack so sorry if it's something obvious.

The column I'm having issues with is the TRAITE column

@Valentin-Kaiser
Copy link
Owner

Unfortunately, I don't know much about DBF either, but apparently I have an error in my library that is based on a comprehension problem. A memo entry can very well be larger than one block. I will look into fixing this.

@FourShore
Copy link
Author

Confirmed working now. Thanks so much! Definitely starring this repo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants