我使用SQLite.swift
我试过表达:
userTable.filter(contains([1, 2, 3, 4, 5], entryId))
从例子。但我收到以下错误:
Cannot find an overload for 'contains' that accepts an argument list of type '([Int], Expression<String>)'
我怎样才能使这项工作?
我使用SQLite.swift
我试过表达:
userTable.filter(contains([1, 2, 3, 4, 5], entryId))
从例子。但我收到以下错误:
Cannot find an overload for 'contains' that accepts an argument list of type '([Int], Expression<String>)'
我怎样才能使这项工作?
SQLite.swift 与 Swift 本身一样,是类型安全的,因此您过滤的列表达式必须与您正在检查的数组的类型相同。
似乎entryId
是 type Expression<String>
,这类似于编写以下 vanilla Swift:
contains([1, 2, 3, 4, 5], "1")
这实际上失败了一个非常相似的错误消息。
找不到接受“([Int],String)”类型参数列表的“包含”的重载
如果您希望entryId
成为Int
,则应将其定义为:
let entryId = Expression<Int>("entryId")
有了这个变化,contains
应该可以正常工作。