Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compiler error: Could not find member 'update' #17

Closed
violabg opened this issue Nov 19, 2014 · 2 comments
Closed

compiler error: Could not find member 'update' #17

violabg opened this issue Nov 19, 2014 · 2 comments
Labels

Comments

@violabg
Copy link

violabg commented Nov 19, 2014

I got a weird compiler error for the class below

class PDSsTb {

    let id = Expression<String>("id")
    let categoryId = Expression<Int>("categoryId")
    let languageId = Expression<String>("languageId")
    let name = Expression<String>("name")
    let thumb = Expression<Blob?>("thumb")
    let modificationDate = Expression<String>("modificationDate")
    let isCurrent = Expression<Int>("isCurrent")
    let isLocal = Expression<Int>("isLocal")
    let needsUpdate = Expression<Int>("needsUpdate")
    let progress = Expression<Double>("progress")

    let table:SQLite.Query

    init(db:Database){

        table = db["pdf"]
    }

    func updatePdfStatusOnDb(brochure:Brochure) {
        let brochureToUpdate = table.filter(id == brochure.pdfId).update(isLocal <- brochure.isLocal, needsUpdate <- brochure.needsUpdate)
    }

    func deleteLocalBrochure(brochure:Brochure) {
        let fileToDelete = table.filter(id == brochure.pdfId).update(isLocal <- brochure.isLocal, needsUpdate <- brochure.needsUpdate)
    }
}

the compiler says:

Could not find member 'update'

for both functions.

@violabg
Copy link
Author

violabg commented Nov 19, 2014

Never mind, I found the problem

I needed to cast Bool to Int

func updatePdfStatusOnDb(brochure:Brochure) {
let brochureToUpdate = table.filter(id == brochure.pdfId).update(isLocal <- Int(brochure.isLocal), needsUpdate <- Int(brochure.needsUpdate)).changes
}

func deleteLocalBrochure(brochure:Brochure) {
    let fileToDelete = table.filter(id == brochure.pdfId).update(isLocal <- Int(brochure.isLocal), needsUpdate <- Int(brochure.needsUpdate)).changes
}

@violabg violabg closed this as completed Nov 19, 2014
@stephencelis
Copy link
Owner

SQLite.swift supports Bool values, but you must declare the expression as Expression<Bool> (and I believe the column's declared datatype must be BOOLEAN).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants