The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
fix: read through a spaced schema qualifier when telling a table from a routine call
mateo-berric9d1b94828f6
diff --git a/tests/code_coverage_tests/check_migrations_no_data_rewrites.py b/tests/code_coverage_tests/check_migrations_no_data_rewrites.pyindex adaabcae079..b0de13675df 100644--- a/tests/code_coverage_tests/check_migrations_no_data_rewrites.py+++ b/tests/code_coverage_tests/check_migrations_no_data_rewrites.py@@ -585,20 +585,21 @@ def names_a_relation(before: str) -> bool:but also a join condition that may itself be a call, so it counts only inside a statementthat creates an index, leaving `JOIN ... ON f()` and an index predicate's `WHERE f()` ascalls. A bare schema qualifier is read through: `INSERT INTO public."Foo"` parks the table's- introducing word a hop back behind `public.`, so a dot touching the word before the name means- that word is the qualifier and the one before it decides. A quoted schema blanks to spaces and- leaves the introducing word already adjacent, so only a dot with no space counts, and a genuine- `SELECT public."f"()` still reaches its `SELECT` and reads as a call."""+ introducing word a hop back behind `public.`, so any word ahead of the name that a dot follows,+ touching or spaced as `public . "Foo"`, is the qualifier and the one before it decides. The+ introducing word is settled before that, so a quoted schema, which blanks to spaces and leaves+ `INTO` itself as the word ahead of the name however the dot is spaced, still reads as a relation,+ while a genuine `SELECT public."f"()` reads through its qualifier to the `SELECT` and stays a call."""word = PRECEDING_WORD.search(before)if word is None:return False- if before[word.end(1) : word.end(1) + 1] == ".":- return names_a_relation(before[: word.start(1)])keyword = word.group(1).upper()if keyword in INTRODUCES_A_RELATION:return Trueif keyword == "ON":return NAMES_AN_INDEX.search(before[before.rfind(";") + 1 :]) is not None+ if "." in before[word.end(1) :]:+ return names_a_relation(before[: word.start(1)])return Falsediff --git a/tests/test_litellm/test_check_migrations_no_data_rewrites.py b/tests/test_litellm/test_check_migrations_no_data_rewrites.pyindex 00cdfc2343c..b9b4196fd6c 100644--- a/tests/test_litellm/test_check_migrations_no_data_rewrites.py+++ b/tests/test_litellm/test_check_migrations_no_data_rewrites.py@@ -505,6 +505,22 @@ class TestStoredRoutines:sql = self.DEFINITION + 'SELECT public."backfill"();\n'assert _keywords(tmp_path, sql) == ("UPDATE",)+ def test_a_spaced_schema_qualifier_on_an_insert_is_not_a_call(self, tmp_path):+ sql = self.DEFINITION + 'INSERT INTO public . "backfill" ("id") VALUES (1);\n'+ assert _keywords(tmp_path, sql) == ()++ def test_a_spaced_schema_qualifier_on_an_index_is_not_a_call(self, tmp_path):+ sql = self.DEFINITION + 'CREATE INDEX ON public . "backfill" ("id");\n'+ assert _keywords(tmp_path, sql) == ()++ def test_a_quoted_schema_with_spaces_round_the_dot_stays_a_relation(self, tmp_path):+ sql = self.DEFINITION + 'INSERT INTO "public" . "backfill" ("id") VALUES (1);\n'+ assert _keywords(tmp_path, sql) == ()++ def test_a_spaced_schema_qualified_call_still_counts(self, tmp_path):+ sql = self.DEFINITION + 'SELECT public . "backfill" ();\n'+ assert _keywords(tmp_path, sql) == ("UPDATE",)+def test_a_trigger_wiring_the_function_up_counts_as_a_call(self, tmp_path):sql = self.DEFINITION + 'CREATE TRIGGER t AFTER INSERT ON "Foo" EXECUTE FUNCTION backfill();\n'assert _keywords(tmp_path, sql) == ("UPDATE",)