Consider factoring sqlx pool out of `to_sql` function
Closed this issue · 0 comments
jamesaoverton commented
I would like to be able to convert the Select
struct to a SQL string without requiring a pool. This requires (at least) two changes:
- I like being able to convert
SELECT *
to an explicit list of columns, as implemented here https://github.com/ontodev/sqlrest.rs/blob/first-issues/src/lib.rs#L413, but I would like that to be optional. I think it should be factored out into aselect_all(&pool)
function that would update theselect
field. - We need to know the SQL flavour: SQLite or Postgres. Currently the code checks the pool type, but I suggest we add
dbtype
field with an enum, which could be set manually or automatically with afor_pool(&pool)
function, or default to SQLite (I guess).
So we would have a few functions on Select
that take a pool, but most would not. We could also consider having to_sqlite()
and to_postgres()
convenience functions.
All of these new things could have better names than what I suggest.