ontodev/sqlrest.rs

Consider factoring sqlx pool out of `to_sql` function

Closed this issue · 0 comments

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:

  1. 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 a select_all(&pool) function that would update the select field.
  2. 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 a for_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.