diff --git a/src/api/components/getMemberInfo.ts b/src/api/components/getMemberInfo.ts index dd591a35f..3d9559ff9 100644 --- a/src/api/components/getMemberInfo.ts +++ b/src/api/components/getMemberInfo.ts @@ -7,7 +7,7 @@ import { IBMiMember } from "../types"; export class GetMemberInfo implements IBMiComponent { static ID = 'GetMemberInfo'; private readonly procedureName = 'GETMBRINFO'; - private readonly currentVersion = 1; + private readonly currentVersion = 2; private installedVersion = 0; reset() { @@ -160,11 +160,15 @@ function getSource(library: string, name: string, version: number) { ` , rtrim( substr( Buffer, 39, 10 ) )`, ` , rtrim( substr( Buffer, 49, 10 ) )`, ` , timestamp_format( case substr( Buffer, 59, 1 )`, - ` when '1' then '20' else '19' end concat `, - ` substr( Buffer, 60, 12 ) , 'YYYYMMDDHH24MISS')`, + ` when '1' then '20' concat substr( Buffer, 60, 12 )`, + ` when '0' then '19' concat substr( Buffer, 60, 12 )`, + ` else '19700101000000'`, + ` end, 'YYYYMMDDHH24MISS')`, ` , timestamp_format( case substr( Buffer, 72, 1 )`, - ` when '1' then '20' else '19' end concat `, - ` substr( Buffer, 73, 12 ), 'YYYYMMDDHH24MISS')`, + ` when '1' then '20' concat substr( Buffer, 73, 12 )`, + ` when '0' then '19' concat substr( Buffer, 73, 12 )`, + ` else '19700101000000'`, + ` end, 'YYYYMMDDHH24MISS')`, ` , rtrim( substr( Buffer, 85, 50 ) )`, ` , case substr( Buffer, 135, 1 ) when '1' then 'Y' else 'N' end`, ` );`, diff --git a/src/api/tests/suites/components.test.ts b/src/api/tests/suites/components.test.ts index b21c03802..7bf79dc80 100644 --- a/src/api/tests/suites/components.test.ts +++ b/src/api/tests/suites/components.test.ts @@ -53,5 +53,31 @@ describe('Component Tests', () => { expect(error).toBeInstanceOf(Tools.SqlError); expect(error.sqlstate).toBe("38501"); } + + // Check getMemberInfo for empty member. + const config = connection.getConfig(); + const tempLib = config!.tempLibrary, + tempSPF = `O_ABC`.concat(connection!.variantChars.local), + tempMbr = `O_ABC`.concat(connection!.variantChars.local); + + const result = await connection!.runCommand({ + command: `CRTSRCPF ${tempLib}/${tempSPF} MBR(${tempMbr})`, + environment: 'ile' + }); + + const memberInfoC = await component.getMemberInfo(connection, tempLib, tempSPF, tempMbr); + expect(memberInfoC).toBeTruthy(); + expect(memberInfoC?.library).toBe(tempLib); + expect(memberInfoC?.file).toBe(tempSPF); + expect(memberInfoC?.name).toBe(tempMbr); + expect(memberInfoC?.created).toBeTypeOf('number'); + expect(memberInfoC?.changed).toBeTypeOf('number'); + + // Cleanup... + await connection!.runCommand({ + command: `DLTF ${tempLib}/${tempSPF}`, + environment: 'ile' + }); + }); });