#176 Sql and Haven Refinements

brian Wed 13 Feb 2008

  • Refactor sql APIs:
    const class SqlService : Thread
    {
      open, close, autoCommit, commit, rollback, ...
      Statement sql(Str s)
    }
    
    class Statement
    {
      Row[] query(Str:Obj params := null)
      Void queryEach(Str:Obj params := null, |Row r| c)
      ? execute(Str:Obj params := null)
      Statement prepare()
      Void close() // if prepared
    }
  • We will organize dialects into one sqlDialects pod
  • Dialect.maxTableNameLength (replaces tableName, indexName)
  • ColDef setup:
    via registry:  @havenCol=Bool.type class BoolCol {}
    explicit:  @havenCol=MyIntCol.type Int someField
  • ResultRow and queryRaw - goes away
    query and queryEach with Type - goes away
    rework Row and Col to be lighter weight and potentially lazily loaded
    enhance Col with more of the meta-data found in ResultSetMetaData
  • SqlDb becomes SqlService, Haven becomes HavenService (extends SqlService) - all are const
  • We need to use Type in const fields (so TableDef, ColDef, and HavenService can be const), will support via a new Type.toImmutable method which works like List and Map
  • HavenService should probably key its TableDefs on Uri not Type - it will have to know Uri mappings anyways when mapping to ref fields; also allows same type to be used for multiple tables
  • HavenService doesn't manage Uri to TableDef mapping, rather the mappings is the Uri namespace itself, and TableResource wraps a const TableDef
  • To bootstrap HavenService inside fand, we will have appriopate const fields which will allow this:
    haven:HavenService
    {
      username   = "brian"
      password   = "foo"
      dialect    = sqlDialects::MySqlDialect
      connection = "jdbc:somehost"  
    }
  • The responsbility of mounting TableResources is the primary services which own those resources:
    UserService
    {
      spaceUri=`/services/haven`
      usersUri=`/users/`
    }

The uri is used by the service to mount the table, it is used by client services to lookup the appriopate tables on a per app basis.

This raises the question of the common mixin used to generically mount storages types, queries, and handle transactions (for example the UserService shouldn't have a dependency on haven).

Login or Signup to reply.