stephencelis/SQLite.swift

Subscript 'subscript(_:)' requires that 'Float' conform to 'Value'

Opened this issue · 1 comments

Issues are used to track bugs and feature requests.
Need help or have a general question? Ask on Stack Overflow (tag sqlite.swift).

Build Information

SQLite.swift version : 0.15.3
XCode : 16
Swift Package manager

I'm trying to select a field of type Float but I get an error assigning it to a variable.

The field is defined as:
let iAmount = Expression<Float>("Amount");

When I try to populate a variable, I this the error:
Subscript 'subscript(_:)' requires that 'Float' conform to 'Value'

Below is the code:

        for ri in try db.prepare(dtRecipeIngredients.order(iName).where(iUUIDRecipe == r[rUUID]))
        {
        let amount : Float = ri[iAmount]
        
        let newIngredient = Ingredient (
            Name: ri[iName]
            , Qnty: amount
        )

The error occurs at compile time, not run time. Should I be declaring the expression for the field in a different way for a Float?

The same thing will work with a Int type, but not Float.

The error occurs on this line:
let amount : Float = ri[iAmount]

I was able to get my code working by switching to a Double:
let iAmount = Expression<Double>("Amount");

The documentation does state that Float should work.