Version française
Home     About     Download     Resources     Contact us    
Browse thread
Idea for another type safe PostgreSQL interface
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Alex Baretta <alex@b...>
Subject: Re: [Caml-list] Idea for another type safe PostgreSQL interface
Richard Jones wrote:
>   [I just throwing this idea out there to see if people find it
>   interesting, or want to shoot it down ...  There're only fragments of
>   working code at the moment]
> 
> I'm thinking about a type safe interface to PostgreSQL.  One such
> interface at the moment is in Xcaml, but it only supports a very small
> subset of SQL, and I like to use complex SQL.  It seems that there is
> a way to support the whole of PostgreSQL's language from within OCaml
> programs, in a type safe way.

Every once in a while we extend the Embedded SQL with a new feature, but
we never planned to support all of PostgreSQL. In fact, what we want to
have is abstraction over the actual DB implementation.

> The general plan would be to have a camlp4 extension which would use
> Postgres's new "PREPARE" feature to actually prepare the statements,
> and Postgres's other new feature, "Describe Statement", to pull out
> the parameter types and result types from the prepared statement.
> This allows the camlp4 extension to replace the statement string with
> a type safe expression, and allow type inference to find mismatches.
> How a typical program would look is shown at the end of this message.

I really think XDBS is the the way to go. You define the schema in a
high level language (OO-Entity-Relationship modeling), supporting lower
level refinements (logical, physical and virtual schema refinements) and
compiling to Ocaml and SQL-DDL. This way, the type safety can be
established at compile time without need for a database connection.
Also, the type safety does not depend on a specific implementation of
SQL, which is usually desireable.

Alex

-- 
*********************************************************************
http://www.barettadeit.com/
Baretta DE&IT
A division of Baretta SRL

tel. +39 02 370 111 55
fax. +39 02 370 111 54

Our technology:

The Application System/Xcaml (AS/Xcaml)
<http://www.asxcaml.org/>

The FreerP Project
<http://www.freerp.org/>