AlgebraicJulia / AlgebraicRelations.jl

Relational Algebra, now with more algebra!
https://www.algebraicjulia.org
MIT License
48 stars 3 forks source link

Multiple Dispatch for Conversion from Julia Types to SQL Types #12

Open bosonbaas opened 3 years ago

bosonbaas commented 3 years ago

Currently, the conversion from Julia Types to SQL types is just facilitated by a dictionary between types. While a solution other than hardcoding the type conversion would be preferable (maybe a more popular library that already maintains this map?), taking advantage of the Julia multiple dispatch system will make it a more flexible hardcoding.

epatters commented 3 years ago

Like you said, using multiple dispatch is more flexible than using a Dict{Type,Symbol} since you can do stuff like:

sql_type(::Type{<:Real}) = :Real
sql_type(::Type{<:Integer}) = :Int

Another complication is that different SQL DBs have very different data types, e.g. compare SQLite's minimalist data types to all the Postgres data types.

jpfairbanks commented 3 years ago

That would be an indication that we should make an sql_type(::Type{PGSQLConverter}, t::T) or sql_type(::Type{SQLiteConverter}, t::T) function so that multiple backends can be added later.