feat(completion): use all table name initials for aliases
This commit is contained in:
1 parent
eb91f08369
commit
bd3c647370
2 files changed
+25
-2
No files matched your search
@@ -114,6 +114,30 @@ describe("sqlCompletion table targets", () => {
|
||||
});
|
||||
|
||||
describe("sqlCompletion table aliases", () => {
|
||||
it("uses initials from all words for generated aliases", () => {
|
||||
const sql = "SELECT * FROM mat";
|
||||
const items = buildSqlCompletionItems(sql, sql.length, {
|
||||
tables: [{ name: "materials_order_item", type: "table" }],
|
||||
columnsByTable: new Map(),
|
||||
autoAliasTables: true,
|
||||
});
|
||||
|
||||
const table = items.find((item) => item.label === "materials_order_item" && item.type === "table");
|
||||
expect(table?.apply).toBe("materials_order_item AS moi");
|
||||
});
|
||||
|
||||
it("uses every word initial for longer multi-word names", () => {
|
||||
const sql = "SELECT * FROM sup";
|
||||
const items = buildSqlCompletionItems(sql, sql.length, {
|
||||
tables: [{ name: "super_long_customer_order_history_archive_snapshot_daily_replica", type: "table" }],
|
||||
columnsByTable: new Map(),
|
||||
autoAliasTables: true,
|
||||
});
|
||||
|
||||
const table = items.find((item) => item.label === "super_long_customer_order_history_archive_snapshot_daily_replica" && item.type === "table");
|
||||
expect(table?.apply).toBe("super_long_customer_order_history_archive_snapshot_daily_replica AS slcohasdr");
|
||||
});
|
||||
|
||||
it("applies generated aliases to table completions when enabled", () => {
|
||||
const sql = "SELECT * FROM ord";
|
||||
const items = buildSqlCompletionItems(sql, sql.length, {
|
||||
|
||||
Reference in new issue
Block a user