Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix db2 options #661

Merged
merged 1 commit into from
Nov 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI: In general instead of specifying false here, better to just skip the option altogether. At least that's the style that the rest of the tests are following for now. Keeps the tests shorter, as like supportsAlterTable() takes an entire 5 boolean flags.

This concrete case I already cleaned up: 91e4be0

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noted - only did it this way to clarify that it was on purpose in contrast to the DB2, which has true in renameColumn.

});
supportsDropTable(format, { ifExists: true });
supportsJoin(format, {
without: ['NATURAL'],
Expand Down
Loading