将记录插入表的代码在最新更新之前工作正常,但现在抛出此错误,所以我想知道我做错了什么。
记录插入的示例代码:
Recipes.insert(Title <- "Chocolate Cake", Description <- "Rich and moist", CookTime <- 20, PictureURL <- "http://w2.fnstatic.co.uk/sites/default/files/pictures/articles/omg-chocolate-cake-7.jpg", VideoURL <- "https://www.youtube.com/watch?v=ZqMqTB7RSjo", Instructions <- "Prepare ingredients into bowl. Whisk for 20 mins, and pour into cake moulding tin. Place in oven at 200C for 15 minutes. Allow 10 mins to cool before icing with chocolate frosting.", Category <- "Desert", Ingredients <- "50g Flour, 200ml Milk, 2 large eggs, Choclate frosting", Favourited <- false)
数据库设置示例:
import Foundation
import SQLite
let path = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true).first as! String
let db = Database("\(path)/databasetest.sqlite3")
let Recipes = db["Recipes"]
let RecipeID = Expression<Int>("RecipeID")
let Title = Expression<String>("Title")
let Description = Expression<String>("Description")
let CookTime = Expression<Int>("CookTime")
let PictureURL = Expression<String>("PictureURL")
let VideoURL = Expression<String>("VideoURL")
let Instructions = Expression<String>("Instructions")
let Category = Expression<String>("Category")
let Ingredients = Expression<String>("Ingredients")
let Favourited = Expression<Bool>("Favourited")
func TableSetup() {
db.create(table: Recipes, ifNotExists: true) { t in
t.column(RecipeID, primaryKey: true)
t.column(Title)
t.column(Description)
t.column(CookTime)
t.column(PictureURL)
t.column(VideoURL)
t.column(Instructions)
t.column(Category)
t.column(Ingredients)
t.column(Favourited, defaultValue: false)
}
我正在使用斯蒂芬斯的 SQLite.swift 项目。https://github.com/stephencelis/SQLite.swift