Bun implements sync function for sql.options.pass[word]

This commit is contained in:
Alistair Smith
2025-07-07 13:43:10 -07:00
parent 39c82c2add
commit dca9d767b6
4 changed files with 16 additions and 7 deletions

View File

@@ -1384,14 +1384,14 @@ declare module "bun" {
* Database password for authentication
* @default ""
*/
password?: string | (() => Promise<string>) | undefined;
password?: string | (() => MaybePromise<string>) | undefined;
/**
* Database password for authentication (alias for password)
* @deprecated Prefer {@link password}
* @default ""
*/
pass?: string | (() => Promise<string>) | undefined;
pass?: string | (() => MaybePromise<string>) | undefined;
/**
* Name of the database to connect to

View File

@@ -14,16 +14,16 @@ declare module "bun" {
): void;
}
/** @deprecated Use {@link SQL.Query} */
/** @deprecated Use {@link SQL.Query Bun.SQL.Query} */
type SQLQuery<T = any> = SQL.Query<T>;
/** @deprecated Use {@link SQL.TransactionContextCallback} */
/** @deprecated Use {@link SQL.TransactionContextCallback Bun.SQL.TransactionContextCallback} */
type SQLTransactionContextCallback<T> = SQL.TransactionContextCallback<T>;
/** @deprecated Use {@link SQL.SavepointContextCallback} */
/** @deprecated Use {@link SQL.SavepointContextCallback Bun.SQL.SavepointContextCallback} */
type SQLSavepointContextCallback<T> = SQL.SavepointContextCallback<T>;
/** @deprecated Use {@link SQL.Options} */
/** @deprecated Use {@link SQL.Options Bun.SQL.Options} */
type SQLOptions = SQL.Options;
/**

View File

@@ -1339,7 +1339,7 @@ function decodeIfValid(value) {
}
return null;
}
function loadOptions(o) {
function loadOptions(o: Bun.SQL.Options) {
var hostname,
port,
username,

View File

@@ -200,6 +200,15 @@ expectType(await queryNum.execute()).is<number>();
expectType(await queryNum.raw()).is<number>();
expectType(await queryNum.values()).is<number>();
expectType<Bun.SQL.Options>({
password: () => "hey",
pass: async () => "hey",
});
expectType<Bun.SQL.Options>({
password: "hey",
});
expectType(sql({ name: "Alice", email: "alice@example.com" })).is<
Bun.SQL.Helper<{
name: string;