- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我正在尝试在 Cocoa macOS 应用程序中使用 SQLite.swift 和 Swift 检索表中的记录数。根据README ,这可以使用以下方法实现:
let users = Table("users")
...
let count = try db.scalar(users.count)
但是,当执行此代码时(从按钮单击事件处理程序),将抛出以下异常:
Fatal error: 'try!' expression unexpectedly raised an error: unrecognized token: ":" (code: 1): file...
有问题的代码是下面的 db
访问行。 db
对象被分配了一个 Connection
对象,该对象在 View 加载时从一个单独的 Database
结构函数返回。我相信这是有效且无关的,因为其他代码区域正在使用相同的方法成功打开与数据库的连接。
let login = Login()
var db : Connection?
...
let count = try! db?.scalar(login.table.count)
这是它生成的查询表达式。在文本中,这似乎是 SELECT count(_:)(*) FROM login
。
但是,有趣的是,如果我使用以下行,则会返回正确的结果。
let count = try! db?.scalar(“SELECT COUNT(*) FROM login”)
此 Login
对象的模型是:
import SQLite
public struct Login {
let table = Table("login")
// Bunch of properties for various record fields
init() {}
}
任何和所有帮助将不胜感激。提前致谢!
最佳答案
正如我所怀疑的那样,它原来是 SQLite.swift
本身的问题。几天前,我在 GitHub 上发现了以下报告此问题的 SQLite.swift
问题。
问题如下,据记者描述,tanzolone :
In Xcode 10.2 beta 4 the macro#functionshows a different behaviour. As SQLite.swift relies on #function in different subroutines for the composition of SQLite queries, several bugs linked to invalid SQLite statements seem to be introduced.
I have just run the SQLite.swift tests with Xcode 10.2 beta 4 and there are several failures linked to this issue.
An example as follows: In the following helper function (Helpers.swift line 107):
func wrap<T>(_ expression: Expressible, function: String = #function) -> Expression<T> {
return function.wrap(expression)
}when called from
static func count(_ star: Star) -> Expression<UnderlyingType>
the value of the function when running in Xcode 10.2 beta 4 is
count(_:)
instead ofcount
. This leads to invalid SQLite statements of the typeSELECT count(_:)(*) myTable
.
项目维护人员现在已经在 master
的最新 HEAD
中解决了这个问题(当前为 1a908a7da11852f252e7c6b6366a4d9f8a7d5272)。
在我的项目中,需要更新的行在我的 Podfile
中如下:
pod 'SQLite.swift/SQLCipher', :git => 'https://github.com/stephencelis/SQLite.swift.git', :commit => 'ed8f603f856e9f1f4adb76b63b7234547257ec5a'
这已更新为:
pod 'SQLite.swift/SQLCipher', :git => 'https://github.com/stephencelis/SQLite.swift.git', :branch => 'master'
或者,可以引用提交本身:
pod 'SQLite.swift/SQLCipher', :git => 'https://github.com/stephencelis/SQLite.swift.git', :commit => '1a908a7da11852f252e7c6b6366a4d9f8a7d5272'
为了更新此引用,我在我的项目根目录中执行了以下 CLI 步骤来删除、更新和安装项目 pod:
$ pod cache clean --all
$ rm -rf Pods/
$ rm Podfile.lock
$ open -a Xcode Podfile # Updated the SQLite.swift project ref to the above
$ pod install
这就解决了问题,不再抛出异常。
关于swift - SQLite.swift:由于无法识别的 token 无法检索表计数: ":",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55755296/
我正在开发一个应用程序,它使用 OAuth - 基于 token 的身份验证。 考虑到我们拥有访问和刷新 token ,这就是流程的样子。 Api call -> intercepter append
如何取消标记此代码的输出? 类(class)核心: def __init__(self, user_input): pos = pop(user_input) subject = ""
当我使用命令 kubectl 时与 --token标记并指定 token ,它仍然使用 kubeconfig 中的管理员凭据文件。 这是我做的: NAMESPACE="default" SERVICE
我正在制作 SPA,并决定使用 JWT 进行身份验证/授权,并且我已经阅读了一些关于 Tokens 与 Cookies 的博客。我了解 cookie 授权的工作原理,并了解基本 token 授权的工作
我正在尝试从应用服务获取 Google 的刷新 token ,但无法。 日志说 2016-11-04T00:04:25 PID[500] Verbose Received request: GET h
我正在开发一个项目,只是为了为 java 开发人员测试 eclipse IDE。我是java新手,所以我想知道为什么它不起作用,因为我已经知道该怎么做了。这是代码: public class ecli
我正在尝试使用 JwtSecurityTokenHandler 将 token 字符串转换为 jwt token 。但它出现错误说 IDX12709: CanReadToken() returned
我已阅读文档 Authentication (来自 Facebook 的官方)。我仍然不明白 Facebook 提供的这三种访问 token 之间的区别。网站上给出了一些例子,但我还是不太明白。 每个
我的部署服务器有时有这个问题,这让我抓狂,因为我无法在本地主机中重现,我已经尝试在我的 web.config 中添加机器 key ,但没有成功远。 它只发生在登录页面。 我的布局:
我已经设法获得了一个简单的示例代码,它可以创建一个不记名 token ,还可以通过阅读 stackoverflow 上的其他论坛来通过刷新 token 请求新的不记名 token 。 启动类是这样的
如果我有以前的刷新 token 和使用纯 php 的访问 token ,没有 Google Api 库,是否可以刷新 Google Api token ?我在数据库中存储了许多用户刷新和访问 toke
我通过 Java 应用程序使用 Google 电子表格时遇到了问题。我创建了应用程序,该应用程序运行了 1 年多,没有任何问题,我什至在 Create Spreadsheet using Google
当我有一个有效的刷新 token 时,我正在尝试使用 Keycloak admin REST API 重新创建访问 token 。 我已经通过调用 POST/auth/realms/{realm}/p
我正在尝试让第三方 Java 客户端与我编写的 WCF 服务进行通信。 收到消息时出现如下异常: Cannot find a token authenticator for the 'System.I
在尝试将数据插入到我的 SQl 数据库时,我收到以下错误 System.Data.SqlServerCe.SqlCeException: There was an error parsing the
使用数据库 session token 系统,我可以让用户使用用户名/密码登录,服务器可以生成 token (例如 uuid)并将其存储在数据库中并将该 token 返回给客户端。其上的每个请求都将包
我最近注册了 Microsoft Azure 并设置了认知服务帐户。使用 Text Translation API Documentation 中的说明我能够使用 interactive online
我使用 IAntiforgery API 创建了一个 ASP.Net Core 2 应用程序。 这提供了一种返回 cookie 的方法。 客户端获取该 cookie,并在后续 POST 请求中将该值放
我正在使用 spacy 来匹配某些文本(意大利语)中的特定表达式。我的文本可以多种形式出现,我正在尝试学习编写一般规则的最佳方式。我有如下 4 个案例,我想写一个适用于所有案例的通用模式。像这样的东西
我无法理解 oauth 2.0 token 的原则处理。 我的场景是,我有一个基于 web 的前端后端系统,带有 node.js 和 angular 2。用户应该能够在此站点上上传视频。然后创建一些额
我是一名优秀的程序员,十分优秀!