Skip to content

Commit 88ec87c

Browse files
committed
stash for fixup
1 parent bb2d3cc commit 88ec87c

File tree

1 file changed

+28
-18
lines changed

1 file changed

+28
-18
lines changed

test/options/identifierCase.ts

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,14 @@ import { FormatFn } from '../../src/sqlFormatter.js';
44

55
export default function supportsIdentifierCase(format: FormatFn) {
66
it('preserves identifier case by default', () => {
7-
const result = format('select Abc from tBl1 left join Tbl2 where colA > 1 and colB = 3');
7+
const result = format(
8+
dedent`
9+
select Abc, 'mytext' as MyText from tBl1 left join Tbl2 where colA > 1 and colB = 3`
10+
);
811
expect(result).toBe(dedent`
912
select
10-
Abc
13+
Abc,
14+
'mytext' as MyText
1115
from
1216
tBl1
1317
left join Tbl2
@@ -18,12 +22,15 @@ export default function supportsIdentifierCase(format: FormatFn) {
1822
});
1923

2024
it('converts identifiers to uppercase', () => {
21-
const result = format('select Abc from tBl1 left join Tbl2 where colA > 1 and colB = 3', {
22-
identifierCase: 'upper',
23-
});
25+
const result = format(
26+
dedent`
27+
select Abc, 'mytext' as MyText from tBl1 left join Tbl2 where colA > 1 and colB = 3`,
28+
{ identifierCase: 'upper' }
29+
);
2430
expect(result).toBe(dedent`
2531
select
26-
ABC
32+
ABC,
33+
'mytext' as MYTEXT
2734
from
2835
TBL1
2936
left join TBL2
@@ -34,12 +41,15 @@ export default function supportsIdentifierCase(format: FormatFn) {
3441
});
3542

3643
it('converts identifiers to lowercase', () => {
37-
const result = format('select Abc from tBl1 left join Tbl2 where colA > 1 and colB = 3', {
38-
identifierCase: 'lower',
39-
});
44+
const result = format(
45+
dedent`
46+
select Abc, 'mytext' as MyText from tBl1 left join Tbl2 where colA > 1 and colB = 3`,
47+
{ identifierCase: 'lower' }
48+
);
4049
expect(result).toBe(dedent`
4150
select
42-
abc
51+
abc,
52+
'mytext' as mytext
4353
from
4454
tbl1
4555
left join tbl2
@@ -49,23 +59,23 @@ export default function supportsIdentifierCase(format: FormatFn) {
4959
`);
5060
});
5161

52-
it('does not uppercase identifiers inside strings', () => {
53-
const result = format(`select 'abc' as foo`, {
62+
it('does not uppercase quoted identifiers', () => {
63+
const result = format(`select "abc" as foo`, {
5464
identifierCase: 'upper',
5565
});
5666
expect(result).toBe(dedent`
5767
select
58-
'abc' as FOO
68+
"abc" as FOO
5969
`);
6070
});
6171

62-
it('does not uppercase identifiers inside quotes', () => {
63-
const result = format(`select "abc" as foo`, {
64-
identifierCase: 'upper',
65-
});
72+
it('converts multi-part identifiers to uppercase', () => {
73+
const result = format('select Abc from Part1.Part2.Part3', { identifierCase: 'upper' });
6674
expect(result).toBe(dedent`
6775
select
68-
"abc" as FOO
76+
ABC
77+
from
78+
PART1.PART2.PART3
6979
`);
7080
});
7181
}

0 commit comments

Comments
 (0)