mirror of
https://github.com/beekeeper-studio/beekeeper-studio.git
synced 2026-03-13 10:12:54 +08:00
33 lines
1.5 KiB
TypeScript
33 lines
1.5 KiB
TypeScript
import { removeQueryQuotes } from "../../lib/utils/sql";
|
|
|
|
const unquoteTestCases = {
|
|
"SELECT * FROM foo;": `SELECT * FROM foo;`,
|
|
"\"SELECT * FROM foo;\"": `SELECT * FROM foo;`,
|
|
"\"this is not a query\"": `"this is not a query"`,
|
|
"'this is not a query'": `'this is not a query'`,
|
|
"`this is not a query`": '`this is not a query`',
|
|
"\"select foo, bar from baz where bar like '%;';\"": `select foo, bar from baz where bar like '%;';`,
|
|
"'select foo, bar from baz where bar like '%;';'": `select foo, bar from baz where bar like '%;';`,
|
|
"`select foo, bar from baz where bar like '%;';`": `select foo, bar from baz where bar like '%;';`,
|
|
"\n\n\"SELECT * FROM foo;\"": `SELECT * FROM foo;`,
|
|
"\n\n'SELECT * FROM foo;'": `SELECT * FROM foo;`,
|
|
"\n\n`SELECT * FROM foo;`": `SELECT * FROM foo;`,
|
|
"\"SELECT * FROM foo;\"\n\n\n ": `SELECT * FROM foo;`,
|
|
"'SELECT * FROM foo;'\n\n\n ": `SELECT * FROM foo;`,
|
|
"`SELECT * FROM foo;`\n\n\n ": `SELECT * FROM foo;`,
|
|
"\n\n\n\n\"SELECT * FROM bar;\"\n\n\n\n ": `SELECT * FROM bar;`,
|
|
"\n\n\n\n'SELECT * FROM bar;'\n\n\n\n ": `SELECT * FROM bar;`,
|
|
"\n\n\n\n`SELECT * FROM bar;`\n\n\n\n ": `SELECT * FROM bar;`,
|
|
}
|
|
|
|
describe("Query Unquoter", () => {
|
|
it("should unquote queries that are quoted, and leave the others", () => {
|
|
Object.keys(unquoteTestCases).forEach(possibleQuery => {
|
|
const expected = unquoteTestCases[possibleQuery];
|
|
const result = removeQueryQuotes(possibleQuery, "generic");
|
|
expect(result).toBe(expected);
|
|
})
|
|
})
|
|
})
|
|
|