Partial SQL insertion in haskelldb

I just started a new project and wanted to use HaskellDB at the beginning. I created a database with two columns:

create table sensor (
    service text,
    name text
);

.. learned how to make the basic HaskellDB mechanism (ohhhh .. in the documentation) and wanted to do an insert. However, I wanted to do a partial insertion (there should be more columns), something like:

insert into sensor (service) values ('myservice');

Translated to HaskellDB:

transaction db $ insert db SE.sensor (SE.service <<- (Just $ senService sensor))

But ... it just doesn't work. What also does not work is to specify the column names in a different order, which is also not very convenient. Is there a way to do partial insertion in haskelldb?

The error codes I get is when I simply inserted another column ("name") as the first:

Couldn't match expected type `SEI.Service'
       against inferred type `SEI.Name'
  Expected type: SEI.Intsensor
  Inferred type: Database.HaskellDB.HDBRec.RecCons
                   SEI.Name (Expr String) er
When using functional dependencies to combine
  Database.HaskellDB.Query.InsertRec
    (Database.HaskellDB.HDBRec.RecCons f (e a) r)
    (Database.HaskellDB.HDBRec.RecCons f (Expr a) er),
etc..

And when I do the "service" as the first and only field, I get:

Couldn't match expected type `Database.HaskellDB.HDBRec.RecCons
                                SEI.Name
                                (Expr String)
                                (Database.HaskellDB.HDBRec.RecCons
                                   SEI.Time
                                   (Expr Int)
                                   (Database.HaskellDB.HDBRec.RecCons
                                      SEI.Intval (Expr Int) Database.HaskellDB.HDBRec.RecNil))'
       against inferred type `Database.HaskellDB.HDBRec.RecNil'

( ) " ", : (

+5
1

, . HaskellDB.Query , insert :

insert :: (ToPrimExprs r, ShowRecRow r, InsertRec r er) => Database -> Table er -> Record r -> IO ()

, InsertRec r er. :

InsertRec RecNil RecNil
(InsertExpr e, InsertRec r er) => InsertRec (RecCons f (e a) r) (RecCons f (Expr a) er)

- . - . er, . . , _default:

insQ db = insert db test_tbl1 (c1 <<- (Just 5) # c2 << _default)

, , :

insC1 db x = insert db test_tbl1 (c1 <<- (Just x) # c2 << _default)
insC2 db x = insert db test_tbl2 (c1 << _default  # c2 <<- (Just x))

, , . , InsertRec HList, . .

+4

All Articles