Skip to content

Commit

Permalink
USING clause (#99)
Browse files Browse the repository at this point in the history
  • Loading branch information
dolezel authored Jul 19, 2017
1 parent d84955e commit 4cc9e71
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ This is required for some SQL operations that cannot be run within a transaction
- `default` _[string or null]_ - null, string
- `type` _[string]_ - new datatype
- `notNull` _[boolean]_ - sets NOT NULL if true
- `using` _[string]_ - adds USING clause to change values in column

-----------------------------------------------------

Expand Down
7 changes: 6 additions & 1 deletion lib/operations/tables.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,12 @@ export const alterColumn = (table_name, column_name, options) => {
actions.push(`SET DEFAULT ${escapeValue(options.default)}`);
}
if (options.type) {
actions.push(`SET DATA TYPE ${applyTypeAdapters(options.type)}`);
const action = `SET DATA TYPE ${applyTypeAdapters(options.type)}`;
actions.push(
options.using
? `${action} USING ${options.using}`
: action
);
}
if (options.notNull) {
actions.push('SET NOT NULL');
Expand Down

0 comments on commit 4cc9e71

Please sign in to comment.