SwifQL / Bridges

🌉 SwifQL+NIO provider to Postgres and MySQL

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Documentation or fix for Decimal type

EthanLozano opened this issue · comments

Bridges' documentation should nudge the user from Decimal to Double, or SwifQL/Bridges should appropriately translate a swift Double to a Postgres decimal/numeric.

I had a table column declared with a Decimal swift type:

    @Column("my_decimal")
    var myDecimal: Decimal

and I received the following error

column "my_decimal" is of type numeric but expression is of type text (transformAssignedExpr)

I enabled Bridges debugging, and the prepared statement showed a quoted value (i.e. "250")

After snooping around in SwifQL's Type+Autodetect.swift, I noticed that a swift Double translates to a Postgres decimal/numeric. My code started working when I changed the variable type from Decimal to a Double:

    @Column("my_decimal")
    var myDecimal: Double