Skip to content

Commit

Permalink
Allow TYPE to be used as an identifier in Snowflake
Browse files Browse the repository at this point in the history
Fixes #771
  • Loading branch information
nene committed Aug 28, 2024
1 parent 2e637ed commit 678b3e4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/languages/snowflake/snowflake.formatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ const tabularOnelineClauses = expandPhrases([
'DROP ALL ROW ACCESS POLICIES',
'{SET | DROP} DEFAULT', // for alter column
'{SET | DROP} NOT NULL', // for alter column
'[SET DATA] TYPE', // for alter column
'SET DATA TYPE', // for alter column
'UNSET COMMENT', // for alter column
'{SET | UNSET} MASKING POLICY', // for alter column
// - truncate:
Expand Down
14 changes: 14 additions & 0 deletions test/snowflake.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,4 +190,18 @@ describe('SnowflakeFormatter', () => {
third STRING
);`);
});

// Issue #771
it('allows TYPE to be used as an identifier', () => {
expect(format(`SELECT CASE WHEN type = 'upgrade' THEN amount ELSE 0 END FROM items;`))
.toBe(dedent`
SELECT
CASE
WHEN type = 'upgrade' THEN amount
ELSE 0
END
FROM
items;
`);
});
});

0 comments on commit 678b3e4

Please sign in to comment.