@Override public void visit(Selector selector) { if (notFound.get() && selector.getAliasOrName().equals(name)) { notFound.set(false); } } });
if (selector.hasAlias()) selectorPlan.addSelector(selector.getAlias()); selectorPlan.setAlias(selector.getAlias()); selectorPlan.setName(selector.getName()); selectorPlan.addSelector(selector.getName()); selectorPlan.setName(selector.getName()); Table table = context.getSchema().getTable(selector.getName()); if (table != null) if (querySelectorsMap.put(selector.getAliasOrName(), table) != null) new TableDoesntExistException("Table " + selector.getName() + " doesn't exist"));
/** * Specify the name of the table from which tuples should be selected. The * supplied string is of the form " <code>tableName [AS alias]</code>". * * @param tableNameWithOptionalAlias * the name of the table, optionally including the alias * @return this builder object, for convenience in method chaining */ public QueryBuilder from(String tableNameWithOptionalAlias) { Selector selector = namedSelector(tableNameWithOptionalAlias); SelectorName oldName = this.source instanceof Selector ? ((Selector)source).getName() : null; // Go through the columns and change the selector name to use the new // alias ... for (int i = 0; i != columns.size(); ++i) { Column old = columns.get(i); if (old.getSelectorName().equals(oldName)) { columns.set(i, new Column(selector.getAliasOrName(), old.getPropertyName(), old.getColumnName())); } } this.source = selector; return this; }
/** * Convenience method that creates a {@link Selector} object given a string * that contains the selector name and optionally an alias. The format of the * string parameter is <code>name [AS alias]</code>. Leading and trailing * whitespace are trimmed. * * @param nameWithOptionalAlias * the name and optional alias; may not be null * @return the named selector object; never null */ protected Selector namedSelector(String nameWithOptionalAlias) { String[] parts = nameWithOptionalAlias.split("\\sAS\\s"); if (parts.length == 2) { return new Selector(selector(parts[0]), selector(parts[1])); } return new Selector(selector(parts[0])); }
/** * Utility method that does all the work of the clear, but with a flag that * defines whether to clear the first query. This method is used by * {@link #clear()} as well as the {@link #union() many} {@link #intersect() * set} {@link #except() operations}. * * @param clearFirstQuery * true if the first query should be cleared, or false if the first * query should be retained * @return this builder object, for convenience in method chaining */ protected QueryBuilder clear(boolean clearFirstQuery) { source = new Selector(new SelectorName("__not:defined__")); constraint = null; columns = new LinkedList<Column>(); orderings = new LinkedList<Ordering>(); limit = Limit.NONE; distinct = false; if (clearFirstQuery) { this.firstQuery = null; } return this; }
sname = registerQueryName(tname); res = new Selector(tname, sname);
if (rightSource.getAliasOrName().equals(name))