use of org.eclipse.scout.rt.server.jdbc.AbstractSqlService in project scout.rt by eclipse.
the class StatementProcessorTest method testLookupCall.
@Test
public void testLookupCall() throws Exception {
LookupCall call = new LookupCall() {
private static final long serialVersionUID = 1L;
};
//
AbstractSqlService sqlService = new AbstractSqlService() {
};
BeanInstanceUtil.initializeBeanInstance(sqlService);
StatementProcessor sp = new StatementProcessor(sqlService, "SELECT P.PERSON_NR,P.NAME" + " FROM PERSON P " + " WHERE P.PERSON_NR=:key " + " AND P.NAME like '%'||:text||'%'", new Object[] { call });
sp.simulate();
String sqlPlainTextDump = sp.createSqlDump(false, true);
assertFalse(sqlPlainTextDump.contains("UNPARSED"));
}
use of org.eclipse.scout.rt.server.jdbc.AbstractSqlService in project scout.rt by eclipse.
the class StatementProcessorTest method testIgnoreInvalidDuplicateBinds.
@Test
public void testIgnoreInvalidDuplicateBinds() {
AbstractSqlService sqlService = new AbstractSqlService() {
};
BeanInstanceUtil.initializeBeanInstance(sqlService);
// The abstract server session contains active but without a setter and is thus not a valid bind
// In this test, the NVPair active should be used and there should be no exception throw
StatementProcessor sp = new StatementProcessor(sqlService, "SELECT 1 FROM DUAL INTO :active ", new Object[] { new Session(), new NVPair("active", new IntegerHolder()) });
sp.simulate();
}
use of org.eclipse.scout.rt.server.jdbc.AbstractSqlService in project scout.rt by eclipse.
the class FunctionInput method produceSqlBindAndSetReplaceToken.
@Override
public SqlBind produceSqlBindAndSetReplaceToken(ISqlStyle sqlStyle) {
if (isBatch() || !m_valueSet) {
if (m_callerService instanceof AbstractSqlService) {
m_value = ((AbstractSqlService) m_callerService).callbackCustomBindFunction(m_target.getName(), m_target.getArgs(), m_bindBases);
} else {
throw new ProcessingException("don't know how to resolve custom bind function '" + m_target.getName() + "' on service " + m_callerService.getClass().getName());
}
m_valueSet = true;
}
Object value = null;
if (isBatch() && m_batchIndex >= 1) {
value = null;
} else {
value = m_value;
}
Class<?> nullType = null;
if (value instanceof IHolder<?>) {
IHolder h = (IHolder<?>) value;
value = h.getValue();
nullType = h.getHolderType();
}
//
if (m_target.isPlainToken()) {
m_target.setReplaceToken(m_target.getParsedToken());
return null;
} else if (m_target.isPlainValue()) {
m_target.setReplaceToken(sqlStyle.toPlainText(value));
return null;
} else if (m_target.isPlainSql()) {
m_target.setReplaceToken("" + value);
return null;
} else {
m_target.setReplaceToken("?");
return sqlStyle.buildBindFor(value, nullType);
}
}
use of org.eclipse.scout.rt.server.jdbc.AbstractSqlService in project scout.rt by eclipse.
the class StatementProcessorTest method exec.
private String[] exec(final boolean checkForDuplicateBinds, final String statement, final Object... binds) {
final Collection<String> duplicates = new ArrayList<>();
final AbstractSqlService sqlService = new AbstractSqlService() {
};
new StatementProcessor(sqlService, statement, binds) {
@Override
protected boolean isBindDuplicateCheckEnabled() {
return checkForDuplicateBinds;
}
@Override
protected void onDuplicateBind(IToken token) {
if (token instanceof ValueInputToken) {
duplicates.add(((ValueInputToken) token).getName());
} else if (token instanceof ValueOutputToken) {
duplicates.add(((ValueOutputToken) token).getName());
} else {
throw new ProcessingException("Unexpected token: {}", token);
}
}
}.simulate();
return duplicates.toArray(new String[duplicates.size()]);
}
use of org.eclipse.scout.rt.server.jdbc.AbstractSqlService in project scout.rt by eclipse.
the class StatementProcessorTest method testSelectLike.
@Test
public void testSelectLike() throws Exception {
AbstractSqlService sqlService = new AbstractSqlService() {
};
BeanInstanceUtil.initializeBeanInstance(sqlService);
StatementProcessor sp = new StatementProcessor(sqlService, "SELECT BP_NR FROM FLM_BP WHERE BP_NO LIKE :bpNo INTO :bpNr", new Object[] { new NVPair("bpNo", "12"), new NVPair("bpNr", new LongHolder()) });
sp.simulate();
String sqlPlainTextDump = sp.createSqlDump(false, true);
assertFalse(sqlPlainTextDump.contains("UNPARSED"));
}
Aggregations