kysely-org / kysely

A type-safe typescript SQL query builder
https://kysely.dev
MIT License
9.81k stars 249 forks source link

Enhance flexibility of `createPool()` in `MysqlDialectConfig` #1051

Closed rentalhost closed 1 week ago

rentalhost commented 1 week ago

Hello!

I noticed that the following code can be made more flexible, as it is not necessary to use async, given that createPool() is not:

https://github.com/kysely-org/kysely/blob/e71bbc4fd796c3e6de1eb5991740ff649d1a992f/src/dialect/mysql/mysql-dialect-config.ts#L16

However, to avoid breaking changes, I believe it's sufficient to extend the support:

pool: MysqlPool | (() => MysqlPool) | (() => Promise<MysqlPool>);

This prevents errors like the following:

error image 1

error image 2

Thank you!