Skip to content

Commit

Permalink
LDEV-4867 remove debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
zspitzer committed Jul 2, 2024
1 parent 6acc9ae commit 1874e54
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 58 deletions.
27 changes: 6 additions & 21 deletions core/src/main/java/lucee/commons/lang/ParserString.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
package lucee.commons.lang;

import lucee.commons.io.SystemUtil;
import lucee.aprint;

/**
* Der CFMLString ist eine Hilfe fuer die Transformer, er repraesentiert den CFML Code und bietet
Expand Down Expand Up @@ -62,10 +61,10 @@ public ParserString(String text) {
}

/**
* Diesen Konstruktor kann er CFML Code als Zeichenkette uebergeben werden.
* This constructor allows stripping comments from SQL Text
*
* @param text CFML Code
* @param doIgnoreComments treat comments as space
* @param text SQL Text
* @param doIgnoreComments strip sql comments from text
*/
public ParserString(String text, boolean doIgnoreComments) {
init(text, doIgnoreComments);
Expand All @@ -78,7 +77,7 @@ public ParserString(String text, boolean doIgnoreComments) {
* @param str
*/
protected void init(String str, boolean doIgnoreComments) {
if (doIgnoreComments) str = stripComments(str);
if (doIgnoreComments) str = stripSqlComments(str);
int len = str.length();
text = new char[len];
lcText = new char[len];
Expand Down Expand Up @@ -712,31 +711,24 @@ public boolean removeSpace() {
}
return (start < pos);
}
/*
* MARK: stripcomment
*
*/
/**
* Strip out all sql comments
*
* @return SQL text with comments stripped out
*/
public String stripComments(String sql) {
public String stripSqlComments(String sql) {
char c;
int sqlLen = sql.length();
StringBuilder sb = new StringBuilder();

// aprint.out( "-----stripComments START---" );
// aprint.out( sql );

for (int i = 0; i < sqlLen; i++) {
c = sql.charAt(i);
if ( i < (sqlLen - 1)) {
// handle multi line comment
if (c == '/' && sql.charAt(i + 1) == '*') {
int end = sql.indexOf("*/", i + 2);
if (end != -1) {
i = end + 1; // TODO why 1 here, not 2?
i = end + 1;
continue;
}
}
Expand All @@ -752,14 +744,7 @@ public String stripComments(String sql) {
}
}
sb.append(c);
//aprint.out( "@" + i );
//aprint.out( sb.toString() );
}
/*
aprint.out( "" );
aprint.out( sb.toString() );
aprint.out( "-----stripComments END---" );
*/
return sb.toString().trim();
}

Expand Down
7 changes: 1 addition & 6 deletions core/src/main/java/lucee/runtime/db/HSQLDBHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@
import lucee.runtime.type.QueryImpl;
import lucee.runtime.type.dt.TimeSpan;
import lucee.runtime.type.util.CollectionUtil;
import lucee.aprint;

/**
* class to reexecute queries on the resultset object inside the cfml environment
Expand Down Expand Up @@ -268,18 +267,15 @@ public QueryImpl execute(PageContext pc, final SQL sql, int maxrows, int fetchsi
if (spe.getCause() != null && spe.getCause() instanceof IllegalQoQException) {
throw Caster.toPageException(spe);
}
aprint.out(spe);

prettySQL = SQLPrettyfier.prettyfie(sql.getSQLString(), true);
//aprint.out("---prettyfie----");
//aprint.out(prettySQL);

try {
QueryImpl query = executer.execute(pc, sql, prettySQL, maxrows);
query.setExecutionTime(stopwatch.time());
return query;
}
catch (Exception ex) {
aprint.out(ex);
}

}
Expand Down Expand Up @@ -345,7 +341,6 @@ public QueryImpl execute(PageContext pc, final SQL sql, int maxrows, int fetchsi

}
catch (ParseException e) {
aprint.out(sql);
throw new DatabaseException(e.getMessage(), null, sql, null);
}

Expand Down
8 changes: 2 additions & 6 deletions core/src/main/java/lucee/runtime/db/SQLImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,8 @@ public String toString() {
sb.append(c);
}
else if (!inQuotes && c == '?') {
if ((index + 1) > items.length){
//System.out.println( sb.toString() );
throw new RuntimeException("There are more question marks [" + (index+1)
+ "] in the SQL than params defined [" + items.length
+ "], in the SQL String: [" + strSQL + "]");
}
if ((index + 1) > items.length) throw new RuntimeException("There are more question marks [" + (index+1)
+ "] in the SQL than params defined [" + items.length + "], in the SQL String: [" + strSQL + "]");
if (items[index].isNulls()) sb.append("null");
else sb.append(SQLCaster.toString(items[index]));
index++;
Expand Down
13 changes: 2 additions & 11 deletions core/src/main/java/lucee/runtime/sql/SelectParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
import lucee.runtime.sql.exp.value.ValueNumber;
import lucee.runtime.sql.exp.value.ValueString;
import lucee.runtime.type.Collection.Key;
import lucee.aprint;

public class SelectParser {

Expand All @@ -63,14 +62,7 @@ public class SelectParser {
// select <select-statement> from <tables> where <where-statement>
public Selects parse(String sql) throws SQLParserException {
columnIndex = 0;
ParserString raw = new ParserString(sql.trim(), true);
/*
aprint.out("---select parser----");
aprint.out(sql);
aprint.out( "" );
aprint.out( raw.toString() );
aprint.out( "" );
*/
ParserString raw = new ParserString(sql.trim(),true);
Selects selects = new Selects();
Select select = new Select();

Expand Down Expand Up @@ -168,8 +160,7 @@ public Selects parse(String sql) throws SQLParserException {

if (raw.forwardIfCurrent(';')) raw.removeSpace();

if (!raw.isAfterLast())
throw new SQLParserException("Error parsing SQL statement (stop at char:" + raw.getCurrent() + ", pos: " + raw.getPos() + "), sql: [" + raw.toString() + "]");
if (!raw.isAfterLast()) throw new SQLParserException("Error parsing SQL statement (stop at char:" + raw.getCurrent() + ", pos: " + raw.getPos() + "), sql: [" + raw.toString() + "]");
return selects;
}

Expand Down
12 changes: 1 addition & 11 deletions core/src/main/java/lucee/runtime/tag/Query.java
Original file line number Diff line number Diff line change
Expand Up @@ -674,17 +674,7 @@ else if (data.cachedWithin == null) {
// cache not found, process and cache result if needed
if (queryResult == null) {
// QoQ
if ("parseonly".equals(data.dbtype)) { // used for testing the query parser, doens't execute
Struct sct = new StructImpl();
sct.setEL(KeyConstants._SQL, sqlQuery.getSQLString());
sct.setEL(KeyConstants._source, strSQL);
if (setVars){
if (!StringUtil.isEmpty(data.result)) pageContext.setVariable(data.result, sct);
else if (!StringUtil.isEmpty(data.name)) pageContext.setVariable(data.name, sct);
}
return EVAL_PAGE;
}
else if ("query".equals(data.dbtype)) {
if ("query".equals(data.dbtype)) {
QueryImpl q = executeQoQ(pageContext, data, sqlQuery, tl);
q.setTemplateLine(tl);
if (data.returntype == RETURN_TYPE_ARRAY) queryResult = QueryArray.toQueryArray(q); // TODO this should be done in queryExecute
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public static Struct toStruct(SQLItem item, boolean fns) {
NamedSQLItem nsi = (NamedSQLItem) item;
sct.setEL(KeyConstants._name, nsi.getName());
}
if (fns || item.getValue() != null) sct.setEL(KeyConstants._value, item.getValue() );
if (fns || item.getValue() != null) sct.setEL(KeyConstants._value, item.getValue());
else sct.setEL(KeyConstants._value, "");
sct.setEL(KeyConstants._type, SQLCaster.toStringType(item.getType(), null));
sct.setEL(KeyConstants._scale, item.getScale());
Expand Down Expand Up @@ -167,7 +167,6 @@ private static SQL convert(String sql, List<SQLItems<SQLItem>> items, List<SQLIt
sb.append(sql.substring(i, end+1));
i = end;
continue;
//else break;
}
}

Expand Down
2 changes: 1 addition & 1 deletion test/tickets/LDEV2754.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ component extends = "org.lucee.cfml.test.LuceeTestCase" labels="query" {
expect(result.filecontent).tobe("juwait");
});

it(title = "Using (') with QoQ", body = function( currentSpec ){
it(title = "Using (') with QoQ", skip=noMssql(), body = function( currentSpec ){
local.result = _InternalRequest(
template : "#uri#\test.cfm",
forms : { scene = 3 }
Expand Down

0 comments on commit 1874e54

Please sign in to comment.