Skip to content

Commit 2398fb0

Browse files
committed
pg and postgress driver should throw on unsupported execlastid command
1 parent 456b2a5 commit 2398fb0

File tree

3 files changed

+24
-4
lines changed

3 files changed

+24
-4
lines changed

src/app.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,10 @@ function createNodeGenerator(driver?: string): Driver {
8383
return mysql2;
8484
}
8585
case "pg": {
86-
return pg as any;
86+
return pg;
8787
}
8888
case "postgres": {
89-
return postgres as any;
89+
return postgres;
9090
}
9191
}
9292
throw new Error(`unknown driver: ${driver}`);

src/drivers/pg.ts

+11-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { SyntaxKind, NodeFlags, Node, TypeNode, factory } from "typescript";
1+
import { SyntaxKind, NodeFlags, Node, TypeNode, factory, FunctionDeclaration } from "typescript";
22

33
import { Parameter, Column, Query } from "../gen/plugin/codegen_pb";
44
import { argName, colName } from "./utlis";
@@ -778,10 +778,20 @@ export function manyDecl(
778778
);
779779
}
780780

781+
export function execlastidDecl(
782+
funcName: string,
783+
queryName: string,
784+
argIface: string | undefined,
785+
params: Parameter[]
786+
): FunctionDeclaration {
787+
throw new Error('pg driver does not support :execlastid')
788+
}
789+
781790
export default {
782791
columnType,
783792
execDecl,
784793
manyDecl,
785794
oneDecl,
786795
preamble,
796+
execlastidDecl,
787797
};

src/drivers/postgres.ts

+11-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { SyntaxKind, NodeFlags, TypeNode, factory } from "typescript";
1+
import { SyntaxKind, NodeFlags, TypeNode, factory, FunctionDeclaration } from "typescript";
22

33
import { Parameter, Column } from "../gen/plugin/codegen_pb";
44
import { argName, colName } from "./utlis";
@@ -577,10 +577,20 @@ export function oneDecl(
577577
);
578578
}
579579

580+
export function execlastidDecl(
581+
funcName: string,
582+
queryName: string,
583+
argIface: string | undefined,
584+
params: Parameter[]
585+
): FunctionDeclaration {
586+
throw new Error('postgres driver does not support :execlastid')
587+
}
588+
580589
export default {
581590
columnType,
582591
preamble,
583592
execDecl,
584593
manyDecl,
585594
oneDecl,
595+
execlastidDecl
586596
};

0 commit comments

Comments
 (0)