From: Marc W. <mar...@gm...> - 2006-08-17 02:06:42
|
Hi. I've noticed that this piece of code doesn't create a nullable field finished_date. Why? [...] --con :: (D.Database -> IO a) -> IO a con = mysqlConnect ( MySQLOptions {server="localhost", db=dbName, uid="sadmin", pwd=""}) createDatabase :: IO () createDatabase= do con $ \a -> dbSpecToDatabase a dbinfo where tblTodoItems= [ CInfo {cname="ID", descr = (IntT, True)} , CInfo {cname="ID2", descr = (IntT, True)} , CInfo {cname="finished_date", descr = (CalendarTimeT, True)} -- !!!! <<<<<<<<<<<<<<<<<<<<<< here ] tblTodoAssoc = TInfo { tname="todos", cols=tblTodoItems } testopts = DBOptions {useBString = False} dbinfo::DBInfo dbinfo = DBInfo {dbname = "todos" , opts = testopts, tbls = [tblTodoAssoc] } ------------------ Another question. Is con $ \db -> insert db todos ( (iD << (constant id)) # (iD2 << (constant Nothing)) # (finished_date << (constant Nothing)) ) the way to insert a new record? ( In hope it's used this way so I think yes.. ) Then let me ask the question wether it would be possible to create a function like insertValues3 a b c = ( iD << a # iD2 << b # finished_date << c) to use the insert query like this: con $ \db -> insert db todosu( insertValues3 (constant id) (constant Nothing) (constant Nothing) ) because order and types are defined by the table description so there is no need to repeat "iD <<", "iD2 <<" and "finished_date <<" again, right ? Sincerely Marc Weber |