Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: support encoding for string type cast #2407

Merged
merged 1 commit into from
Jan 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions test/tsc-build/strict-checks/typeCast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,14 @@ import { access, sql } from '../promise/baseConnection.js';
const type: string = field.type;
const buffer: Buffer | null = field.buffer();
const string: string | null = field.string();
const stringWithEncoding: string | null = field.string('utf-8');
const geometry:
| { x: number; y: number }
| { x: number; y: number }[]
| null = field.geometry();

console.log(db, length, name, table, type);
console.log(buffer, string, geometry);
console.log(buffer, string, stringWithEncoding, geometry);

return next();
},
Expand Down Expand Up @@ -64,13 +65,14 @@ import { access, sql } from '../promise/baseConnection.js';
const type: string = field.type;
const buffer: Buffer | null = field.buffer();
const string: string | null = field.string();
const stringWithEncoding: string | null = field.string('utf-8');
const geometry:
| { x: number; y: number }
| { x: number; y: number }[]
| null = field.geometry();

console.log(db, length, name, table, type);
console.log(buffer, string, geometry);
console.log(buffer, string, stringWithEncoding, geometry);

return next();
},
Expand Down Expand Up @@ -101,13 +103,14 @@ import { access, sql } from '../promise/baseConnection.js';
const type: string = field.type;
const buffer: Buffer | null = field.buffer();
const string: string | null = field.string();
const stringWithEncoding: string | null = field.string('utf-8');
const geometry:
| { x: number; y: number }
| { x: number; y: number }[]
| null = field.geometry();

console.log(db, length, name, table, type);
console.log(buffer, string, geometry);
console.log(buffer, string, stringWithEncoding, geometry);

return next();
},
Expand Down Expand Up @@ -138,13 +141,14 @@ import { access, sql } from '../promise/baseConnection.js';
const type: string = field.type;
const buffer: Buffer | null = field.buffer();
const string: string | null = field.string();
const stringWithEncoding: string | null = field.string('utf-8');
const geometry:
| { x: number; y: number }
| { x: number; y: number }[]
| null = field.geometry();

console.log(db, length, name, table, type);
console.log(buffer, string, geometry);
console.log(buffer, string, stringWithEncoding, geometry);

return next();
},
Expand Down
2 changes: 1 addition & 1 deletion typings/mysql/lib/parsers/typeCast.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ type Field = Type & {
db: string;
table: string;
name: string;
string: () => string | null;
string: (encoding?: BufferEncoding | string | undefined) => string | null;
buffer: () => Buffer | null;
geometry: () => Geometry | Geometry[] | null;
};
Expand Down
Loading