如何使用筛选器更新SQLite.swift库中的行? [英] how to use filter to update row in SQLite.swift library?

查看:106
本文介绍了如何使用筛选器更新SQLite.swift库中的行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 SQLite.swift 库.

我已经定义了一个表达式:

I have defined a expression:

let id = Expression<Int64>("id")

我有一个变量:

let num: Int = 1

然后,在更新语句中,我进行过滤:

Then, in update statement I do filtering:

let users = Table("User")
// compiler error: // Binary operator '==' cannot be applied to operands of type 'Expression<Int64>' and 'Int'
users.filter(id == num) 

我在上面的注释中显示了编译器错误.我理解错误在说什么,但是如何消除它呢?根据SQLite.swift库文件的说明,该库应该足够聪明,可以将Int与Expression Int64映射.

I get compiler error showing in above comment. I understand what the error is saying, but how to get rid of it? According to SQLite.swift library document, the library should be smart enough to map Int with Expression Int64.

推荐答案

对于id表达式和num变量都使用Int64类型(或Int),您将摆脱此错误.

You will get rid of this error by using the Int64 type (or Int) for both the id expression and the num variable.

这篇关于如何使用筛选器更新SQLite.swift库中的行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