Skip to content

Commit 66d596e

Browse files
committed
Add tests for casing ARRAY data types
1 parent fb60928 commit 66d596e

File tree

3 files changed

+83
-0
lines changed

3 files changed

+83
-0
lines changed

src/languages/db2/db2.keywords.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,7 @@ export const keywords: string[] = [
403403

404404
export const dataTypes: string[] = [
405405
// https://www.ibm.com/docs/en/db2-for-zos/12?topic=columns-data-types
406+
'ARRAY',
406407
'CCSID',
407408
'CHAR',
408409
'CHARACTER',

src/languages/db2i/db2i.keywords.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,7 @@ export const keywords: string[] = [
498498

499499
export const dataTypes: string[] = [
500500
// https://www.ibm.com/docs/en/i/7.2?topic=iaodsd-odbc-data-types-how-they-correspond-db2-i-database-types
501+
'ARRAY',
501502
'BIGINT',
502503
'BINARY',
503504
'BIT',

test/features/arrayLiterals.ts

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,87 @@ export default function supportsArrayLiterals(format: FormatFn, cfg: ArrayLitera
3131
];
3232
`);
3333
});
34+
35+
it('supports preserving ARRAY[] literals keywords casing', () => {
36+
expect(
37+
format(
38+
`SELECT ArrAy[1, 2] FROM aRRAY['aaa', 'bbb', 'ccc', 'ddd', 'eee', 'fff', 'ggg', 'hhh', 'iii', 'jjj'];`,
39+
{
40+
dataTypeCase: 'preserve',
41+
}
42+
)
43+
).toBe(dedent`
44+
SELECT
45+
ArrAy[1, 2]
46+
FROM
47+
aRRAY[
48+
'aaa',
49+
'bbb',
50+
'ccc',
51+
'ddd',
52+
'eee',
53+
'fff',
54+
'ggg',
55+
'hhh',
56+
'iii',
57+
'jjj'
58+
];
59+
`);
60+
});
61+
62+
it('supports converting ARRAY[] literals keywords to uppercase', () => {
63+
expect(
64+
format(
65+
`SELECT ArrAy[1, 2] FROM aRRAY['aaa', 'bbb', 'ccc', 'ddd', 'eee', 'fff', 'ggg', 'hhh', 'iii', 'jjj'];`,
66+
{
67+
dataTypeCase: 'upper',
68+
}
69+
)
70+
).toBe(dedent`
71+
SELECT
72+
ARRAY[1, 2]
73+
FROM
74+
ARRAY[
75+
'aaa',
76+
'bbb',
77+
'ccc',
78+
'ddd',
79+
'eee',
80+
'fff',
81+
'ggg',
82+
'hhh',
83+
'iii',
84+
'jjj'
85+
];
86+
`);
87+
});
88+
89+
it('supports converting ARRAY[] literals keywords to lowercase', () => {
90+
expect(
91+
format(
92+
`SELECT ArrAy[1, 2] FROM aRRAY['aaa', 'bbb', 'ccc', 'ddd', 'eee', 'fff', 'ggg', 'hhh', 'iii', 'jjj'];`,
93+
{
94+
dataTypeCase: 'lower',
95+
}
96+
)
97+
).toBe(dedent`
98+
SELECT
99+
array[1, 2]
100+
FROM
101+
array[
102+
'aaa',
103+
'bbb',
104+
'ccc',
105+
'ddd',
106+
'eee',
107+
'fff',
108+
'ggg',
109+
'hhh',
110+
'iii',
111+
'jjj'
112+
];
113+
`);
114+
});
34115
}
35116

36117
if (cfg.withoutArrayPrefix) {

0 commit comments

Comments
 (0)