         let value = obj.valueForKey(id)!
         var update = model.table.update()
         let sql: String
-        let predicate = NSPredicate(format: "\(id) = \(value)")
+        let predicate = NSPredicate(format: "\(id) = '\(value)'")
         var params = [AnyObject]()
 
         for each in model.table.sortedColumns{

        var automaticPrimaryKey = false
        var params = [AnyObject]()

        for each in model.table.sortedColumns{
            let value: AnyObject?

            if each.primaryKey && each.type == .Integer64AttributeType{
                automaticPrimaryKey = true
                continue
            }

            if let column = each.foreignKey{
                let parts = each.label.unicodeScalars.split{ $0 == "_"}.map(String.init)

                if let target = obj.valueForKey(parts[0]) as? AmigoModel{
                    let fkModel = config.tableIndex[column.relatedColumn.table!.label]!

    public func addModel<T: AmigoModel>(obj: T){
        let type = obj.dynamicType.description()
        let model = typeIndex[type]!

        var isInsert = false
        let key = obj.valueForKey(model.primaryKey.label)

        switch model.primaryKey.type{
        case .Integer16AttributeType: fallthrough
        case .Integer32AttributeType: fallthrough
        case .Integer64AttributeType:
            if key == nil{
                isInsert = true
            } else if let key = key as? Int where key == 0 {
                isInsert = true
            }
        default:
            if key == nil{
                isInsert = true
            }
        }

        if isInsert {
            insert(obj, model: model)
        } else {
            update(obj, model: model)
