Skip to content

Use " AS " when aliasing tables#7706

Open
tempoz wants to merge 1 commit intogo-gorm:masterfrom
tempoz:fix-table-aliasing
Open

Use " AS " when aliasing tables#7706
tempoz wants to merge 1 commit intogo-gorm:masterfrom
tempoz:fix-table-aliasing

Conversation

@tempoz
Copy link

@tempoz tempoz commented Feb 11, 2026

  • Do only one thing
  • Non breaking API changes
  • Tested

What did this pull request do?

Addresses #6391

Uses " AS " instead of " " between a table and its alias.

User Case Description

As described in the related issue, #6391:

My specific use case is that I want to be able to use the table alias in clause.OnConflict.DoUpdates because the table names I'm working with are mixed case, which means I need to manually quote them to reference them directly in the expressions for those updates when I'm using postgres (and I have to use a table name or alias to disambiguate the column from the row that failed to insert, which is available as excluded), which I do not want to do.

@propel-code-bot
Copy link
Contributor

This ensures stmt.QuoteTo renders table aliases with an explicit AS, keeping alias handling predictable across SQL dialects when dealing with quoted or mixed-case identifiers.

Affected Areas

statement.go
clause/expression_test.go

This summary was automatically generated by @propel-code-bot

@tempoz
Copy link
Author

tempoz commented Feb 11, 2026

The failures in the checks seem ignorable:

  • the linter is complaining about not checking the error returned by writer.WriteString, but that matches both the behavior that was there before when we were calling writer.WriteByte as well as all other calls to writer.WriteString in the rest of the function
  • the mysql test failures seem wholly unrelated to this change.

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