Skip to content

Implement SELECT INTO for Postgres#1021

Merged
Huliiiiii merged 4 commits intoSeaQL:masterfrom
jonasrichard:select-into-clause
Jan 26, 2026
Merged

Implement SELECT INTO for Postgres#1021
Huliiiiii merged 4 commits intoSeaQL:masterfrom
jonasrichard:select-into-clause

Conversation

@jonasrichard
Copy link
Copy Markdown
Contributor

PR Info

New Features

  • Introduce a fn into_target() on SelectStatement in order to specify the SELECT INTO clause for Postgresql
  • Also introduce a struct and an enum with which one can specify the target table and the table modifier.

Changes

  • Postgres query builder emits the SELECT INTO clause but other backends just go over and don't append anything to the generated query.

Check the naming please.

/// r#"SELECT "character" INTO UNLOGGED TABLE "character_copy" FROM "character""#
/// );
/// ```
pub fn into_target(&mut self, into_table: SelectInto) -> &mut Self {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why name it into_target instead of into_table? This type of statement is only used to create new tables.

Copy link
Copy Markdown
Member

@Huliiiiii Huliiiiii Dec 9, 2025

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I see that there are other INTOs:

  • in MySQL it is coming after FROM and it puts the values into variables
  • in PL/PgSQL the into is before the FROM and it puts values into variables (but this is not what we want here)
  • in SQLite I haven't seen any INTO

So I think into_table is a good name. I added at first into() then I though it might interfere with Into trait if once it needs to be implemented. So I wanted to change to something else, watching the Postgres spec too long the target word hooked in, so I chose into_target but into_table describes better the intent what an API should do otherwise.

@Huliiiiii Huliiiiii requested review from Expurple and tyt2y3 December 15, 2025 10:57
@jonasrichard
Copy link
Copy Markdown
Contributor Author

How are we with this? @Huliiiiii you asked a review which never happened.

@Huliiiiii Huliiiiii merged commit af866a9 into SeaQL:master Jan 26, 2026
9 checks passed
@github-actions
Copy link
Copy Markdown

github-actions bot commented Feb 8, 2026

🎉 Released In 1.0.0-rc.31 🎉

Thank you everyone for the contribution!
This feature is now available in the latest release. Now is a good time to upgrade!
Your participation is what makes us unique; your adoption is what drives us forward.
You can support SeaQL 🌊 by starring our repos, sharing our libraries and becoming a sponsor ⭐.

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.

Support SELECT ... INTO

3 participants