private static boolean isFunction(String lcToken, String nextToken, SQLFunctionRegistry functionRegistry) { // checking for "(" is currently redundant because it is checked before getting here; // doing the check anyhow, in case that earlier check goes away; if ( "(".equals( nextToken ) ) { return true; } SQLFunction function = functionRegistry.findSQLFunction(lcToken); if ( function == null ) { // lcToken does not refer to a function return false; } // if function.hasParenthesesIfNoArguments() is true, then assume // lcToken is not a function (since it is not followed by '(') return ! function.hasParenthesesIfNoArguments(); }
public boolean aggregateFuncNoArgsHasParenthesis(String funcToken, QueryTranslatorImpl q) { return getFunction( funcToken, q ).hasParenthesesIfNoArguments(); }
private String locateAppropriateDialectFunctionNameForAliasTest() { for (Iterator itr = getDialect().getFunctions().entrySet().iterator(); itr.hasNext(); ) { final Map.Entry entry = (Map.Entry) itr.next(); final SQLFunction function = (SQLFunction) entry.getValue(); if ( !function.hasArguments() && !function.hasParenthesesIfNoArguments() ) { return (String) entry.getKey(); } } return null; }
@SuppressWarnings( {"ForLoopReplaceableByForEach"}) private String locateAppropriateDialectFunctionNameForAliasTest() { for (Iterator itr = getDialect().getFunctions().entrySet().iterator(); itr.hasNext(); ) { final Map.Entry entry = (Map.Entry) itr.next(); final SQLFunction function = (SQLFunction) entry.getValue(); if ( !function.hasArguments() && !function.hasParenthesesIfNoArguments() ) { return (String) entry.getKey(); } } return null; }
@Override @SuppressWarnings("SimplifiableIfStatement") protected boolean isFunctionName(AST ast) { /* * Semantic predicate used to determine whether a given AST node represents a function call */ AST child = ast.getFirstChild(); // assume it is a function if it has parameters if ( child != null && "{param list}".equals( child.getText() ) ) { return true; } // otherwise, in order for this to be a function logically it has to be a function that does not // have arguments. So try to assert that using the registry of known functions final SQLFunction function = context.getSqlFunctionRegistry().findSQLFunction( ast.getText() ); if ( function == null ) { // no registered function, so we cannot know for certain return false; } else { // if function.hasParenthesesIfNoArguments() is true, then assume the node is not a function return !function.hasParenthesesIfNoArguments(); } }
@Test public void testNoArgFcnAndColumnSameNameAsNoArgFunctionHQL() { SQLFunction function = sessionFactory().getSqlFunctionRegistry().findSQLFunction( "current_date" ); if ( function == null || function.hasParenthesesIfNoArguments() ) { SkipLog.reportSkip( "current_date reuires ()", "tests noarg function that does not require ()" ); return;
@Test public void testGetMultiColumnSameNameAsNoArgFunctionHQL() throws Exception { SQLFunction function = sessionFactory().getSqlFunctionRegistry().findSQLFunction( "current_date" ); if ( function == null || function.hasParenthesesIfNoArguments() ) { SkipLog.reportSkip( "current_date reuires ()", "tests noarg function that does not require ()" ); return;
@Test public void testGetMultiColumnSameNameAsNoArgFunctionCriteria() { SQLFunction function = sessionFactory().getSqlFunctionRegistry().findSQLFunction( "current_date" ); if ( function == null || function.hasParenthesesIfNoArguments() ) { SkipLog.reportSkip( "current_date reuires ()", "tests noarg function that does not require ()" ); return;
@Override public boolean hasParenthesesIfNoArguments() { return function.hasParenthesesIfNoArguments(); }
public boolean aggregateFuncNoArgsHasParenthesis(String funcToken, QueryTranslatorImpl q) { return getFunction( funcToken, q ).hasParenthesesIfNoArguments(); }
public boolean aggregateFuncNoArgsHasParenthesis(String funcToken, QueryTranslatorImpl q) { return getFunction( funcToken, q ).hasParenthesesIfNoArguments(); }
public boolean aggregateFuncNoArgsHasParenthesis(String funcToken, QueryTranslatorImpl q) { return getFunction( funcToken, q ).hasParenthesesIfNoArguments(); }
public boolean aggregateFuncNoArgsHasParenthesis(String funcToken, QueryTranslatorImpl q) { return getFunction( funcToken, q ).hasParenthesesIfNoArguments(); }
private static boolean isFunction(String lcToken, String nextToken, SQLFunctionRegistry functionRegistry) { // checking for "(" is currently redundant because it is checked before getting here; // doing the check anyhow, in case that earlier check goes away; if ("(".equals(nextToken)) { return true; } SQLFunction function = functionRegistry.findSQLFunction(lcToken); if (function == null) { // lcToken does not refer to a function return false; } // if function.hasParenthesesIfNoArguments() is true, then assume // lcToken is not a function (since it is not followed by '(') return !function.hasParenthesesIfNoArguments(); }
private static boolean isFunction(String lcToken, String nextToken, SQLFunctionRegistry functionRegistry) { // checking for "(" is currently redundant because it is checked before getting here; // doing the check anyhow, in case that earlier check goes away; if ( "(".equals( nextToken ) ) { return true; } SQLFunction function = functionRegistry.findSQLFunction(lcToken); if ( function == null ) { // lcToken does not refer to a function return false; } // if function.hasParenthesesIfNoArguments() is true, then assume // lcToken is not a function (since it is not followed by '(') return ! function.hasParenthesesIfNoArguments(); }
private static boolean isFunction(String lcToken, String nextToken, SQLFunctionRegistry functionRegistry) { // checking for "(" is currently redundant because it is checked before getting here; // doing the check anyhow, in case that earlier check goes away; if ( "(".equals( nextToken ) ) { return true; } SQLFunction function = functionRegistry.findSQLFunction(lcToken); if ( function == null ) { // lcToken does not refer to a function return false; } // if function.hasParenthesesIfNoArguments() is true, then assume // lcToken is not a function (since it is not followed by '(') return ! function.hasParenthesesIfNoArguments(); }
/** * {@inheritDoc} */ @Override protected boolean isFunctionName(AST ast) { AST child = ast.getFirstChild(); // assume it is a function if it has parameters if ( child != null && "{param list}".equals( child.getText() ) ) { return true; } final SQLFunction function = context.getSqlFunctionRegistry().findSQLFunction( ast.getText() ); if ( function == null ) { return false; } // if function.hasParenthesesIfNoArguments() is true, then assume // ast.getText() is not a function. return ! function.hasParenthesesIfNoArguments(); }
/** * {@inheritDoc} */ @Override protected boolean isFunctionName(AST ast) { AST child = ast.getFirstChild(); // assume it is a function if it has parameters if ( child != null && "{param list}".equals( child.getText() ) ) { return true; } final SQLFunction function = context.getSqlFunctionRegistry().findSQLFunction( ast.getText() ); if ( function == null ) { return false; } // if function.hasParenthesesIfNoArguments() is true, then assume // ast.getText() is not a function. return ! function.hasParenthesesIfNoArguments(); }