Skip to content

Conversation

@stephencelis
Copy link
Member

This PR (draft for now) introduces some potential helpers for SQLite's full-text search capabilities (FTS5). We can refine them further, and potentially quarantine them to a SQLite-only trait/module before merging.

@stephencelis stephencelis requested a review from mbrandonw July 22, 2025 18:07
///
/// - Parameter pattern: A string expression describing the `MATCH` pattern.
/// - Returns: A predicate expression.
public func match(_ pattern: QueryValue) -> some QueryExpression<Bool> {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moving this to requiring an FTS5 conformance is technically a breaking change, but it's not valid to call match outside of FTS, so I think it's fine while the library is still 0.x.

@mackoj
Copy link
Contributor

mackoj commented Aug 5, 2025

After integrating it into my project, the migration from my custom FTS5 implementation was smooth.

I did encounter two issues:

  • inheriting from FTS5, as it conflicted with GRDB’s own FTS5 type. Using @Table(virtual: FTS5.self) would be ideal even though the workaround was simply to prefix it with StructuredQueries.FTS5.
@Table("tokens_fts")
public struct DBTokenFTS: StructuredQueries.FTS5, Codable, Sendable, Hashable {
  @Column(primaryKey: true)
  public let rowid: DBToken.ID
  public let path: String

  public init(rowid: DBToken.ID, path: String) {
    self.rowid = rowid
    self.path = path
  }
}

@stephencelis stephencelis marked this pull request as ready for review August 20, 2025 22:21
@stephencelis stephencelis merged commit eb8c86d into main Aug 20, 2025
3 checks passed
@stephencelis stephencelis deleted the fts branch August 20, 2025 22:23
coenttb pushed a commit to coenttb/swift-structured-queries-postgres that referenced this pull request Oct 14, 2025
* Full-text search

* wip

* wip

* Update FTS5.swift

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* fix
coenttb pushed a commit to coenttb/swift-structured-queries-postgres that referenced this pull request Oct 15, 2025
* Full-text search

* wip

* wip

* Update FTS5.swift

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* fix
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

Successfully merging this pull request may close these issues.

3 participants