Skip to content

Commit

Permalink
Merge pull request #52 from sanaullah/BL-224
Browse files Browse the repository at this point in the history
BL-224
  • Loading branch information
lmajano authored Jun 7, 2024
2 parents 3d7278c + 2964c84 commit 56ba6b5
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/main/java/ortus/boxlang/runtime/types/Query.java
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ public boolean hasColumn( Key name ) {

/**
* Get the data for this query
* This method is really only for debugging and the underlying List you get will not be syncronized with the query.
* This method is really only for debugging and the underlying List you get will not be synchronized with the query.
*
* @return list of arrays of data
*/
Expand Down Expand Up @@ -216,7 +216,7 @@ public synchronized Query addColumn( Key name, QueryColumnType type, Object[] co
}
}
columns.put( name, new QueryColumn( name, type, this, newColIndex ) );
if ( data.size() > 0 ) {
if ( !data.isEmpty() ) {
// loop over data and replace each array with a new array having an additional null at the end
for ( int i = 0; i < data.size(); i++ ) {
Object[] row = data.get( i );
Expand All @@ -229,9 +229,9 @@ public synchronized Query addColumn( Key name, QueryColumnType type, Object[] co
}
} else if ( columnData != null ) {
// loop over column data and add that many rows with an array as big as their are columns
for ( int i = 0; i < columnData.length; i++ ) {
for ( Object columnDatum : columnData ) {
Object[] row = new Object[ columns.size() ];
row[ newColIndex ] = columnData[ i ];
row[ newColIndex ] = columnDatum;
data.add( row );
}
}
Expand Down Expand Up @@ -384,8 +384,7 @@ public int addRow( IStruct row ) {
public int addRows( int rows ) {
int lastRow = 0;
for ( int i = 0; i < rows; i++ ) {
Object[] rowData = new Object[ columns.size() ];
lastRow = addRow( rowData );
lastRow = addRow( ( Object[] ) new Object[ columns.size() ] );
}
return lastRow;
}
Expand Down Expand Up @@ -438,12 +437,12 @@ public int addData( Object rowData ) {
CastAttempt<Array> arrayCastAttempt = ArrayCaster.attempt( rowData );
if ( arrayCastAttempt.wasSuccessful() ) {
Array arrData = arrayCastAttempt.get();
if ( arrData.size() == 0 ) {
if ( arrData.isEmpty() ) {
return 0;
}
// Test the first row to see if we have an array of arrays or an array of structs
Boolean isArray = ArrayCaster.attempt( arrData.get( 0 ) ).wasSuccessful();
Boolean isStruct = StructCaster.attempt( arrData.get( 0 ) ).wasSuccessful();
Boolean isArray = ArrayCaster.attempt( arrData.getFirst() ).wasSuccessful();
Boolean isStruct = StructCaster.attempt( arrData.getFirst() ).wasSuccessful();
if ( isArray || isStruct ) {
int lastRow = 0;
for ( Object row : arrData ) {
Expand Down Expand Up @@ -595,6 +594,7 @@ public boolean contains( Object o ) {
@Override
public Iterator<IStruct> iterator() {
// TODO: Thread safe?

return new Iterator<IStruct>() {

private int index = 0;
Expand Down

0 comments on commit 56ba6b5

Please sign in to comment.