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

Export with data fails for linked tables #385

Closed
ollypsilon opened this issue Mar 11, 2023 · 13 comments
Closed

Export with data fails for linked tables #385

ollypsilon opened this issue Mar 11, 2023 · 13 comments
Labels
pending resolved Possibly resolved, needs testing or confirmation

Comments

@ollypsilon
Copy link

https://github.com/joyfullservice/msaccess-vcs-integration/blob/0ff31fe6ba208356d774ace113a67f48df4e000e/Version%20Control.accda.src/modules/clsDbTableData.cls#L62

For me export of linked table with data fail with error 31532.
When replacing acEmbedSchema' with 0 or better with acExportAllTableAndFieldProperties all seems to be fine (needs to be verified).

@joyfullservice
Copy link
Owner

Hmm... I am able to export a linked table as XML data with no problem... I tried linking the users table from your sample database, and this exported with no issues for me.

What type of a linked table is this? I am assuming that it would be a Microsoft Access database table linked to a back-end database.

Also, just as a consideration here, after splitting to a front-end/back-end database setup, you may not need to include the table data as part of your export. The linked table allows you to develop various versions of the front end that all connect to the same back end data.

@joyfullservice joyfullservice added the need more details Further information needed to understand issue label Mar 11, 2023
@ollypsilon
Copy link
Author

ollypsilon commented Mar 12, 2023

Hmm... I am able to export a linked table as XML data with no problem... I tried linking the users table from your sample database, and this exported with no issues for me.

Strange, I get the error as described.

What type of a linked table is this? I am assuming that it would be a Microsoft Access database table linked to a back-end database.

Yes, it's a MS Access database as you can see in my sample database you can access in our private repo.

Also, just as a consideration here, after splitting to a front-end/back-end database setup, you may not need to include the table data as part of your export. The linked table allows you to develop various versions of the front end that all connect to the same back end data.

Yes, sure, there's no need to include data. That was a leftover after splitting database as VCS option for this table hasn't be edited to exclude data. But as the error occurred I wanted to address it. Sure, I don't need data for linked tables 😉

Access is Microsoft® Access® für Microsoft 365 MSO (Version 2302 Build 16.0.16130.20186) 64 Bit
System is Windows 11 Pro, Version 22H2, Build 22621.1344, Windows Feature Experience Pack 1000.22639.1000.0

What else do you need?

@ollypsilon
Copy link
Author

ollypsilon commented Mar 12, 2023

During build linked tables are built correct.
But as also mentioned there's no need to import data as they reside in the source table.
During import module looks for table definition but can't find it. Even tough linked table is created correct.

Importing table data...
USysRibbons.txt
Users.xml
WARNING: Table definition does not exist for 'Users'. This must be created before importing table data.
[2] table data processed.

I wonder what would happen if table data for a linked table would have been exported and tried to import during build.

I've updated our private repo, you'll find everything there.

@joyfullservice
Copy link
Owner

WARNING: Table definition does not exist for 'Users'. This must be created before importing table data.

This message seems to indicate that the table was not found in MSysObjects. See the TableExists function used in clsDbTableData.IDbComponent_Import.

After reviewing this, I found an issue with the TableExists function where it was only checking for local tables, not linked ones. I will update the function shortly.

I wonder what would happen if table data for a linked table would have been exported and tried to import during build.

Well, at the moment it did nothing because the TableExists function was not working correctly for linked tables. But I don't think we should reload data in a linked table. Although in some cases this is technically feasible, it seems like a bad idea because we are then impacting data outside the scope of the database being built.

I think I will update this code to ensure that data is only being loaded into local tables, and show a warning message if a user attempts to load data into a linked table.

joyfullservice added a commit that referenced this issue Mar 13, 2023
Fixed an issue with table detection and adjusted to prevent importing table data into a linked table during a build or merge operation. #385
joyfullservice added a commit that referenced this issue Mar 13, 2023
Attempting to export table data as XML can throw an error if you use the acEmbedSchema option on a linked table. #385
@joyfullservice
Copy link
Owner

Yes, sure, there's no need to include data. That was a leftover after splitting database as VCS option for this table hasn't be edited to exclude data. But as the error occurred I wanted to address it. Sure, I don't need data for linked tables 😉

