I'm a newbie in nim, and I'd like to make the following assertion work:
import strformat, odbc
template alias(newName: untyped, call: untyped) =
template newName(): untyped = call
proc create_T558B_line(row: SQLRow): string =
alias(PERNR, row[0].intVal) #'Personnel Number'
alias(SEQNR, row[1].intVal) #'Sequential number for payroll period'
alias(PAYTY, row[2].intVal) #'Payroll type'
alias(PAYID, row[3].intVal) #'Payroll Identifier'
alias(PAYDT, row[4].intVal) #'Pay date for payroll result'
alias(PERMO, row[5].intVal) #'Period Parameters'
alias(PABRJ, row[6].intVal) #'Payroll Year'
alias(PABRP, row[7].intVal) #'Payroll Period'
alias(FPBEG, row[8].intVal) #'Start date of payroll period (FOR period)'
alias(FPEND, row[9].intVal) #'End of payroll period (for-period)'
#alias(OCRSN, row[10]) #'Reason for Off-Cycle Payroll' - Keep blank
#alias(SEQNR_CD, row[11]) #'Sequence Number' - Keep blank
&"{PERNR:>08}{SEQNR:>05}{PAYTY:1}{PAYID:1}{PAYDT:>08}{PERMO:2}{PABRJ:4}" &
&"{PABRP:2}{FPBEG:>08}{FPEND:>08}"
# Can't get assert working because I am unsure how to instantiate SQLData since kind is not exported
# assert(create_T558B_line(SqlRow(@[SQLData(intVal: 3000011),
# SQLData(intVal: 1),
# SQLData(intVal: 0),
# SQLData(intVal: 0),
# SQLData(intVal: 20210623),
# SQLData(intVal: 94),
# SQLData(intVal: 2021),
# SQLData(intVal: 13),
# SQLData(intVal: 20210606),
# SQLData(intVal: 20210623)])) ==
# "03000011000010020210623942021132021060620210623", "Failed")
But I get an error, because the kind field is not exported from odbc. What's the best way to handle this?
Could have done something incorrect, but I imported the library, added a call
privateAccess(SQLData)
before the assert and got the following back from the compiler
D:\src\importutils.nim(23, 41) Warning: unknown magic 'PrivateAccess' might crash the compiler [UnknownMagic]
D:\src\BuildPayrollYtds.nim(25, 16) template/generic instantiation of `privateAccess` from here
D:\src\importutils.nim(23, 41) Warning: unknown magic 'PrivateAccess' might crash the compiler [UnknownMagic]
D:\src\BuildPayrollYtds.nim(26, 44) Error: the field 'kind' is not accessible.
I tried replacing with
privateAccess(typeof(SQLData))
And got the same thing?