Skip to content

Issue with storing and reusing joined query – cannot conform to ‘Table’ #137

@byMohamedali

Description

@byMohamedali

Description

Title: Issue with storing and reusing joined query – cannot conform to 'Table'

Hi team 👋

I'm running into a compilation issue when trying to store a joined query and then apply a .where clause afterward.

✅ This works fine:

MediaPreference
  .join(select) { $0.mediaId == $1.id }
  .where { pref, _ in pref.isDeleted == false }

❌ But this throws an error:

var joinedQuery = MediaPreference
  .join(select) { $0.mediaId == $1.id }

joinedQuery.where { pref, _ in pref.isFavorite == true }

Type '(_: MediaGRDB)' cannot conform to 'Table'

It seems like the compiler has trouble resolving the type once the result of .join() is stored. This makes it hard to build reusable and advanced queries in steps.

Is there a way to store the joined query and still use it with filters afterward? Any guidance or workaround would be much appreciated.

Thanks again for the great work on this library 🙏
Image

Checklist

  • I have determined whether this bug is also reproducible in a vanilla SwiftUI project.
  • I have determined whether this bug is also reproducible in a vanilla GRDB project.
  • If possible, I've reproduced the issue using the main branch of this package.
  • This issue hasn't been addressed in an existing GitHub issue or discussion.

Expected behavior

No response

Actual behavior

No response

Reproducing project

No response

SharingGRDB version information

0.5.1

Sharing version information

No response

GRDB version information

No response

Destination operating system

No response

Xcode version information

No response

Swift Compiler version information

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions