Permalink
Browse files

Extracted column to separate case class.

  • Loading branch information...
1 parent 04c06d9 commit bb835aa03fd20103435b96e9958c248498a14369 Georgii Leontiev committed Apr 13, 2012
Showing with 3 additions and 2 deletions.
  1. +3 −2 src/main/scala/DDLParser.scala
@@ -13,7 +13,8 @@ object DDLParser extends JavaTokenParsers {
val columnDelimiter = """,*""".r
// Columns: column name, data type, not null, autoincr, default value
- case class CreateTable(name: String, columns: List[(String, String, Boolean, Boolean, Option[String])])
+ case class CreateTable(name: String, columns: List[Column])
+ case class Column(name: String, datatype: String, notNull: Boolean, autoInc: Boolean, defaultVal: Option[String])
def cleanString(str: String) = str.replaceAll("`", "")
@@ -33,7 +34,7 @@ object DDLParser extends JavaTokenParsers {
val columnsData = columns map { entry =>
entry match {
case colName ~ colType ~ notNull ~ autoInc ~ isDefault ~ _ =>
- (cleanString(colName), colType, notNull.isDefined, autoInc.isDefined, isDefault.map(_._2))
+ Column(cleanString(colName), colType, notNull.isDefined, autoInc.isDefined, isDefault.map(_._2))
}
}
CreateTable(cleanString(name), columnsData)

0 comments on commit bb835aa

Please sign in to comment.