Added support for joins#25
Conversation
There was a problem hiding this comment.
Summary of Changes
Hello @liuzicheng1987, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
This pull request introduces comprehensive support for SQL JOIN operations within the sqlgen C++ library. It enables users to construct type-safe and composable queries involving INNER JOIN, LEFT JOIN, RIGHT JOIN, and FULL JOIN, including the ability to chain multiple joins and perform joins on subqueries.
Highlights
- Core Join Functionality: Added
inner_join,left_join,right_join, andfull_joinoperations to thesqlgenAPI, allowing users to express various SQL join types directly in C++. - Subquery Joins: Implemented the capability to join tables with subqueries, significantly enhancing the flexibility and power of query construction.
- Aliasing System Enhancement: Extended the column and table aliasing mechanism to properly handle disambiguation in multi-table and subquery join scenarios, including new
_t1to_t99literal operators for convenience. - Internal Query Representation: Updated the internal dynamic query representation (
dynamic::SelectFrom) to include join clauses and their associated metadata, such as join type, source table/subquery, and ON conditions. - SQL Generation: Modified the SQL generation logic for both PostgreSQL and SQLite to correctly translate the new internal join structures into valid SQL
JOINclauses, including proper aliasing. - Documentation: Added a dedicated
joins.mddocumentation file with detailed explanations and examples for using the new join features. - Test Coverage: Introduced a suite of new integration tests for both PostgreSQL and SQLite, covering basic joins, chained joins, nested joins, and grouped joins, ensuring the new functionality works as expected.
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.
| Feature | Command | Description |
|---|---|---|
| Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
| Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
| Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
| Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
There was a problem hiding this comment.
Code Review
This pull request introduces comprehensive support for SQL joins, a significant and well-implemented feature. The changes span documentation, the core API, SQL generation for both PostgreSQL and SQLite, and a solid suite of tests. The implementation of aliased columns and joins on subqueries is particularly well done.
My review focuses on a few areas to enhance maintainability and clarity:
- Documentation: The new
joins.mdfile has some redundant sections that could be consolidated. - Maintainability: There's a large amount of boilerplate code for table alias literals in
col.hppthat could be a maintenance burden. - Correctness/Redundancy: I've identified a couple of minor issues, including a redundant alias assignment and a potentially unreachable code branch in the SQL generation logic.
Overall, this is a great addition to the library. Addressing these points will further improve the quality of the codebase.
No description provided.