equal
deleted
inserted
replaced
50 val String = Value("TEXT") |
50 val String = Value("TEXT") |
51 val Bytes = Value("BLOB") |
51 val Bytes = Value("BLOB") |
52 } |
52 } |
53 |
53 |
54 type Type_Name = Type.Value => String |
54 type Type_Name = Type.Value => String |
55 def default_type_name(t: Type.Value): String = t.toString |
55 |
|
56 def type_name_default(t: Type.Value): String = t.toString |
|
57 |
|
58 def type_name_sqlite(t: Type.Value): String = |
|
59 if (t == Type.Boolean) "INTEGER" |
|
60 else type_name_default(t) |
|
61 |
|
62 def type_name_postgresql(t: Type.Value): String = |
|
63 if (t == Type.Bytes) "BYTEA" |
|
64 else type_name_default(t) |
56 |
65 |
57 |
66 |
58 /* columns */ |
67 /* columns */ |
59 |
68 |
60 object Column |
69 object Column |
95 { |
104 { |
96 val x = apply(rs) |
105 val x = apply(rs) |
97 if (rs.wasNull) None else Some(x) |
106 if (rs.wasNull) None else Some(x) |
98 } |
107 } |
99 |
108 |
100 override def toString: String = sql_decl(default_type_name) |
109 override def toString: String = sql_decl(type_name_default) |
101 } |
110 } |
102 |
111 |
103 class Column_Boolean private[SQL](name: String, strict: Boolean, primary_key: Boolean) |
112 class Column_Boolean private[SQL](name: String, strict: Boolean, primary_key: Boolean) |
104 extends Column[Boolean](name, strict, primary_key, Type.Boolean) |
113 extends Column[Boolean](name, strict, primary_key, Type.Boolean) |
105 { |
114 { |
284 |
293 |
285 class Database private[SQLite](name: String, val connection: Connection) extends SQL.Database |
294 class Database private[SQLite](name: String, val connection: Connection) extends SQL.Database |
286 { |
295 { |
287 override def toString: String = name |
296 override def toString: String = name |
288 |
297 |
289 def type_name(t: SQL.Type.Value): String = |
298 def type_name(t: SQL.Type.Value): String = SQL.type_name_sqlite(t) |
290 if (t == SQL.Type.Boolean) "INTEGER" |
|
291 else SQL.default_type_name(t) |
|
292 |
299 |
293 def rebuild { using(statement("VACUUM"))(_.execute()) } |
300 def rebuild { using(statement("VACUUM"))(_.execute()) } |
294 } |
301 } |
295 } |
302 } |
296 |
303 |
340 name: String, val connection: Connection, port_forwarding: Option[SSH.Port_Forwarding]) |
347 name: String, val connection: Connection, port_forwarding: Option[SSH.Port_Forwarding]) |
341 extends SQL.Database |
348 extends SQL.Database |
342 { |
349 { |
343 override def toString: String = name |
350 override def toString: String = name |
344 |
351 |
345 def type_name(t: SQL.Type.Value): String = |
352 def type_name(t: SQL.Type.Value): String = SQL.type_name_postgresql(t) |
346 if (t == SQL.Type.Bytes) "BYTEA" |
|
347 else SQL.default_type_name(t) |
|
348 |
353 |
349 override def close() { super.close; port_forwarding.foreach(_.close) } |
354 override def close() { super.close; port_forwarding.foreach(_.close) } |
350 } |
355 } |
351 } |
356 } |