Skip to content

Commit de5bc86

Browse files
committed
pg and postgress driver should throw on unsupported execlastid command
1 parent d45400d commit de5bc86

File tree

3 files changed

+24
-4
lines changed

3 files changed

+24
-4
lines changed

src/app.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,10 @@ function createNodeGenerator(driver?: string): Driver {
8484
return mysql2;
8585
}
8686
case "pg": {
87-
return pg as any;
87+
return pg;
8888
}
8989
case "postgres": {
90-
return postgres as any;
90+
return postgres;
9191
}
9292
case "better-sqlite3": {
9393
return betterSQLite3;

src/drivers/pg.ts

Lines changed: 11 additions & 1 deletion
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

Lines changed: 11 additions & 1 deletion
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";
@@ -602,10 +602,20 @@ export function oneDecl(
602602
);
603603
}
604604

605+
export function execlastidDecl(
606+
funcName: string,
607+
queryName: string,
608+
argIface: string | undefined,
609+
params: Parameter[]
610+
): FunctionDeclaration {
611+
throw new Error('postgres driver does not support :execlastid')
612+
}
613+
605614
export default {
606615
columnType,
607616
preamble,
608617
execDecl,
609618
manyDecl,
610619
oneDecl,
620+
execlastidDecl
611621
};

0 commit comments

Comments
 (0)