oven-sh / bun

Incredibly fast JavaScript runtime, bundler, test runner, and package manager – all in one
https://bun.sh
Other
73.17k stars 2.68k forks source link

sqlite count name="title" result inconsistent with others #13683

Open ruanjiayou opened 2 weeks ago

ruanjiayou commented 2 weeks ago

What version of Bun is running?

1.1.26

What platform is your computer?

Darwin 21.6.0 x86_64 i386

What steps can reproduce the bug?

the condition where name="title" always return 0, others condition works.

import { expect, test, describe } from "bun:test";

import { Database } from "bun:sqlite";

const db = new Database("data/temp.db", { create: true });
db.query(`DROP TABLE IF EXISTS apps`).run();
db.query(`CREATE TABLE IF NOT EXISTS apps(
    id INTEGER PRIMARY KEY,
    name CHAR(100),
    title CHAR(100)
  ); `).run();

describe("sqlite", () => {
  test("insert", async () => {
    const result = db.query(`INSERT INTO apps (id,name) VALUES(1, "title")`).run();
    expect(result).toStrictEqual({ changes: 1, lastInsertRowid: 1 });
  });
  test("count", async () => {
    const v = db.query(`SELECT COUNT(*) as count FROM apps WHERE name="title"`).get()
    console.log(v)
    expect(v).toStrictEqual({ count: 1 });
  });
});
企业微信截图_a391094e-9d5c-4569-9510-769499eeba84 企业微信截图_904b3fe0-b43a-4199-a6d1-1f69a65642cb

What is the expected behavior?

No response

What do you see instead?

No response

Additional information

No response

ruanjiayou commented 2 weeks ago

resolution: query with single quotes. eg, name='title'. double quotes maybe fail!