Skip to content

Commit 213dd21

Browse files
committed
Add support for using *LIBL with DCLF in CL
Signed-off-by: worksofliam <[email protected]>
1 parent de8f734 commit 213dd21

File tree

4 files changed

+81
-0
lines changed

4 files changed

+81
-0
lines changed

cli/src/targets.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -688,6 +688,10 @@ export class Targets {
688688
files.forEach(def => {
689689
const possibleObject = def.file;
690690
if (possibleObject) {
691+
if (possibleObject.library?.toUpperCase() === `*LIBL`) {
692+
possibleObject.library = undefined; // This means lookup as normal
693+
}
694+
691695
if (possibleObject.library) {
692696
this.logger.fileLog(ileObject.relativePath, {
693697
message: `Definition to ${possibleObject.library}/${possibleObject.name} ignored due to qualified path.`,

cli/test/cldclf.test.ts

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import { beforeAll, describe, expect, test } from 'vitest';
2+
3+
import { Targets } from '../src/targets'
4+
import { setupFixture } from './fixtures/projects';
5+
import { ReadFileSystem } from '../src/readFileSystem';
6+
7+
describe(`CL with DCLF`, () => {
8+
const project = setupFixture(`cldclf`);
9+
10+
const fs = new ReadFileSystem();
11+
const targets = new Targets(project.cwd, fs);
12+
13+
beforeAll(async () => {
14+
project.setup();
15+
await targets.loadProject();
16+
17+
expect(targets.getTargets().length).toBeGreaterThan(0);
18+
targets.resolveBinder();
19+
});
20+
21+
test(`Objects are loaded`, () => {
22+
expect(targets).toBeDefined();
23+
expect(targets.binderRequired()).toBeFalsy();
24+
25+
const targetObjects = targets.getTargets();
26+
27+
expect(targetObjects.length).toBe(2);
28+
29+
expect(targetObjects.some(t => t.systemName === `APGM` && t.type === `PGM` && t.extension === `clle`)).toBeTruthy();
30+
expect(targetObjects.some(t => t.systemName === `DEPARTMENT` && t.type === `FILE` && t.extension === `table`)).toBeTruthy();
31+
});
32+
33+
test(`CL has valid dependency`, () => {
34+
const apgm = targets.getTarget({systemName: `APGM`, type: `PGM`});
35+
expect(apgm).toBeDefined();
36+
37+
const logs = targets.logger.getLogsFor(apgm.relativePath);
38+
console.log(logs);
39+
expect(logs.length).toBe(0);
40+
41+
expect(apgm.deps.length).toBe(1);
42+
expect(apgm.deps[0].systemName).toBe(`DEPARTMENT`);
43+
expect(apgm.deps[0].type).toBe(`FILE`);
44+
});
45+
});
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
PGM
2+
DCLF FILE(*LIBL/DEPARTMENT) OPNID(SAVRSTLIB)
3+
ENDPGM
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
--https://www.ibm.com/docs/en/i/7.3?topic=tables-department-table-department
2+
3+
CREATE OR REPLACE TABLE DEPARTMENT
4+
(DEPTNO CHAR(3) NOT NULL,
5+
DEPTNAME VARCHAR(36) NOT NULL,
6+
MGRNO CHAR(6) NOT NULL,
7+
ADMRDEPT CHAR(3) NOT NULL,
8+
LOCATION CHAR(16) NOT NULL,
9+
PRIMARY KEY (DEPTNO));
10+
11+
ALTER TABLE DEPARTMENT
12+
ADD FOREIGN KEY ROD (ADMRDEPT)
13+
REFERENCES DEPARTMENT
14+
ON DELETE CASCADE;
15+
16+
-- Remove circular reference
17+
--ALTER TABLE DEPARTMENT
18+
-- ADD FOREIGN KEY RDE (MGRNO)
19+
-- REFERENCES EMPLOYEE
20+
-- ON DELETE SET NULL;
21+
22+
-- CREATE UNIQUE INDEX XDEPT1
23+
-- ON DEPARTMENT (DEPTNO);
24+
25+
-- CREATE INDEX XDEPT2
26+
-- ON DEPARTMENT (MGRNO);
27+
28+
-- CREATE INDEX XDEPT3
29+
-- ON DEPARTMENT (ADMRDEPT);

0 commit comments

Comments
 (0)