Thanks for pointing out the error on export. It should be fixed now with fae2ee6.

@joyfullservice joyfullservice added pending resolved Possibly resolved, needs testing or confirmation and removed need more details Further information needed to understand issue labels Mar 13, 2023
@ollypsilon
Copy link
Author

Yes, sure, there's no need to include data. That was a leftover after splitting database as VCS option for this table hasn't be edited to exclude data. But as the error occurred I wanted to address it. Sure, I don't need data for linked tables 😉

Thanks for pointing out the error on export. It should be fixed now with fae2ee6.

For me it looks fine now, no data being imported.
From Build.log:
Table data from 'Users' was not imported.

But where should this be logged? It's not in Build.log.
https://github.com/joyfullservice/msaccess-vcs-integration/blob/fae2ee6a50ea2076af88e0b5ee60fed0187d49ec/Version%20Control.accda.src/modules/clsDbTableData.cls#L388

@ollypsilon
Copy link
Author

Thanks for pointing out the error on export. It should be fixed now with fae2ee6.

Unfortunately spotted another issue on export for linked table when link source is not accessible:
https://github.com/joyfullservice/msaccess-vcs-integration/blob/6645a08c834d153b6801daec64830237bde21159/Version%20Control.accda.src/modules/clsDbTableData.cls#L67

Either inspect if link source is accessible, table data can be read etc. or just fetch error, give warning and ask user to check (as there is no need to export linked table data IMHO).

joyfullservice added a commit that referenced this issue Mar 14, 2023
Thanks, @ollypsilon for identifying this oversight! #385
@joyfullservice
Copy link
Owner

But where should this be logged? It's not in Build.log.

Good catch. I have fixed the logging for warning messages to make sure they get written to the log file. 👍

joyfullservice added a commit that referenced this issue Mar 14, 2023
@joyfullservice
Copy link
Owner

Unfortunately spotted another issue on export for linked table when link source is not accessible:

https://github.com/joyfullservice/msaccess-vcs-integration/blob/6645a08c834d153b6801daec64830237bde21159/Version%20Control.accda.src/modules/clsDbTableData.cls#L67

Either inspect if link source is accessible, table data can be read etc. or just fetch error, give warning and ask user to check

Error handling has been added here.

(as there is no need to export linked table data IMHO).

I agree. For purposes of managing source code, there are very few cases where you need to export table data, and probably not many reasons to export data from a linked table. But people can be very creative in how they use the system, so I am not preventing them from doing this. 😄 Hopefully most people that understand the concept of version control also realize that version control is not a backup solution for their data.

@ollypsilon
Copy link
Author

Error handling has been added here.

Well, I think I would omit If DebugMode(True) Then On Error GoTo 0 Else because it's a "known" error, not trapped on purpose. So just On Error Resume Next.
And maybe put it just for the export portion of the code here: Application.ExportXML acExportTable, m_Table.Name, strFile? Because there are other steps which could raise an error, too.

With Debug VBA Errors ticked I just get the runtime error with option to debug.
With debug option not set the error is logged in Export.log, which would be fine for me no matter if debug errors is set or not.

Exporting table data...       
  Local table
    Sanitized in 0,001 seconds.
  Users

-------------------------------------
ERROR: Unhandled error found before `On Error` directive
Error 31532: PAF 2023+ konnte die Daten nicht exportieren. Source: Unknown
-------------------------------------

@ollypsilon
Copy link
Author

Beside the export table data part I wonder if on table definition export it should be checked if linked table is defined correct.
Like in my test case with link source damaged (remote database not available) it could be known in case of split database with front-end development isolated or it could be by accident, then exporting a definition which would cause some issues on build from source. Like you did on table data export part you might be able to log a warning.

@ollypsilon
Copy link
Author

I'll close this issue as the main reason has been fixed 👍
Maybe my last two annotations are worth to create a new enhancement topic.

@joyfullservice
Copy link
Owner

Thanks! Feel free to open a new enhancement issue for the items you mentioned.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pending resolved Possibly resolved, needs testing or confirmation
Projects
None yet
Development

No branches or pull requests

2 participants