msaccess-vcs-addin icon indicating copy to clipboard operation
msaccess-vcs-addin copied to clipboard

VCS 4.0.34 Data Macros not exported when using Export Selected from the ribbon on a table

Open arpm-awv opened this issue 3 months ago • 6 comments

Using VCS 4.0.34 If I select a table that I have just updated the data macro (After Update in this case), then use the Export Selected button on the Version Control ribbon, the data macro is not exported.

Opening the add-in and running Export All Source does export the data macro.

arpm-awv avatar Mar 11 '24 19:03 arpm-awv

Great question! Right now, it just exports the primary component type that was selected. You can see the mapping for this in the following function:

'---------------------------------------------------------------------------------------
' Procedure : GetClassFromObject
' Author    : Adam Waller
' Date      : 2/22/2023
' Purpose   : Returns a database component class from a database object. (Used when
'           : exporting a single object.)
'           : Note that not all component types are supported.
'---------------------------------------------------------------------------------------
'
Public Function GetClassFromObject(objItem As AccessObject) As IDbComponent

    Dim cItem As IDbComponent

    ' Map to correct component class
    Select Case objItem.Type
        Case acForm:    Set cItem = New clsDbForm
        Case acMacro:   Set cItem = New clsDbMacro
        Case acModule:  Set cItem = New clsDbModule
        Case acQuery:   Set cItem = New clsDbQuery
        Case acReport:  Set cItem = New clsDbReport
        Case acTable:   Set cItem = New clsDbTableDef
        Case Else
            ' Not currently supported
    End Select

    ' Set database item and return class instance
    If Not cItem Is Nothing Then
        Set cItem.DbObject = objItem
        Set GetClassFromObject = cItem
    End If

End Function

However, as you encountered here, there are some underlying component types that also come from the same parent object. For example, a table exports the TableDef object definition, but it could also involve table data, table data macros, hidden attribute, or document properties.

To support this use case, we would need to refactor this function to return a collection of component classes, and then iterate through each of the classes during the export. That would provide a more comprehensive export when selecting a single component.

For what it's worth, in my personal development practices, I hardly ever export a single object. With fast save turned on (exporting only changed items), it takes less than a second to scan for changes and export any changed objects. I just click the button to Export Source Files and then I review the changes in GitHub Desktop. This lets me easily select what I want included or excluded from the next commit.

I am interested in hearing more about the cases where you find it helpful to export a single object.

joyfullservice avatar Mar 11 '24 20:03 joyfullservice

It isn't the time that it takes, it's the noise. If I modified a single object, I only need to export that object. If I export changed items (even with fast save turned on) I end up with a large commit containing unrelated objects.

After modifying this table data macro, and finding that exporting a single object didn't export the macro, I exported changed items. This resulted in a commit with dozens of unrelated objects included.

arpm-awv avatar Mar 11 '24 20:03 arpm-awv

Thanks, that is some helpful context. Where do you typically see the noise? There are three main areas where I encounter unrelated "changes":

  • After upgrading VCS to a newer version. This is typically a one-time set of change that I usually commit as "VCS Updates".
  • When using different computers with different monitor configurations. This can affect some of the cached geometry of forms and reports.
  • When working with multiple developers on the same project. (Usually from the above reason.)

You can also play with the options in the sanitize levels to see if that helps reduce unwanted noise.

Just to be clear, there is nothing wrong with exporting individual objects as you are doing. I am just wanting to make sure there is not a way to easily resolve the underlying noise issue to help streamline your process. 😄

joyfullservice avatar Mar 11 '24 20:03 joyfullservice

This particular case was complicated by a VCS upgrade as you noted. This was a backend database that I rarely have to modify. I see it more often on front ends, which is how I came to be in the habit of using it. I can't account for the reason in most cases.

arpm-awv avatar Mar 11 '24 20:03 arpm-awv

image

For some reason I'm seeing a lot of this kind of noise. It randomly changes the case of some of my variable names. Not sure if it happened when I built or when I exported.

arpm-awv avatar Mar 15 '24 19:03 arpm-awv

For some reason I'm seeing a lot of this kind of noise. It randomly changes the case of some of my variable names. Not sure if it happened when I built or when I exported.

This is a common issue with the VBA IDE if you are using naming conventions other than PascalCase. Mike Wolfe has a great article on this. It is also mentioned in the FAQ page for this add-in.

Personally, I use the more traditional naming conventions and PascalCase, and virtually never run into this issue. (Other than times when I find myself inconsistent, like using strSQL in one place, and strSql in another place. 😄

joyfullservice avatar Mar 15 '24 21:03 joyfullservice