mausch / FsSql

Functional wrapper around ADO.NET for F#
https://www.openhub.net/p/FsSql
Apache License 2.0
67 stars 15 forks source link

Schemas abstraction/removal #18

Closed haf closed 10 years ago

haf commented 10 years ago

Example, works with SQLite:

let private insertMetric schema (m : Measure) connMgr =
  Sql.execNonQuery connMgr
    "INSERT INTO Metrics (Path, EpochTicks, Level, Type, Value)
     VALUES (@path, @epoch, @level, @type, @value)"
    [ P("@path", m.path)
      P("@epoch", m.timestamp.Ticks)
      P("@level", m.level.ToInt())
      P("@type", m.mtype.ToString())
      P("@value", m.value) ]

What I'd want for SQLServer:

let private insertMetric schema (m : Measure) connMgr =
  Sql.execNonQuery connMgr
    (sprintf "INSERT INTO %s.Metrics (Path, EpochTicks, Level, Type, Value)
     VALUES (@path, @epoch, @level, @type, @value)" schema)
    [ P("@path", m.path)
      P("@epoch", m.timestamp.Ticks)
      P("@level", m.level.ToInt())
      P("@type", m.mtype.ToString())
      P("@value", m.value) ]

Is there an existing way of doing schemas transparently in FsSql?

mausch commented 10 years ago

Nope, there's nothing to do this and I think it's out of the scope of FsSql (just as it's out of the scope of ADO.NET).

haf commented 10 years ago

ADO.Net has logging, so that is incorrect.

mausch commented 10 years ago

This issue is about "Schemas abstraction/removal", not logging.

mausch commented 10 years ago

You might want to implement this with a custom IDbConnection parsing and modifying the CommandText before passing it to the real IDbConnection. The wrappers I committed for https://github.com/mausch/FsSql/issues/19 should help, the principle is similar.