Permalink
Browse files

Merge branch 'tmp'

  • Loading branch information...
Jenkins (CI)
Jenkins (CI) committed Jan 14, 2014
2 parents b3f6c0b + e401d3f commit d1b489f523bec42765e799fa4f9adb0d59ecd50e
View
@@ -6,6 +6,11 @@ as it is included in Scoorge's user's guide.
3.x
-----
+3.12.1
+~~~~~
+
+- scrooge: properly handle field annotations
+
3.12.0
~~~~~
View
@@ -4,7 +4,7 @@
<groupId>com.twitter</groupId>
<artifactId>scrooge</artifactId>
<packaging>pom</packaging>
- <version>3.12.1-SNAPSHOT</version>
+ <version>3.12.2-SNAPSHOT</version>
<distributionManagement>
<repository>
<id>artifactory-release</id>
View
@@ -4,7 +4,7 @@ import com.typesafe.sbt.SbtSite.site
import com.typesafe.sbt.site.SphinxSupport.Sphinx
object Scrooge extends Build {
- val libVersion = "3.12.0"
+ val libVersion = "3.12.1"
val utilVersion = "6.10.0"
val finagleVersion = "6.10.0"
@@ -4,7 +4,7 @@
<groupId>com.twitter</groupId>
<artifactId>scrooge-benchmark</artifactId>
<packaging>jar</packaging>
- <version>3.12.1-SNAPSHOT</version>
+ <version>3.12.2-SNAPSHOT</version>
<parent>
<groupId>com.twitter</groupId>
<artifactId>scala-parent-292</artifactId>
@@ -19,7 +19,7 @@
<dependency>
<groupId>com.twitter</groupId>
<artifactId>scrooge-runtime</artifactId>
- <version>3.12.1-SNAPSHOT</version>
+ <version>3.12.2-SNAPSHOT</version>
</dependency>
<!-- library dependencies -->
<dependency>
@@ -30,7 +30,7 @@
<dependency>
<groupId>com.twitter</groupId>
<artifactId>scrooge-generator</artifactId>
- <version>3.12.1-SNAPSHOT</version>
+ <version>3.12.2-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.twitter</groupId>
View
@@ -4,7 +4,7 @@
<groupId>com.twitter</groupId>
<artifactId>scrooge-core</artifactId>
<packaging>jar</packaging>
- <version>3.12.1-SNAPSHOT</version>
+ <version>3.12.2-SNAPSHOT</version>
<parent>
<groupId>com.twitter</groupId>
<artifactId>scala-parent-292</artifactId>
@@ -4,7 +4,7 @@
<groupId>com.twitter</groupId>
<artifactId>scrooge-generator</artifactId>
<packaging>jar</packaging>
- <version>3.12.1-SNAPSHOT</version>
+ <version>3.12.2-SNAPSHOT</version>
<parent>
<groupId>com.twitter</groupId>
<artifactId>scala-parent-292</artifactId>
@@ -20,7 +20,7 @@
<dependency>
<groupId>com.twitter</groupId>
<artifactId>scrooge-runtime</artifactId>
- <version>3.12.1-SNAPSHOT</version>
+ <version>3.12.2-SNAPSHOT</version>
<scope>test</scope>
</dependency>
<!-- library dependencies -->
@@ -41,8 +41,8 @@ case class Field(
fieldType: FieldType,
default: Option[RHS] = None,
requiredness: Requiredness = Requiredness.Default,
- fieldAnnotations: Map[String, String] = Map.empty,
- defaultValueAnnotations: Map[String, String] = Map.empty
+ typeAnnotations: Map[String, String] = Map.empty,
+ fieldAnnotations: Map[String, String] = Map.empty
) extends Node
case class Function(
@@ -189,32 +189,29 @@ class ThriftParser(
lazy val field = (opt(comments) ~> opt(fieldId) ~ fieldReq) ~
(fieldType ~ defaultedAnnotations ~ simpleID) ~
- opt("=" ~> (rhs ~ defaultedAnnotations)) <~ opt(listSeparator) ^^ {
- case (fid ~ req) ~ (ftype ~ fieldAnnotations ~ sid) ~ optDefault => {
- val value = optDefault map { _._1 }
- val valueAnnotations = optDefault map { _._2 } getOrElse Map.empty
-
- val transformedVal = ftype match {
- case TBool => value map {
- case IntLiteral(0) => BoolLiteral(false)
- case _ => BoolLiteral(true)
+ opt("=" ~> rhs) ~ defaultedAnnotations <~ opt(listSeparator) ^^ {
+ case (fid ~ req) ~ (ftype ~ typeAnnotations ~ sid) ~ value ~ fieldAnnotations => {
+ val transformedVal = ftype match {
+ case TBool => value map {
+ case IntLiteral(0) => BoolLiteral(false)
+ case _ => BoolLiteral(true)
+ }
+ case _ => value
}
- case _ => value
- }
- // if field is marked optional and a default is defined, ignore the optional part.
- val transformedReq = if (!defaultOptional && transformedVal.isDefined && req.isOptional) Requiredness.Default else req
-
- Field(
- fid.getOrElse(0),
- sid,
- sid.name,
- ftype,
- transformedVal,
- transformedReq,
- fieldAnnotations,
- valueAnnotations
- )
+ // if field is marked optional and a default is defined, ignore the optional part.
+ val transformedReq = if (!defaultOptional && transformedVal.isDefined && req.isOptional) Requiredness.Default else req
+
+ Field(
+ fid.getOrElse(0),
+ sid,
+ sid.name,
+ ftype,
+ transformedVal,
+ transformedReq,
+ typeAnnotations,
+ fieldAnnotations
+ )
}
}
@@ -332,9 +332,10 @@ enum Foo
Map("dbtype" -> "fixedchar(4)", "nullable" -> "false")
))
- val idAnnotations = Map("autoincrement" -> "true")
- val idValueAnnotations = Map("initialValue" -> "0")
- val codeAnnotations = Map("dbtype" -> "varchar(255)")
+ val idTypeAnnotations = Map("autoincrement" -> "true")
+ val idFieldAnnotations = Map("initialValue" -> "0")
+ val codeTypeAnnotations = Map("dbtype" -> "varchar(255)")
+ val nameFieldAnnotations = Map("postid" -> "varchar(255)")
val structAnnotations = Map(
"primary_key" -> "(id)",
"index" -> "code_idx(code)",
@@ -345,7 +346,7 @@ enum Foo
struct Airport {
1: optional i64 (autoincrement="true") id = 0(initialValue="0"),
2: optional string(dbtype="varchar(255)") code,
- 3: optional string name
+ 3: optional string name(postid="varchar(255)")
} (primary_key="(id)",
index="code_idx(code)",
sql_name="airports",)
@@ -355,9 +356,9 @@ enum Foo
SimpleID("Airport"),
"Airport",
Seq(
- Field(1, SimpleID("id"), "id", TI64, Some(IntLiteral(0)), Requiredness.Default, idAnnotations, idValueAnnotations),
- Field(2, SimpleID("code"), "code", TString, None, Requiredness.Optional, codeAnnotations, Map.empty),
- Field(3, SimpleID("name"), "name", TString, None, Requiredness.Optional, Map.empty, Map.empty)
+ Field(1, SimpleID("id"), "id", TI64, Some(IntLiteral(0)), Requiredness.Default, idTypeAnnotations, idFieldAnnotations),
+ Field(2, SimpleID("code"), "code", TString, None, Requiredness.Optional, codeTypeAnnotations, Map.empty),
+ Field(3, SimpleID("name"), "name", TString, None, Requiredness.Optional, Map.empty, nameFieldAnnotations)
),
None,
structAnnotations
@@ -5,7 +5,7 @@
<artifactId>scrooge-maven-plugin</artifactId>
<packaging>maven-plugin</packaging>
<name>scrooge-maven-plugin</name>
- <version>3.12.0</version>
+ <version>3.12.1</version>
<prerequisites>
<maven>2.0.6</maven>
</prerequisites>
@@ -217,7 +217,7 @@
<dependency>
<groupId>com.twitter</groupId>
<artifactId>scrooge-generator_2.9.2</artifactId>
- <version>3.12.0</version>
+ <version>3.12.1</version>
</dependency>
</dependencies>
<reporting>
View
@@ -4,7 +4,7 @@
<groupId>com.twitter</groupId>
<artifactId>scrooge-ostrich</artifactId>
<packaging>jar</packaging>
- <version>3.12.1-SNAPSHOT</version>
+ <version>3.12.2-SNAPSHOT</version>
<parent>
<groupId>com.twitter</groupId>
<artifactId>scala-parent-292</artifactId>
View
@@ -4,7 +4,7 @@
<groupId>com.twitter</groupId>
<artifactId>scrooge-runtime</artifactId>
<packaging>jar</packaging>
- <version>3.12.1-SNAPSHOT</version>
+ <version>3.12.2-SNAPSHOT</version>
<parent>
<groupId>com.twitter</groupId>
<artifactId>scala-parent-292</artifactId>
@@ -20,7 +20,7 @@
<dependency>
<groupId>com.twitter</groupId>
<artifactId>scrooge-core</artifactId>
- <version>3.12.1-SNAPSHOT</version>
+ <version>3.12.2-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.twitter</groupId>
@@ -4,7 +4,7 @@
<groupId>com.twitter</groupId>
<artifactId>scrooge-serializer</artifactId>
<packaging>jar</packaging>
- <version>3.12.1-SNAPSHOT</version>
+ <version>3.12.2-SNAPSHOT</version>
<parent>
<groupId>com.twitter</groupId>
<artifactId>scala-parent-292</artifactId>
@@ -35,7 +35,7 @@
<dependency>
<groupId>com.twitter</groupId>
<artifactId>scrooge-core</artifactId>
- <version>3.12.1-SNAPSHOT</version>
+ <version>3.12.2-SNAPSHOT</version>
</dependency>
</dependencies>
</project>

0 comments on commit d1b489f

Please sign in to comment.