Skip to content

Commit a9a6643

Browse files
feat: add CreateStmt, CreatePolicyStmt, and DropStmt transformation methods
Co-Authored-By: Dan Lynch <[email protected]>
1 parent 3d6b9fa commit a9a6643

File tree

1 file changed

+126
-0
lines changed

1 file changed

+126
-0
lines changed

packages/transform/src/transformers/v13-to-v14.ts

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1658,4 +1658,130 @@ export class V13ToV14Transformer {
16581658
return { StatsElem: result };
16591659
}
16601660

1661+
CreateStmt(node: any, context: TransformerContext): any {
1662+
const result: any = {};
1663+
1664+
if (node.relation !== undefined) {
1665+
result.relation = this.transform(node.relation as any, context);
1666+
}
1667+
1668+
if (node.tableElts !== undefined) {
1669+
result.tableElts = Array.isArray(node.tableElts)
1670+
? node.tableElts.map((item: any) => this.transform(item as any, context))
1671+
: this.transform(node.tableElts as any, context);
1672+
}
1673+
1674+
if (node.inhRelations !== undefined) {
1675+
result.inhRelations = Array.isArray(node.inhRelations)
1676+
? node.inhRelations.map((item: any) => this.transform(item as any, context))
1677+
: this.transform(node.inhRelations as any, context);
1678+
}
1679+
1680+
if (node.partbound !== undefined) {
1681+
result.partbound = this.transform(node.partbound as any, context);
1682+
}
1683+
1684+
if (node.partspec !== undefined) {
1685+
result.partspec = this.transform(node.partspec as any, context);
1686+
}
1687+
1688+
if (node.ofTypename !== undefined) {
1689+
result.ofTypename = this.transform(node.ofTypename as any, context);
1690+
}
1691+
1692+
if (node.constraints !== undefined) {
1693+
result.constraints = Array.isArray(node.constraints)
1694+
? node.constraints.map((item: any) => this.transform(item as any, context))
1695+
: this.transform(node.constraints as any, context);
1696+
}
1697+
1698+
if (node.options !== undefined) {
1699+
result.options = Array.isArray(node.options)
1700+
? node.options.map((item: any) => this.transform(item as any, context))
1701+
: this.transform(node.options as any, context);
1702+
}
1703+
1704+
if (node.oncommit !== undefined) {
1705+
result.oncommit = node.oncommit;
1706+
}
1707+
1708+
if (node.tablespacename !== undefined) {
1709+
result.tablespacename = node.tablespacename;
1710+
}
1711+
1712+
if (node.accessMethod !== undefined) {
1713+
result.accessMethod = node.accessMethod;
1714+
}
1715+
1716+
if (node.if_not_exists !== undefined) {
1717+
result.if_not_exists = node.if_not_exists;
1718+
}
1719+
1720+
return { CreateStmt: result };
1721+
}
1722+
1723+
CreatePolicyStmt(node: any, context: TransformerContext): any {
1724+
const result: any = {};
1725+
1726+
if (node.policy_name !== undefined) {
1727+
result.policy_name = node.policy_name;
1728+
}
1729+
1730+
if (node.table !== undefined) {
1731+
result.table = this.transform(node.table as any, context);
1732+
}
1733+
1734+
if (node.cmd_name !== undefined) {
1735+
result.cmd_name = node.cmd_name;
1736+
}
1737+
1738+
if (node.permissive !== undefined) {
1739+
result.permissive = node.permissive;
1740+
}
1741+
1742+
if (node.roles !== undefined) {
1743+
result.roles = Array.isArray(node.roles)
1744+
? node.roles.map((item: any) => this.transform(item as any, context))
1745+
: this.transform(node.roles as any, context);
1746+
}
1747+
1748+
if (node.qual !== undefined) {
1749+
result.qual = this.transform(node.qual as any, context);
1750+
}
1751+
1752+
if (node.with_check !== undefined) {
1753+
result.with_check = this.transform(node.with_check as any, context);
1754+
}
1755+
1756+
return { CreatePolicyStmt: result };
1757+
}
1758+
1759+
DropStmt(node: any, context: TransformerContext): any {
1760+
const result: any = {};
1761+
1762+
if (node.objects !== undefined) {
1763+
result.objects = Array.isArray(node.objects)
1764+
? node.objects.map((item: any) => this.transform(item as any, context))
1765+
: this.transform(node.objects as any, context);
1766+
}
1767+
1768+
if (node.removeType !== undefined) {
1769+
result.removeType = node.removeType;
1770+
}
1771+
1772+
if (node.behavior !== undefined) {
1773+
result.behavior = node.behavior;
1774+
}
1775+
1776+
if (node.missing_ok !== undefined) {
1777+
result.missing_ok = node.missing_ok;
1778+
}
1779+
1780+
if (node.concurrent !== undefined) {
1781+
result.concurrent = node.concurrent;
1782+
}
1783+
1784+
return { DropStmt: result };
1785+
}
1786+
16611787
}

0 commit comments

Comments
 (0)