Skip to content

Commit

Permalink
Merge branch 'dev-jp' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
josef-poetzl authored Nov 8, 2023
2 parents a666c9d + 3e82751 commit 43c7133
Show file tree
Hide file tree
Showing 10 changed files with 314 additions and 115 deletions.
Binary file modified Ribbon/Build/MSAccessVCSLib_win32.dll
Binary file not shown.
Binary file modified Ribbon/MSAccessVCS_Ribbon.twinproj
Binary file not shown.
23 changes: 20 additions & 3 deletions Ribbon/Source/Sources/AddInRibbon.twin
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@

Class AddInRibbon

Private Const AddInFileName As String = "msaccess-vcs"
' don't use "Version Control"
' * FileName without " " is simple to use for Applaction.Run
' * "Version Control" has little significance as to what kind of file this is
Private Const AddInFileNameWithExt As String = AddInFileName & ".accda"

Implements IDTExtensibility2

/*
Expand Down Expand Up @@ -115,7 +121,7 @@ Class AddInRibbon
Dim strTempDbPath As String = App.Path & "Temp.accdb"

' Get relative path to Access add-in (Should be in same folder as this dll)
strAddInPath = App.Path & "\Version Control.accda"
strAddInPath = AddInFile

' See if add-in project is already loaded.
For Each proj In applicationObject.VBE.VBProjects
Expand Down Expand Up @@ -143,10 +149,12 @@ Class AddInRibbon
' The following lines will load the add-in at the application level,
' but will not actually call the function. Ignore the error of function not found.
' https://stackoverflow.com/questions/62270088/how-can-i-launch-an-access-add-in-not-com-add-in-from-vba-code
'
' not required if call methods with full add-in name
On Error Resume Next
With applicationObject
.DoCmd.Hourglass True
.Run strAddInPath & "!DummyFunction"
.Run AddInCallPath & ".DummyFunction"
.DoCmd.Hourglass False
End With
On Error GoTo 0
Expand All @@ -169,7 +177,14 @@ Class AddInRibbon

End Function

Private Property Get AddInFile() As String
AddInFile = App.Path & "\" & AddInFileNameWithExt
End Property

Private Property Get AddInCallPath() As String
AddInCallPath = App.Path & "\" & AddInFileName
End Property

/*
Wrapper for the file system object
*/
Expand All @@ -186,7 +201,9 @@ Class AddInRibbon
Public Sub OnActionButton(control As IRibbonControl)
If VerifyAccessAddinProject Then
' Pass the control ID to the handler function
applicationObject.Run "MSAccessVCS.HandleRibbonCommand", control.Id
' applicationObject.Run "MSAccessVCS.HandleRibbonCommand", control.Id
' run with add-in-file:
applicationObject.Run AddInCallPath & ".HandleRibbonCommand", control.Id
End If
End Sub

Expand Down
86 changes: 86 additions & 0 deletions Tests/Version Control/clsSqlFormatterTests.cls
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
VERSION 1.0 CLASS
BEGIN
MultiUse = -1 'True
END
Attribute VB_Name = "clsSqlFormatterTests"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Option Compare Text
Option Explicit

'AccUnit:TestClass
' Call: TestSuite.AddByClassName("clsSqlFormatterTests").Run

Private m_SqlFormatter As clsSqlFormatter

'--------------------------------------------------------------------
' Test Preparation / Cleanup
'--------------------------------------------------------------------
Public Sub Setup()
Set m_SqlFormatter = New clsSqlFormatter
End Sub

Public Sub TearDown()
Set m_SqlFormatter = Nothing
End Sub

'--------------------------------------------------------------------
' Tests
'--------------------------------------------------------------------

Public Sub TestSqlString_SingleQuote()

Const UnformattedSql As String = "Select 'xxx\' & FileName As FullFileName, 'a''bc' as T1, ""a'bc"" as T2 From FileTable"
Const Expected As String = _
"Select" & vbNewLine & _
" 'xxx\' & FileName As FullFileName," & vbNewLine & _
" 'a''bc' as T1," & vbNewLine & _
" ""a'bc"" as T2" & vbNewLine & _
"From" & vbNewLine & _
" FileTable"

Dim Actual As String
Actual = m_SqlFormatter.FormatSQL(UnformattedSql)

Assert.That Actual, Iz.EqualTo(Expected)

End Sub

Public Sub TestSqlString_DoubleQuote()

Const UnformattedSql As String = "Select ""xxx\"" & FileName As FullFileName, ""a""""bc"" as T1, ""a'bc"" as T2 From FileTable"
Const Expected As String = _
"Select" & vbNewLine & _
" ""xxx\"" & FileName As FullFileName," & vbNewLine & _
" ""a""""bc"" as T1," & vbNewLine & _
" ""a'bc"" as T2" & vbNewLine & _
"From" & vbNewLine & _
" FileTable"

Dim Actual As String
Actual = m_SqlFormatter.FormatSQL(UnformattedSql)

Assert.That Actual, Iz.EqualTo(Expected)

End Sub

Public Sub TestSqlString_Like()

Const UnformattedSql As String = "Select * From Table Where T like 'a[1-5]z'"
Const Expected As String = _
"Select" & vbNewLine & _
" *" & vbNewLine & _
"From" & vbNewLine & _
" Table" & vbNewLine & _
"Where" & vbNewLine & _
" T like 'a[1-5]z'"

Dim Actual As String
Actual = m_SqlFormatter.FormatSQL(UnformattedSql)

Assert.That Actual, Iz.EqualTo(Expected)

End Sub

Loading

0 comments on commit 43c7133

Please sign in to comment.