Skip to content

Added support for joins#25

Merged
liuzicheng1987 merged 11 commits intomainfrom
f/joins
Jul 15, 2025
Merged

Added support for joins#25
liuzicheng1987 merged 11 commits intomainfrom
f/joins

Conversation

@liuzicheng1987
Copy link
Copy Markdown
Collaborator

No description provided.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

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, and full_join operations to the sqlgen API, 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 _t1 to _t99 literal 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 JOIN clauses, including proper aliasing.
  • Documentation: Added a dedicated joins.md documentation 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

  1. 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.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

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.md file has some redundant sections that could be consolidated.
  • Maintainability: There's a large amount of boilerplate code for table alias literals in col.hpp that 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.

Comment thread include/sqlgen/col.hpp
Comment thread tests/postgres/test_select_from_with_timestamps.cpp
Comment thread tests/sqlite/test_select_from_with_timestamps.cpp
Comment thread docs/README.md
Comment thread include/sqlgen/select_from.hpp
Comment thread src/sqlgen/postgres/to_sql.cpp
Comment thread src/sqlgen/sqlite/to_sql.cpp
@liuzicheng1987 liuzicheng1987 merged commit b283ccf into main Jul 15, 2025
16 checks passed
@liuzicheng1987 liuzicheng1987 deleted the f/joins branch August 21, 2025 19:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant