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

fix(order by): for localized sorting, prepend table alias #546

Merged
merged 18 commits into from
Apr 11, 2024

Conversation

patricebender
Copy link
Member

@patricebender patricebender commented Mar 25, 2024

Usually, column references in simple names in order by clauses are left as is. That means no table alias is prepended. In expressions however, only source elements can be reffered to.

That is why in case of localized sorting, we must prepend the table alias nevertheless, as in the DB specific drivers, a COLLATE expression is wrapped around the string reference. Hence we must replace the column reference with the underlying source reference.

as reported in #543, postgres is not able to resolve a reference to a column unambigously if the reference is part of a COLLATE expression.

as reported in #543, postgres is not able to resolve
a reference to a column unambigously if the reference
is part of a `COLLATE` expression. This change adds a test
which should reveal how the other DBs behave.:
@patricebender patricebender changed the title test(scenario): order by with collation references column fix(order by): for localized sorting, prepend table alias Mar 26, 2024
@patricebender patricebender changed the title fix(order by): for localized sorting, prepend table alias fix(order by): Ambiguous column reference in COLLATE expression for localized sorting Mar 26, 2024
@patricebender patricebender linked an issue Mar 26, 2024 that may be closed by this pull request
@patricebender patricebender changed the title fix(order by): Ambiguous column reference in COLLATE expression for localized sorting fix(order by): for localized sorting, prepend table alias Mar 28, 2024
@patricebender patricebender changed the title fix(order by): for localized sorting, prepend table alias fix(order by): for localized sorting, prepend table alias Mar 28, 2024
@patricebender
Copy link
Member Author

@stewsk @BobdenOs please have a look

test/scenarios/bookshop/orderBy.test.js Outdated Show resolved Hide resolved
test/scenarios/bookshop/orderBy.test.js Show resolved Hide resolved
.gitignore Outdated Show resolved Hide resolved
@patricebender patricebender requested a review from BobdenOs April 11, 2024 09:28
.gitignore Outdated Show resolved Hide resolved
@patricebender patricebender enabled auto-merge (squash) April 11, 2024 11:26
@patricebender patricebender merged commit a273a92 into main Apr 11, 2024
4 checks passed
@patricebender patricebender deleted the patrice/collate branch April 11, 2024 13:04
patricebender added a commit that referenced this pull request Apr 11, 2024
this is a fix for #546, where those properties in some cases got lost.
johannes-vogel added a commit that referenced this pull request Apr 12, 2024
🤖 I have created a release *beep* *boop*
---


<details><summary>db-service: 1.8.0</summary>

##
[1.8.0](db-service-v1.7.0...db-service-v1.8.0)
(2024-04-12)


### Added

* Odata built-in query functions
([#558](#558))
([6e63367](6e63367))
* support HANA stored procedures
([#542](#542))
([52a00a0](52a00a0))


### Fixed

* **`expand`:** Only accept on structures, assocs or table aliases
([#551](#551))
([3248512](3248512))
* **`order by`:** for localized sorting, prepend table alias
([#546](#546))
([a273a92](a273a92))
* etag with stream_compat
([#562](#562))
([b0a3a41](b0a3a41))
* exclude `cds.LargeBinary` from wildcard expansion
([#577](#577))
([6661d63](6661d63))
* Reduce insert queries for deep update
([#568](#568))
([55e5114](55e5114))
* Reduced count query complexity when possible
([#553](#553))
([3331f02](3331f02))
</details>

<details><summary>postgres: 1.7.0</summary>

##
[1.7.0](postgres-v1.6.0...postgres-v1.7.0)
(2024-04-12)


### Added

* Odata built-in query functions
([#558](#558))
([6e63367](6e63367))
</details>

<details><summary>hana: 0.2.0</summary>

##
[0.2.0](hana-v0.1.0...hana-v0.2.0)
(2024-04-12)


### Added

* Odata built-in query functions
([#558](#558))
([6e63367](6e63367))
* support HANA stored procedures
([#542](#542))
([52a00a0](52a00a0))
</details>

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: Johannes Vogel <31311694+johannes-vogel@users.noreply.github.com>
@cap-bots cap-bots mentioned this pull request Jul 18, 2024
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.

@cap-js/postgres: column reference is ambiguous
2 participants