src/Pure/General/sql.scala
changeset 77598 6370d9e5ab50
parent 77596 dd8b08729458
child 77664 f5d3ade80d15
equal deleted inserted replaced
77597:308f3f48c2c7 77598:6370d9e5ab50
   328     def timing(c1: Column, c2: Column, c3: Column): Timing =
   328     def timing(c1: Column, c2: Column, c3: Column): Timing =
   329       Timing(Time.ms(long(c1)), Time.ms(long(c2)), Time.ms(long(c3)))
   329       Timing(Time.ms(long(c1)), Time.ms(long(c2)), Time.ms(long(c3)))
   330 
   330 
   331     def get[A](column: Column, f: Column => A): Option[A] = {
   331     def get[A](column: Column, f: Column => A): Option[A] = {
   332       val x = f(column)
   332       val x = f(column)
   333       if (rep.wasNull) None else Some(x)
   333       if (rep.wasNull || x == null) None else Some(x)
   334     }
   334     }
   335     def get_bool(column: Column): Option[Boolean] = get(column, bool)
   335     def get_bool(column: Column): Option[Boolean] = get(column, bool)
   336     def get_int(column: Column): Option[Int] = get(column, int)
   336     def get_int(column: Column): Option[Int] = get(column, int)
   337     def get_long(column: Column): Option[Long] = get(column, long)
   337     def get_long(column: Column): Option[Long] = get(column, long)
   338     def get_double(column: Column): Option[Double] = get(column, double)
   338     def get_double(column: Column): Option[Double] = get(column, double)
   492     def update_date(stmt: SQL.Statement, i: Int, date: Date): Unit =
   492     def update_date(stmt: SQL.Statement, i: Int, date: Date): Unit =
   493       if (date == null) stmt.string(i) = (null: String)
   493       if (date == null) stmt.string(i) = (null: String)
   494       else stmt.string(i) = date_format(date)
   494       else stmt.string(i) = date_format(date)
   495 
   495 
   496     def date(res: SQL.Result, column: SQL.Column): Date =
   496     def date(res: SQL.Result, column: SQL.Column): Date =
   497       date_format.parse(res.string(column))
   497       proper_string(res.string(column)) match {
       
   498         case None => null
       
   499         case Some(s) => date_format.parse(s)
       
   500       }
   498 
   501 
   499     def insert_permissive(table: SQL.Table, sql: SQL.Source = ""): SQL.Source =
   502     def insert_permissive(table: SQL.Table, sql: SQL.Source = ""): SQL.Source =
   500       table.insert_cmd(cmd = "INSERT OR IGNORE", sql = sql)
   503       table.insert_cmd(cmd = "INSERT OR IGNORE", sql = sql)
   501   }
   504   }
   502 }
   505 }