Skip to content

Commit

Permalink
DB2 does not allow ALTER TABLE RENAME COLUMN
Browse files Browse the repository at this point in the history
  • Loading branch information
chrjorgensen committed Nov 11, 2023
1 parent 434d2f8 commit 8913263
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 7 deletions.
1 change: 0 additions & 1 deletion src/languages/db2i/db2i.formatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ const onelineClauses = expandPhrases([
'ADD [COLUMN]',
'ALTER [COLUMN]',
'DROP [COLUMN]',
'RENAME [COLUMN]',
'SET DATA TYPE', // for alter column
'SET {GENERATED ALWAYS | GENERATED BY DEFAULT}', // for alter column
'SET NOT NULL', // for alter column
Expand Down
6 changes: 0 additions & 6 deletions test/behavesLikeDb2Formatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import dedent from 'dedent-js';
import { FormatFn } from '../src/sqlFormatter.js';
import behavesLikeSqlFormatter from './behavesLikeSqlFormatter.js';

import supportsAlterTable from './features/alterTable.js';
import supportsBetween from './features/between.js';
import supportsSchema from './features/schema.js';
import supportsStrings from './features/strings.js';
Expand All @@ -29,11 +28,6 @@ export default function behavesLikeDb2Formatter(format: FormatFn) {
supportsCommentOn(format);
supportsCreateView(format, { orReplace: true });
supportsConstraints(format, ['NO ACTION', 'RESTRICT', 'CASCADE', 'SET NULL']);
supportsAlterTable(format, {
addColumn: true,
dropColumn: true,
renameColumn: true,
});
supportsDeleteFrom(format);
supportsInsertInto(format);
supportsUpdate(format, { whereCurrentOf: true });
Expand Down
6 changes: 6 additions & 0 deletions test/db2.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { format as originalFormat, FormatFn } from '../src/sqlFormatter.js';
import behavesLikeDb2Formatter from './behavesLikeDb2Formatter.js';

import supportsCreateTable from './features/createTable.js';
import supportsAlterTable from './features/alterTable.js';
import supportsDropTable from './features/dropTable.js';
import supportsJoin from './features/join.js';
import supportsParams from './options/param.js';
Expand All @@ -19,6 +20,11 @@ describe('Db2Formatter', () => {

supportsComments(format);
supportsCreateTable(format);
supportsAlterTable(format, {
addColumn: true,
dropColumn: true,
renameColumn: true,
});
supportsDropTable(format);
supportsJoin(format, { without: ['NATURAL'] });
supportsParams(format, { positional: true, named: [':'] });
Expand Down
6 changes: 6 additions & 0 deletions test/db2i.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import behavesLikeDb2Formatter from './behavesLikeDb2Formatter.js';
import supportsComments from './features/comments.js';

import supportsCreateTable from './features/createTable.js';
import supportsAlterTable from './features/alterTable.js';
import supportsDropTable from './features/dropTable.js';
import supportsJoin from './features/join.js';
import supportsOperators from './features/operators.js';
Expand All @@ -16,6 +17,11 @@ describe('Db2iFormatter', () => {

supportsComments(format, { nestedBlockComments: true });
supportsCreateTable(format, { orReplace: true });
supportsAlterTable(format, {
addColumn: true,
dropColumn: true,
renameColumn: false,
});
supportsDropTable(format, { ifExists: true });
supportsJoin(format, {
without: ['NATURAL'],
Expand Down

0 comments on commit 8913263

Please sign in to comment.