-
Notifications
You must be signed in to change notification settings - Fork 202
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 many-to-one (and one-to-one) join #3337
base: 4.12.x
Are you sure you want to change the base?
Conversation
@@ -92,7 +92,7 @@ class CriteriaSpec extends AbstractCriteriaSpec { | |||
String query = getSqlQuery(criteriaQuery) | |||
|
|||
expect: | |||
query == '''SELECT book_."id",book_."author_id",book_."title",book_."total_pages",book_."last_updated" FROM "book" book_ WHERE (book_."id" IN (SELECT book_book_."id" FROM "book" book_book_ WHERE (book_book_."id" = 123)))''' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does not return field from the association if not requested by join for retrieval
@@ -524,7 +524,7 @@ interface BookRepository extends GenericRepository<Book, Long> { | |||
when: | |||
def updateReturningCustomMethod = repository.findPossibleMethods("updateReturning").findFirst().get() | |||
then: | |||
getQuery(updateReturningCustomMethod) == 'UPDATE "book" SET "author_id"=?,"genre_id"=?,"title"=?,"total_pages"=?,"publisher_id"=?,"last_updated"=? WHERE ("id" = ?) RETURNING "id","author_id","genre_id","title","total_pages","publisher_id","last_updated"' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Returning also returns only fields belonging to the entity. This might be the most significant change, not sure if returning could have @Join
annotation to tell Micronaut Data to return joined entities?
data-tck/src/main/java/io/micronaut/data/tck/entities/SaleItem.java
Outdated
Show resolved
Hide resolved
|
This might be the fix for issue. The idea is not
SELECT
entity id for many-to-one and one-to-one relation and onlySELECT
entity and its fields if joined.However, it does change previous behavior and does not select entities with just id for many-to-one, one-to-one, which I think is correct way and fixes original issue).