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

`left_join` incorrectly compiling if additional joins are done afterwards #1459

Open
sgrif opened this Issue Jan 7, 2018 · 1 comment

Comments

Projects
None yet
1 participant
@sgrif
Member

sgrif commented Jan 7, 2018

Reported via gitter. This query compiles successfully:

build::table
        .left_join(revision::table)
        .inner_join(job::table)
        .select((
                job::name,
                build::build_no,
                revision::hash,
        ))
        .load::<Build>(conn)

It should fail to compile unless .nullable has been called on revision::hash. Reversing the order of the join calls causes this code to fail to compile as it should

@sgrif

This comment has been minimized.

Member

sgrif commented Jan 7, 2018

I actually don't know if we can fix this until disjointness based on associated types lands. We need to change this impl:

        impl<Left, Right> SelectableExpression<
            Join<Left, Right, Inner>,
        > for $column_name where
            $column_name: AppearsOnTable<Join<Left, Right, Inner>>,
            Join<Left, Right, Inner>: AppearsInFromClause<$($table)::*, Count=Once>,
        {
        }

to be these two impls:


        impl<Left, Right> SelectableExpression<
            Join<Left, Right, Inner>,
        > for $column_name where
            $column_name: SelectableExpression<Left>,
            Right: AppearsInFromClause<$($table)::*, Count=Never>,
        {
        }

        impl<Left, Right> SelectableExpression<
            Join<Left, Right, Inner>,
        > for $column_name where
            $column_name: SelectableExpression<Right>,
            Left: AppearsInFromClause<$($table)::*, Count=Never>,
        {
        }

I need to think about this more to come up with a way to fix this today.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment