Skip to content

Support JOIN ... USING #1046

Description

@maciek134

Motivation

I'd like to use shorthand joins, so instead of

INNER JOIN table ON (table.x = other.x AND table.y = other.y)

I could do

INNER JOIN table USING (x, y)

This makes for easier to read queries in logs, but is ofc just syntactic sugar (with one rarely useful feature of not duplicating the columns in SELECT *).

Proposed Solutions

Glancing at the code, looks like making JoinOn::Columns generate code should be enough (as long as the struct/field naming isn't a problem) - https://github.com/SeaQL/sea-query/blob/master/src/backend/query_builder.rs#L1012
With a new SelectStatement method like .join_using.

Additional Information

Postgres, MySQL and SQLite all support this. MS SQL doesn't, but afaik that's not in the scope of this repo.

Metadata

Metadata

Assignees

No one assigned
    No fields configured for Feature.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions