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

.from in .whereIn subquery incorrectly results in parent entity table #248

Open
MordantWastrel opened this issue Feb 28, 2024 · 0 comments

Comments

@MordantWastrel
Copy link
Contributor

The following Quick scope is producing an erroneous table prefix for the 'where in' clause.


     function scopeNotInCloneQueue( query, required string seasonUID ) {
                return query.whereNotIn( "registrationID", function( sQ ) {
                        sQ.from( "registration_clone_queue" )
                                .select( "registrationID" )
                                .join(
                                        "registration_clone_queue_batches",
                                        "registration_clone_queue.batchID",
                                        "=",
                                        "registration_clone_queue_batches.batchID"
                                )
                                .whereTargetSeasonUID( seasonUID )
                } );
        }

What did you expect to happen?

The subquery should be selecting registrationID from registration_clone_queue.

What actually happened instead?

The SQL produced was to SELECT registrationID FROM registrations (the table of the parent entity where the scope lives). registrationID is the primary key.

A workaround is to specify an alias in the from clause and refer to the registraitonID explicitly with the table prefix.

Environment

List the software versions you're using:

  • Quick: 7.3.1 / Lucee 5
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

No branches or pull requests

1 participant