Skip to content

Fix selecting mixed-case objects#11889

Merged
ea-rus merged 6 commits into
releases/25.11.0from
fix-fqe-1745
Nov 21, 2025
Merged

Fix selecting mixed-case objects#11889
ea-rus merged 6 commits into
releases/25.11.0from
fix-fqe-1745

Conversation

@ea-rus
Copy link
Copy Markdown
Collaborator

@ea-rus ea-rus commented Nov 14, 2025

If database was created with quotes (it is stored in mixed case):

  • the name should be matched when used in queries (quoted or not)

If database was create without quotes

  • can be accessed by mixed case if name is not quoted

Fixes https://linear.app/mindsdb/issue/FQE-1745/datasource-created-with-camelcase-cant-be-joined

Type of change

  • 🐛 Bug fix (non-breaking change which fixes an issue)

Verification Process

To ensure the changes are working as expected:

  • Test Location: Specify the URL or path for testing.
  • Verification Steps: Outline the steps or queries needed to validate the change. Include any data, configurations, or actions required to reproduce or see the new functionality.

Additional Media:

  • I have attached a brief loom video or screenshots showcasing the new functionality or change.

Checklist:

  • My code follows the style guidelines(PEP 8) of MindsDB.
  • I have appropriately commented on my code, especially in complex areas.
  • Necessary documentation updates are either made or tracked in issues.
  • Relevant unit and integration tests are updated or added.

 - the name should be matched (quoted or not)
for lower cases databases:
 - can be used mixed case query if it is not quoted
@ea-rus ea-rus requested a review from StpMax November 14, 2025 16:19
@entelligence-ai-pr-reviews
Copy link
Copy Markdown
Contributor

🔒 Entelligence AI Vulnerability Scanner

No security vulnerabilities found!

Your code passed our comprehensive security analysis.

📊 Files Analyzed: 2 files


@entelligence-ai-pr-reviews
Copy link
Copy Markdown
Contributor

Review Summary

🏷️ Draft Comments (4)

Skipped posting 4 draft comments that were valid but scored below your review threshold (>=13/15). Feel free to update them here.

mindsdb/api/executor/planner/plan_join.py (1)

305-387: plan_join_tables (lines 305-387) is a large, complex function with deeply nested logic, making it difficult to maintain and optimize for performance as join logic evolves.

📊 Impact Scores:

  • Production Impact: 2/5
  • Fix Specificity: 4/5
  • Urgency Impact: 2/5
  • Total Score: 8/15

🤖 AI Agent Prompt (Copy & Paste Ready):

Refactor the `plan_join_tables` method in mindsdb/api/executor/planner/plan_join.py (lines 305-387). The function is overly large and complex, with deeply nested logic for join planning, subselect replacement, identifier resolution, and plan step construction. Break it into smaller, well-named helper methods for each major logical block (e.g., subselect replacement, join sequence construction, identifier resolution, plan step assembly). This will significantly improve maintainability and make future performance optimizations easier.

mindsdb/api/executor/planner/query_planner.py (3)

81-87: integration_name = integration["name"] and integration_name = integration do not normalize case, causing mismatches in downstream lookups and database matching logic.

📊 Impact Scores:

  • Production Impact: 3/5
  • Fix Specificity: 5/5
  • Urgency Impact: 3/5
  • Total Score: 11/15

🤖 AI Agent Prompt (Copy & Paste Ready):

In mindsdb/api/executor/planner/query_planner.py, lines 81-87, the code assigns `integration_name = integration["name"]` and `integration_name = integration` without normalizing the case. This can cause mismatches in downstream lookups and database matching logic, as other parts of the code expect lowercased names. Update these assignments to use `.lower()` so that all integration names are consistently lowercased.

264-271: self.databases is a list of mixed-case names, but resolve_database_table lowercases only unquoted input, causing failures to match quoted mixed-case database names.

📊 Impact Scores:

  • Production Impact: 4/5
  • Fix Specificity: 2/5
  • Urgency Impact: 3/5
  • Total Score: 9/15

🤖 AI Agent Prompt (Copy & Paste Ready):

In mindsdb/api/executor/planner/query_planner.py, lines 264-271, the code attempts to match database names by lowercasing only unquoted input, but `self.databases` may contain mixed-case names (e.g., quoted databases). This causes failures to match quoted mixed-case database names. Update the logic to compare lowercased values for unquoted input against lowercased database names, but preserve the original case for quoted names, and select the correct entry from `self.databases`.

291-309: The get_query_info method (lines 283-325) repeatedly calls self.resolve_database_table(node) inside a traversal, which can be expensive for large/complex queries due to repeated lookups and string operations.

📊 Impact Scores:

  • Production Impact: 2/5
  • Fix Specificity: 3/5
  • Urgency Impact: 2/5
  • Total Score: 7/15

🤖 AI Agent Prompt (Copy & Paste Ready):

Optimize performance in mindsdb/api/executor/planner/query_planner.py lines 291-309: The `find_objects` function inside `get_query_info` repeatedly calls `self.resolve_database_table(node)` for each node, which is expensive for large queries. Refactor to cache the result on the node (e.g., as `_resolved_integration`) to avoid redundant computation during traversal. Update the code so that each node's integration is resolved only once.


if part in self.databases:
database = part
parts.pop(0)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will be good also pop node.is_quoted, to keep node consistent

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, added

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, parts is copy of node.parts, we can't change node.is_quoted
rolled it back

@ea-rus ea-rus merged commit bd64ea9 into releases/25.11.0 Nov 21, 2025
34 of 36 checks passed
@ea-rus ea-rus deleted the fix-fqe-1745 branch November 21, 2025 11:46
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 21, 2025
@ea-rus ea-rus changed the title Fix select for mixed cases for mixed case databases: Fix selecting mixed-case objects Dec 2, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants