Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for PostgreSQL Insert table aliases (#1069) #1084

Merged
merged 1 commit into from
Jan 14, 2024

Conversation

boydjohnson
Copy link
Contributor

This is a fix for #1069

@coveralls
Copy link

coveralls commented Jan 6, 2024

Pull Request Test Coverage Report for Build 7513619314

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.05%) to 87.858%

Totals Coverage Status
Change from base Build 7396929961: 0.05%
Covered Lines: 18828
Relevant Lines: 21430

💛 - Coveralls

Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

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

Thank you for this contribution @boydjohnson - this is looking close.

src/ast/mod.rs Outdated
Comment on lines 2417 to 2422
let table_name = if let Some(Ident {
value,
quote_style: _,
}) = table_alias
{
format!("{table_name} AS {value}")
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems like we should format the alias using whatever quote style was originally used

Maybe something like

Suggested change
let table_name = if let Some(Ident {
value,
quote_style: _,
}) = table_alias
{
format!("{table_name} AS {value}")
let table_name = if let Some(table_alias) = table_alias
{
format!("{table_name} AS {table_alias}")

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, I followed your advice. I rebased and force-pushed. I hope that is ok.


pg().verified_stmt(sql1);

let sql2 = "INSERT INTO test_tables AS test_table (id, a) VALUES (DEFAULT, 123)";
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you please:

  1. Make the sql2 a second test (e.g. test_simple_postgres_insert_with_alias)
  2. Add a test for a quoted identifier, something like INSERT INTO test_tables AS "Test_Table" (id, a) VALUES (DEFAULT, 123), perhaps

Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

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

Thank you @boydjohnson

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.

3 participants