Skip to content
Snippets Groups Projects
Commit 7f5f1992 authored by gmantele's avatar gmantele
Browse files

[ADQL] Fix major bug for 'SELECT table.* ...' (it was translated by a 'SELECT * ...')

parent abc1c18b
No related branches found
No related tags found
No related merge requests found
......@@ -38,7 +38,7 @@ import adql.search.ISearchHandler;
* <p>The resulting object of the {@link ADQLParser} is an object of this class.</p>
*
* @author Gr&eacute;gory Mantelet (CDS;ARI)
* @version 1.2 (11/2013)
* @version 1.2 (09/2014)
*/
public class ADQLQuery implements ADQLObject {
......@@ -262,7 +262,12 @@ public class ADQLQuery implements ADQLObject {
ADQLOperand operand = item.getOperand();
if (item instanceof SelectAllColumns){
try{
columns.addAll(from.getDBColumns());
// If "{table}.*", add all columns of the specified table:
if (((SelectAllColumns)item).getAdqlTable() != null)
columns.addAll(((SelectAllColumns)item).getAdqlTable().getDBColumns());
// Otherwise ("*"), add all columns of all selected tables:
else
columns.addAll(from.getDBColumns());
}catch(ParseException pe){
// Here, this error should not occur any more, since it must have been caught by the DBChecker!
}
......
......@@ -20,15 +20,16 @@ import adql.query.from.ADQLTable;
* You should have received a copy of the GNU Lesser General Public License
* along with ADQLLibrary. If not, see <http://www.gnu.org/licenses/>.
*
* Copyright 2012 - UDS/Centre de Données astronomiques de Strasbourg (CDS)
* Copyright 2012,2014 - UDS/Centre de Données astronomiques de Strasbourg (CDS),
* Astronomisches Rechen Institut (ARI)
*/
/**
* In ADQL it corresponds to the '*' and '{tableName}.*' items in the SELECT clause.
* It means: 'select all columns'.
*
* @author Gr&eacute;gory Mantelet (CDS)
* @version 01/2012
* @author Gr&eacute;gory Mantelet (CDS;ARI)
* @version 1.2 (09/2014)
*/
public final class SelectAllColumns extends SelectItem {
......@@ -106,7 +107,7 @@ public final class SelectAllColumns extends SelectItem {
* @param table An {@link ADQLTable} (MUST NOT BE NULL).
*/
public final void setAdqlTable(final ADQLTable table){
if (table == null){
if (table != null){
adqlTable = table;
query = null;
}
......@@ -128,6 +129,7 @@ public final class SelectAllColumns extends SelectItem {
private boolean tableGot = (adqlTable == null);
@Override
public ADQLObject next() throws NoSuchElementException{
if (tableGot)
throw new NoSuchElementException();
......@@ -135,10 +137,12 @@ public final class SelectAllColumns extends SelectItem {
return adqlTable;
}
@Override
public boolean hasNext(){
return !tableGot;
}
@Override
public void replace(ADQLObject replacer) throws UnsupportedOperationException, IllegalStateException{
if (replacer == null)
remove();
......@@ -150,6 +154,7 @@ public final class SelectAllColumns extends SelectItem {
adqlTable = (ADQLTable)replacer;
}
@Override
public void remove(){
if (!tableGot)
throw new IllegalStateException("remove() impossible: next() has not yet been called !");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment