dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #20751
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 9635: Fixed bug<1100706> sql-view-duplicate-column-names
------------------------------------------------------------
revno: 9635
committer: Hieu <hieu.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2013-01-28 16:49:23 +0700
message:
Fixed bug<1100706> sql-view-duplicate-column-names
modified:
dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/sqlview/jdbc/JdbcSqlViewExpandStore.java
dhis-2/dhis-services/dhis-service-administration/src/test/java/org/hisp/dhis/sqlview/SqlViewServiceTest.java
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/sqlview/jdbc/JdbcSqlViewExpandStore.java'
--- dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/sqlview/jdbc/JdbcSqlViewExpandStore.java 2012-07-21 13:43:46 +0000
+++ dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/sqlview/jdbc/JdbcSqlViewExpandStore.java 2013-01-28 09:49:23 +0000
@@ -156,9 +156,13 @@
@Override
public String testSqlGrammar( String sql )
{
+ String viewNameCheck = SqlView.PREFIX_VIEWNAME + System.currentTimeMillis();
+
try
{
- jdbcTemplate.queryForList( sql );
+ jdbcTemplate.execute( PREFIX_CREATEVIEW_QUERY + viewNameCheck + " AS " + sql );
+
+ dropViewTable( viewNameCheck );
}
catch ( Exception ex )
{
=== modified file 'dhis-2/dhis-services/dhis-service-administration/src/test/java/org/hisp/dhis/sqlview/SqlViewServiceTest.java'
--- dhis-2/dhis-services/dhis-service-administration/src/test/java/org/hisp/dhis/sqlview/SqlViewServiceTest.java 2012-11-20 17:04:08 +0000
+++ dhis-2/dhis-services/dhis-service-administration/src/test/java/org/hisp/dhis/sqlview/SqlViewServiceTest.java 2013-01-28 09:49:23 +0000
@@ -29,9 +29,9 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.assertNotSame;
import java.util.Collection;
@@ -192,7 +192,7 @@
@Test
public void testMakeUpForQueryStatement()
- {
+ {
SqlView sqlViewA = createSqlView( 'A', SQL1 );
sqlViewA.setSqlQuery( sqlViewService.makeUpForQueryStatement( sqlViewA.getSqlQuery() ) );
@@ -210,7 +210,7 @@
@Test
public void testSetUpViewTableName()
- {
+ {
SqlView sqlViewC = createSqlView( 'C', SQL3 );
SqlView sqlViewD = createSqlView( 'D', SQL4 );
@@ -221,7 +221,7 @@
@Test
public void testGetAllSqlViewNames()
- {
+ {
SqlView sqlViewA = createSqlView( 'A', SQL4 );
SqlView sqlViewB = createSqlView( 'B', SQL4 );
SqlView sqlViewC = createSqlView( 'C', SQL4 );
@@ -240,10 +240,22 @@
sqlViewService.dropViewTable( sqlViewB.getViewName() );
sqlViewService.dropViewTable( sqlViewC.getViewName() );
sqlViewService.dropViewTable( sqlViewD.getViewName() );
-
+
sqlViewService.deleteSqlView( sqlViewA );
sqlViewService.deleteSqlView( sqlViewB );
sqlViewService.deleteSqlView( sqlViewC );
sqlViewService.deleteSqlView( sqlViewD );
}
+
+ @Test
+ public void testTestSqlGrammar()
+ {
+ String sql = "select de.name, de.name from dataelement de";
+
+ assertNotSame( sqlViewService.testSqlGrammar( sql ), "" );
+
+ sql += " xyz";
+
+ assertNotSame( sqlViewService.testSqlGrammar( sql ), "" );
+ }
}