mirror of
https://github.com/oven-sh/bun
synced 2026-02-10 19:08:50 +00:00
feat(MYSQL) Bun.SQL mysql support (#21968)
### What does this PR do? Add MySQL support, Refactor will be in a followup PR ### How did you verify your code works? A lot of tests --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: cirospaciari <6379399+cirospaciari@users.noreply.github.com>
This commit is contained in:
@@ -17,14 +17,6 @@ describe("Connection & Initialization", () => {
|
||||
expect(myapp.options.adapter).toBe("sqlite");
|
||||
expect(myapp.options.filename).toBe("myapp.db");
|
||||
|
||||
const myapp2 = new SQL("myapp.db", { adapter: "sqlite" });
|
||||
expect(myapp2.options.adapter).toBe("sqlite");
|
||||
expect(myapp2.options.filename).toBe("myapp.db");
|
||||
|
||||
expect(() => new SQL("myapp.db")).toThrowErrorMatchingInlineSnapshot(
|
||||
`"Invalid URL 'myapp.db' for postgres. Did you mean to specify \`{ adapter: "sqlite" }\`?"`,
|
||||
);
|
||||
|
||||
const postgres = new SQL("postgres://user1:pass2@localhost:5432/mydb");
|
||||
expect(postgres.options.adapter).not.toBe("sqlite");
|
||||
});
|
||||
@@ -611,18 +603,6 @@ describe("Connection & Initialization", () => {
|
||||
expect(sql.options.filename).toBe(":memory:");
|
||||
sql.close();
|
||||
});
|
||||
|
||||
test("should throw for invalid URL without adapter", () => {
|
||||
expect(() => new SQL("not-a-url")).toThrowErrorMatchingInlineSnapshot(
|
||||
`"Invalid URL 'not-a-url' for postgres. Did you mean to specify \`{ adapter: "sqlite" }\`?"`,
|
||||
);
|
||||
});
|
||||
|
||||
test("should throw for postgres URL when sqlite adapter is expected", () => {
|
||||
expect(() => new SQL("myapp.db")).toThrowErrorMatchingInlineSnapshot(
|
||||
`"Invalid URL 'myapp.db' for postgres. Did you mean to specify \`{ adapter: "sqlite" }\`?"`,
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe("Mixed Configurations", () => {
|
||||
@@ -690,8 +670,8 @@ describe("Connection & Initialization", () => {
|
||||
|
||||
describe("Error Cases", () => {
|
||||
test("should throw for unsupported adapter", () => {
|
||||
expect(() => new SQL({ adapter: "mysql" as any })).toThrowErrorMatchingInlineSnapshot(
|
||||
`"Unsupported adapter: mysql. Supported adapters: "postgres", "sqlite""`,
|
||||
expect(() => new SQL({ adapter: "mssql" as any })).toThrowErrorMatchingInlineSnapshot(
|
||||
`"Unsupported adapter: mssql. Supported adapters: "postgres", "sqlite", "mysql""`,
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user