Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.

Conversation

daraii
Copy link
Contributor

@daraii daraii commented Aug 1, 2022

The issue #171 fixed an problem when converting a DetachedCriteria (using where queries) but it broke DetachedCriterias (not using where queries) when the alias is specified by using createAlias as shown in the demo included in #598.

Example:

Publisher.createCriteria().list {
            'in'("pubIdentifier", new DetachedCriteria<Isbn>(Isbn).build {
                createAlias("book", "b")
                projections {
                    property("publisher")
                }
                'eq'("b.author", a)
            })
}

For domains:

class Author {
    static hasMany = [books: Book]
    String name
}

class Book {
    String title
    static belongsTo = [author: Author]
    static hasMany = [isbn: Isbn]
}

class Isbn {
    String pubGroup
    String publisher
    String title
    String checkDigit
    static belongsTo = [book: Book]
}

class Publisher {
    String name
    String pubIdentifier
}

The proposed commit allows to use the createAlias inside the DetachedCriteria as it worked before the changes for #171 without breaking those changes.

@puneetbehl puneetbehl added this to the 7.3.1 milestone Sep 14, 2022
@puneetbehl
Copy link
Contributor

puneetbehl commented Sep 14, 2022

@daraii Could you please add some tests specific to this change?

@daraii
Copy link
Contributor Author

daraii commented Sep 19, 2022

@puneetbehl Added tests (daraii@1753131)

@puneetbehl puneetbehl merged commit 7b7875a into grails:7.3.x Jan 9, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants