From dc1320d043efd308f0a22932c03fd70f4dc3123f Mon Sep 17 00:00:00 2001 From: Christian Jorgensen Date: Fri, 21 Feb 2025 11:01:15 +0100 Subject: [PATCH 1/2] Fix TIMESTAMP_FORMAT error in GetMbrInfo --- src/api/components/getMemberInfo.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) 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`, ` );`, From 846d6ebbfa3bc035947f47ed757776ab8558e740 Mon Sep 17 00:00:00 2001 From: Christian Jorgensen Date: Fri, 21 Feb 2025 18:54:57 +0100 Subject: [PATCH 2/2] Add test for valid dates from GetMbrInfo component --- src/api/tests/suites/components.test.ts | 26 +++++++++++++++++++++++++ 1 file changed, 26 insertions(+) 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' + }); + }); });