parent
bc60339806
commit
4aa36cb893
|
|
@ -1095,6 +1095,15 @@ describe("buildExecutionCandidates", () => {
|
|||
expect(candidates[0].sql).toBe(hintedSql);
|
||||
});
|
||||
|
||||
it("preserves leading tenant routing hints in current statement candidates", () => {
|
||||
const hintedSql = "/*@global:true*/\nSELECT * FROM tenant_table";
|
||||
const sql = `SELECT 1;\n${hintedSql};`;
|
||||
const candidates = buildExecutionCandidates(sql, indexOf(sql, "tenant_table"), "mysql");
|
||||
|
||||
expect(candidates[0].sql).toBe(hintedSql);
|
||||
expect(splitSqlStatementRanges("/*@global:true*/", "mysql")).toEqual([]);
|
||||
});
|
||||
|
||||
it("uses the cursor statement for the first candidate when there is no selection", () => {
|
||||
const sql = "SELECT *\nFROM users\nWHERE active = 1";
|
||||
const candidates = buildExecutionCandidates(sql, indexOf(sql, "users"));
|
||||
|
|
|
|||
|
|
@ -444,7 +444,8 @@ export function splitSqlStatementRanges(sql: string, databaseType?: DatabaseType
|
|||
}
|
||||
// Block comments consume until the closing */.
|
||||
if (ch === "/" && next === "*") {
|
||||
if (statementStart === -1 && pendingHintStart === -1 && sql[i + 2] === "+") pendingHintStart = i;
|
||||
const hintMarker = sql[i + 2];
|
||||
if (statementStart === -1 && pendingHintStart === -1 && (hintMarker === "+" || hintMarker === "@")) pendingHintStart = i;
|
||||
const close = sql.indexOf("*/", i + 2);
|
||||
i = close === -1 ? len : close + 2;
|
||||
continue;
|
||||
|
|
|
|||
Loading…
Reference in New Issue