-
-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Version upgrades, add type aliases (#377)
* Version upgrades, add type aliases * alter enum support
- Loading branch information
Showing
17 changed files
with
1,091 additions
and
924 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { | ||
_ISchema, | ||
_Transaction, | ||
_IStatementExecutor, | ||
_IStatement, | ||
} from '../../interfaces-private'; | ||
import {AlterEnumType, AlterSequenceStatement} from '@secam/pgsql-ast-parser'; | ||
import { ExecHelper } from '../exec-utils'; | ||
import { ignore } from '../../utils'; | ||
import {asEnum, CustomEnumType} from "../../datatypes/t-custom-enum"; | ||
|
||
export class AlterEnum extends ExecHelper implements _IStatementExecutor { | ||
private onSchema: _ISchema; | ||
private originalEnum: CustomEnumType; | ||
constructor({ schema }: _IStatement, private p: AlterEnumType) { | ||
super(p); | ||
this.onSchema = schema.getThisOrSiblingFor(p.name); | ||
this.originalEnum = asEnum(schema.getObject(p.name)) | ||
if (!this.onSchema) { | ||
ignore(this.p) | ||
} | ||
} | ||
|
||
execute(t: _Transaction) { | ||
// commit pending data before making changes | ||
// (because the index sequence creation does support further rollbacks) | ||
t = t.fullCommit(); | ||
const enumValues = this.originalEnum.values | ||
|
||
switch (this.p.change.type) { | ||
case 'add value': | ||
enumValues.push(this.p.change.add.value) | ||
break; | ||
case 'rename': | ||
this.originalEnum.drop(t) | ||
this.onSchema.registerEnum(this.p.change.to.name, enumValues) | ||
break; | ||
} | ||
|
||
// new implicit transaction | ||
t = t.fork(); | ||
|
||
return this.noData(t, 'ALTER'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.