stephencelis / SQLite.swift

A type-safe, Swift-language layer over SQLite3.
MIT License
9.72k stars 1.57k forks source link

is there has anyway to implement "glob * || field" ? #1194

Open coder-free opened 1 year ago

coder-free commented 1 year ago

my sql is: SELECT * FROM table where '$domain' GLOB '*' || field order by id desc

I want codable result.

may like this?:


    /// Builds a copy of the expression appended with a `GLOB` query against the
    /// given pattern.
    ///
    ///     let path = Expression<String>("path")
    ///     path.rglob_asterisk("*.png")
    ///     // '*.png' GLOB '*' || "path"
    ///
    /// - Parameter pattern: A pattern to match.
    ///
    /// - Returns: A copy of the expression appended with a `GLOB` query against
    ///   the given pattern.
    public func rglob_asterisk(_ pattern: String) -> Expression<Bool> {
        Function.glob.infix(pattern, "'*' || \(self)".expression)
    }