Closed Blacksmoke16 closed 5 years ago
The type returned of each value is determined by the database engine. At least that is true in this driver.
There is no built in conversion from the returned type to an expected type.
Something like the following might help to unify the result to an Int64 when needed. The driver could always define new custom types. Without new concepts like which types are numerics, the solution will always depend on know supported types by each driver.
value = db.sacalar(query)
value64 =
case value
when Int64
value
when Int32
value.to_i64
when ...
... expr : Int64 ...
else
raise "Unsupported numeric scalar type"
end
Gotcha, thanks for the tips.
The data type of the return value seems to be dependent on the context it the value originates from. For example:
Shouldn't
select 100 - 75
be returned as anInt32
and the last query be anInt64
in this case since the sum is greater than the max ofInt32
and are all integers.It seems it will return an
Int64
on any select that involves math as anInt64
. However i'm not sure this is by design or unintentional...This makes it harder to work with aggregations, since the return type is going to be different than the Postgres shard would return.