Skip to content

Commit 0640128

Browse files
committed
Regenerate examples with updated codegen
1 parent 975cb7c commit 0640128

File tree

9 files changed

+231
-13
lines changed

9 files changed

+231
-13
lines changed

examples/bun-mysql2/src/db/query_sql.ts

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ export interface GetAuthorRow {
1818
bio: string | null;
1919
}
2020

21+
export type GetAuthorRowValues = [
22+
number,
23+
string,
24+
string | null
25+
];
26+
2127
export async function getAuthor(client: Client, args: GetAuthorArgs): Promise<GetAuthorRow | null> {
2228
const [rows] = await client.query<RowDataPacket[]>({
2329
sql: getAuthorQuery,
@@ -45,6 +51,12 @@ export interface ListAuthorsRow {
4551
bio: string | null;
4652
}
4753

54+
export type ListAuthorsRowValues = [
55+
number,
56+
string,
57+
string | null
58+
];
59+
4860
export async function listAuthors(client: Client): Promise<ListAuthorsRow[]> {
4961
const [rows] = await client.query<RowDataPacket[]>({
5062
sql: listAuthorsQuery,
@@ -158,6 +170,46 @@ export interface TestRow {
158170
cJson: any | null;
159171
}
160172

173+
export type TestRowValues = [
174+
Buffer | null,
175+
number | null,
176+
number | null,
177+
number | null,
178+
number | null,
179+
number | null,
180+
number | null,
181+
number | null,
182+
number | null,
183+
number,
184+
string | null,
185+
string | null,
186+
string | null,
187+
string | null,
188+
number | null,
189+
number | null,
190+
number | null,
191+
Date | null,
192+
string | null,
193+
Date | null,
194+
Date | null,
195+
number | null,
196+
string | null,
197+
string | null,
198+
string | null,
199+
string | null,
200+
Buffer | null,
201+
Buffer | null,
202+
Buffer | null,
203+
string | null,
204+
Buffer | null,
205+
string | null,
206+
Buffer | null,
207+
string | null,
208+
Buffer | null,
209+
string | null,
210+
any | null
211+
];
212+
161213
export async function test(client: Client): Promise<TestRow | null> {
162214
const [rows] = await client.query<RowDataPacket[]>({
163215
sql: testQuery,

examples/bun-pg/src/db/query_sql.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ export interface GetAuthorRow {
2020
bio: string | null;
2121
}
2222

23+
export type GetAuthorRowValues = [
24+
string,
25+
string,
26+
string | null
27+
];
28+
2329
export async function getAuthor(client: Client, args: GetAuthorArgs): Promise<GetAuthorRow | null> {
2430
const result = await client.query({
2531
text: getAuthorQuery,
@@ -47,6 +53,12 @@ export interface ListAuthorsRow {
4753
bio: string | null;
4854
}
4955

56+
export type ListAuthorsRowValues = [
57+
string,
58+
string,
59+
string | null
60+
];
61+
5062
export async function listAuthors(client: Client): Promise<ListAuthorsRow[]> {
5163
const result = await client.query({
5264
text: listAuthorsQuery,
@@ -81,6 +93,12 @@ export interface CreateAuthorRow {
8193
bio: string | null;
8294
}
8395

96+
export type CreateAuthorRowValues = [
97+
string,
98+
string,
99+
string | null
100+
];
101+
84102
export async function createAuthor(client: Client, args: CreateAuthorArgs): Promise<CreateAuthorRow | null> {
85103
const result = await client.query({
86104
text: createAuthorQuery,

examples/bun-postgres/src/db/query_sql.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ export interface GetAuthorRow {
1616
bio: string | null;
1717
}
1818

19+
export type GetAuthorRowValues = [
20+
string,
21+
string,
22+
string | null
23+
];
24+
1925
export async function getAuthor(sql: Sql, args: GetAuthorArgs): Promise<GetAuthorRow | null> {
2026
const rows = await sql.unsafe(getAuthorQuery, [args.id]).values();
2127
if (rows.length !== 1) {
@@ -42,8 +48,14 @@ export interface ListAuthorsRow {
4248
bio: string | null;
4349
}
4450

51+
export type ListAuthorsRowValues = [
52+
string,
53+
string,
54+
string | null
55+
];
56+
4557
export async function listAuthors(sql: Sql): Promise<ListAuthorsRow[]> {
46-
return (await sql.unsafe(listAuthorsQuery, []).values()).map(row => ({
58+
return (await sql.unsafe(listAuthorsQuery, []).values()).map((row: any[]) => ({
4759
id: row[0],
4860
name: row[1],
4961
bio: row[2]
@@ -69,6 +81,12 @@ export interface CreateAuthorRow {
6981
bio: string | null;
7082
}
7183

84+
export type CreateAuthorRowValues = [
85+
string,
86+
string,
87+
string | null
88+
];
89+
7290
export async function createAuthor(sql: Sql, args: CreateAuthorArgs): Promise<CreateAuthorRow | null> {
7391
const rows = await sql.unsafe(createAuthorQuery, [args.name, args.bio]).values();
7492
if (rows.length !== 1) {

examples/bun-sql/src/db/query_sql.ts

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,23 @@ SELECT id, name, bio FROM authors
77
WHERE id = $1 LIMIT 1`;
88

99
export interface GetAuthorArgs {
10-
id: string;
10+
id: number;
1111
}
1212

1313
export interface GetAuthorRow {
14-
id: string;
14+
id: number;
1515
name: string;
1616
bio: string | null;
1717
}
1818

19+
export type GetAuthorRowValues = [
20+
number,
21+
string,
22+
string | null
23+
];
24+
1925
export async function getAuthor(sql: SQL, args: GetAuthorArgs): Promise<GetAuthorRow | null> {
20-
const rows = await sql.unsafe(getAuthorQuery, [args.id]).values();
26+
const rows = await sql.unsafe(getAuthorQuery, [args.id]).values() as GetAuthorRowValues[];
2127
if (rows.length !== 1) {
2228
return null;
2329
}
@@ -26,7 +32,7 @@ export async function getAuthor(sql: SQL, args: GetAuthorArgs): Promise<GetAutho
2632
return null;
2733
}
2834
return {
29-
id: row[0],
35+
id: Number(row[0]),
3036
name: row[1],
3137
bio: row[2]
3238
};
@@ -37,14 +43,20 @@ SELECT id, name, bio FROM authors
3743
ORDER BY name`;
3844

3945
export interface ListAuthorsRow {
40-
id: string;
46+
id: number;
4147
name: string;
4248
bio: string | null;
4349
}
4450

51+
export type ListAuthorsRowValues = [
52+
number,
53+
string,
54+
string | null
55+
];
56+
4557
export async function listAuthors(sql: SQL): Promise<ListAuthorsRow[]> {
46-
return (await sql.unsafe(listAuthorsQuery, []).values()).map(row => ({
47-
id: row[0],
58+
return (await sql.unsafe(listAuthorsQuery, []).values() as ListAuthorsRowValues[]).map(row => ({
59+
id: Number(row[0]),
4860
name: row[1],
4961
bio: row[2]
5062
}));
@@ -64,13 +76,19 @@ export interface CreateAuthorArgs {
6476
}
6577

6678
export interface CreateAuthorRow {
67-
id: string;
79+
id: number;
6880
name: string;
6981
bio: string | null;
7082
}
7183

84+
export type CreateAuthorRowValues = [
85+
number,
86+
string,
87+
string | null
88+
];
89+
7290
export async function createAuthor(sql: SQL, args: CreateAuthorArgs): Promise<CreateAuthorRow | null> {
73-
const rows = await sql.unsafe(createAuthorQuery, [args.name, args.bio]).values();
91+
const rows = await sql.unsafe(createAuthorQuery, [args.name, args.bio]).values() as CreateAuthorRowValues[];
7492
if (rows.length !== 1) {
7593
return null;
7694
}
@@ -79,7 +97,7 @@ export async function createAuthor(sql: SQL, args: CreateAuthorArgs): Promise<Cr
7997
return null;
8098
}
8199
return {
82-
id: row[0],
100+
id: Number(row[0]),
83101
name: row[1],
84102
bio: row[2]
85103
};
@@ -90,7 +108,7 @@ DELETE FROM authors
90108
WHERE id = $1`;
91109

92110
export interface DeleteAuthorArgs {
93-
id: string;
111+
id: number;
94112
}
95113

96114
export async function deleteAuthor(sql: SQL, args: DeleteAuthorArgs): Promise<void> {

examples/bun-sqlite/src/db/query_sql.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ export interface GetAuthorRow {
1616
bio: string | null;
1717
}
1818

19+
export type GetAuthorRowValues = [
20+
number,
21+
string,
22+
string | null
23+
];
24+
1925
export async function getAuthor(database: Database, args: GetAuthorArgs): Promise<GetAuthorRow | null> {
2026
const stmt = database.prepare(getAuthorQuery);
2127
const rows = stmt.values(args.id);
@@ -43,6 +49,12 @@ export interface ListAuthorsRow {
4349
bio: string | null;
4450
}
4551

52+
export type ListAuthorsRowValues = [
53+
number,
54+
string,
55+
string | null
56+
];
57+
4658
export async function listAuthors(database: Database): Promise<ListAuthorsRow[]> {
4759
const stmt = database.prepare(listAuthorsQuery);
4860
const rows = stmt.values();

examples/node-better-sqlite3/src/db/query_sql.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ export interface GetAuthorRow {
1616
bio: any | null;
1717
}
1818

19+
export type GetAuthorRowValues = [
20+
any,
21+
any,
22+
any | null
23+
];
24+
1925
export async function getAuthor(database: Database, args: GetAuthorArgs): Promise<GetAuthorRow | null> {
2026
const stmt = database.prepare(getAuthorQuery);
2127
const result = await stmt.get(args.id);
@@ -35,6 +41,12 @@ export interface ListAuthorsRow {
3541
bio: any | null;
3642
}
3743

44+
export type ListAuthorsRowValues = [
45+
any,
46+
any,
47+
any | null
48+
];
49+
3850
export async function listAuthors(database: Database): Promise<ListAuthorsRow[]> {
3951
const stmt = database.prepare(listAuthorsQuery);
4052
const result = await stmt.all();

examples/node-mysql2/src/db/query_sql.ts

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ export interface GetAuthorRow {
1818
bio: string | null;
1919
}
2020

21+
export type GetAuthorRowValues = [
22+
string,
23+
string,
24+
string | null
25+
];
26+
2127
export async function getAuthor(client: Client, args: GetAuthorArgs): Promise<GetAuthorRow | null> {
2228
const [rows] = await client.query<RowDataPacket[]>({
2329
sql: getAuthorQuery,
@@ -45,6 +51,12 @@ export interface ListAuthorsRow {
4551
bio: string | null;
4652
}
4753

54+
export type ListAuthorsRowValues = [
55+
string,
56+
string,
57+
string | null
58+
];
59+
4860
export async function listAuthors(client: Client): Promise<ListAuthorsRow[]> {
4961
const [rows] = await client.query<RowDataPacket[]>({
5062
sql: listAuthorsQuery,
@@ -158,6 +170,46 @@ export interface TestRow {
158170
cJson: any | null;
159171
}
160172

173+
export type TestRowValues = [
174+
Buffer | null,
175+
number | null,
176+
number | null,
177+
number | null,
178+
number | null,
179+
number | null,
180+
number | null,
181+
number | null,
182+
string | null,
183+
string,
184+
string | null,
185+
string | null,
186+
string | null,
187+
string | null,
188+
number | null,
189+
number | null,
190+
number | null,
191+
Date | null,
192+
string | null,
193+
Date | null,
194+
Date | null,
195+
number | null,
196+
string | null,
197+
string | null,
198+
string | null,
199+
string | null,
200+
Buffer | null,
201+
Buffer | null,
202+
Buffer | null,
203+
string | null,
204+
Buffer | null,
205+
string | null,
206+
Buffer | null,
207+
string | null,
208+
Buffer | null,
209+
string | null,
210+
any | null
211+
];
212+
161213
export async function test(client: Client): Promise<TestRow | null> {
162214
const [rows] = await client.query<RowDataPacket[]>({
163215
sql: testQuery,

0 commit comments

Comments
 (0)