empire-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From benni...@apache.org
Subject svn commit: r1171238 - in /incubator/empire-db/trunk/empire-db-codegen/src: main/java/org/apache/empire/db/codegen/CodeGenParser.java test/java/org/apache/empire/db/codegen/CodeGenParserTest.java test/resources/hsqldb/sample.script
Date Thu, 15 Sep 2011 19:50:07 GMT
Author: benniven
Date: Thu Sep 15 19:50:06 2011
New Revision: 1171238

URL: http://svn.apache.org/viewvc?rev=1171238&view=rev
Log:
This commit is for EMPIREDB-113:
- fixed faulty column size detection for decimal data-types

Modified:
    incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGenParser.java
    incubator/empire-db/trunk/empire-db-codegen/src/test/java/org/apache/empire/db/codegen/CodeGenParserTest.java
    incubator/empire-db/trunk/empire-db-codegen/src/test/resources/hsqldb/sample.script

Modified: incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGenParser.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGenParser.java?rev=1171238&r1=1171237&r2=1171238&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGenParser.java
(original)
+++ incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGenParser.java
Thu Sep 15 19:50:06 2011
@@ -343,7 +343,7 @@ public class CodeGenParser {
 			throws SQLException {
 		String name = rs.getString("COLUMN_NAME");
 		DataType empireType = getEmpireDataType(rs.getInt("DATA_TYPE"));
-		double colSize = rs.getInt("COLUMN_SIZE") + (rs.getInt("DECIMAL_DIGITS") / 10.0);
+		double colSize = Double.parseDouble(""+rs.getInt("COLUMN_SIZE") + '.' +rs.getInt("DECIMAL_DIGITS"));
 		boolean required = false;
 		String defaultValue = rs.getString("COLUMN_DEF");
 		if (rs.getString("IS_NULLABLE").equalsIgnoreCase("NO"))

Modified: incubator/empire-db/trunk/empire-db-codegen/src/test/java/org/apache/empire/db/codegen/CodeGenParserTest.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-codegen/src/test/java/org/apache/empire/db/codegen/CodeGenParserTest.java?rev=1171238&r1=1171237&r2=1171238&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db-codegen/src/test/java/org/apache/empire/db/codegen/CodeGenParserTest.java
(original)
+++ incubator/empire-db/trunk/empire-db-codegen/src/test/java/org/apache/empire/db/codegen/CodeGenParserTest.java
Thu Sep 15 19:50:06 2011
@@ -73,6 +73,6 @@ public class CodeGenParserTest {
         final DBColumn salary = employees.getColumn("SALARY");
 
         assertThat(salary.getDataType(), is(DECIMAL));
-        assertThat(salary.getSize(), is(10.2));
+        assertThat(salary.getSize(), is(121.212));
     }
 }

Modified: incubator/empire-db/trunk/empire-db-codegen/src/test/resources/hsqldb/sample.script
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-codegen/src/test/resources/hsqldb/sample.script?rev=1171238&r1=1171237&r2=1171238&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db-codegen/src/test/resources/hsqldb/sample.script (original)
+++ incubator/empire-db/trunk/empire-db-codegen/src/test/resources/hsqldb/sample.script Thu
Sep 15 19:50:06 2011
@@ -21,7 +21,7 @@ CREATE SEQUENCE EMPLOYEE_ID_SEQUENCE AS 
 CREATE MEMORY TABLE ORGANIZATIONS(ORGANIZATION_ID BIGINT NOT NULL,NAME VARCHAR(80) NOT NULL,CONSTRAINT
ORGANIZATIONS_PK PRIMARY KEY(ORGANIZATION_ID))
 CREATE MEMORY TABLE DEPARTMENTS(DEPARTMENT_ID BIGINT NOT NULL,ORGANIZATION_ID BIGINT NOT
NULL,NAME VARCHAR(80) NOT NULL,HEAD VARCHAR(80),BUSINESS_UNIT VARCHAR(4) NOT NULL,UPDATE_TIMESTAMP
TIMESTAMP NOT NULL,CONSTRAINT DEPARTMENTS_PK PRIMARY KEY(DEPARTMENT_ID),CONSTRAINT DEPARTMENTS_ORGANIZATION_I_FK
FOREIGN KEY(ORGANIZATION_ID) REFERENCES ORGANIZATIONS(ORGANIZATION_ID))
 CREATE UNIQUE INDEX DEARTMENT_NAME_IDX ON DEPARTMENTS(NAME)
-CREATE MEMORY TABLE EMPLOYEES(EMPLOYEE_ID BIGINT NOT NULL,SALUTATION VARCHAR(20),FIRSTNAME
VARCHAR(40) NOT NULL,LASTNAME VARCHAR(40) NOT NULL,DATE_OF_BIRTH DATE,DEPARTMENT_ID BIGINT
NOT NULL,GENDER VARCHAR(1),PHONE_NUMBER VARCHAR(40),EMAIL VARCHAR(80),SALARY DECIMAL(10,2),RETIRED
BOOLEAN NOT NULL,UPDATE_TIMESTAMP TIMESTAMP NOT NULL,CONSTRAINT EMPLOYEES_PK PRIMARY KEY(EMPLOYEE_ID),CONSTRAINT
EMPLOYEES_DEPARTMENT_I_FK FOREIGN KEY(DEPARTMENT_ID) REFERENCES DEPARTMENTS(DEPARTMENT_ID))
+CREATE MEMORY TABLE EMPLOYEES(EMPLOYEE_ID BIGINT NOT NULL,SALUTATION VARCHAR(20),FIRSTNAME
VARCHAR(40) NOT NULL,LASTNAME VARCHAR(40) NOT NULL,DATE_OF_BIRTH DATE,DEPARTMENT_ID BIGINT
NOT NULL,GENDER VARCHAR(1),PHONE_NUMBER VARCHAR(40),EMAIL VARCHAR(80),SALARY DECIMAL(121,212),RETIRED
BOOLEAN NOT NULL,UPDATE_TIMESTAMP TIMESTAMP NOT NULL,CONSTRAINT EMPLOYEES_PK PRIMARY KEY(EMPLOYEE_ID),CONSTRAINT
EMPLOYEES_DEPARTMENT_I_FK FOREIGN KEY(DEPARTMENT_ID) REFERENCES DEPARTMENTS(DEPARTMENT_ID))
 CREATE UNIQUE INDEX EMPLOYEE_NAME_IDX ON EMPLOYEES(FIRSTNAME,LASTNAME,DATE_OF_BIRTH)
 CREATE USER SA PASSWORD ""
 GRANT DBA TO SA



Mime
View raw message