/**
* Create join "USING" clause.
* <p>
* Each of the columns specified must exist in the datasets to both the left and right
* of the join-operator. For each pair of columns, the expression "lhs.X = rhs.X"
* is evaluated for each row of the cartesian product as a boolean expression.
* Only rows for which all such expressions evaluates to true are included from the
* result set. When comparing values as a result of a USING clause, the normal rules
* for handling affinities, collation sequences and NULL values in comparisons apply.
* The column from the dataset on the left-hand side of the join-operator is considered
* to be on the left-hand side of the comparison operator (=) for the purposes of
* collation sequence and affinity precedence.
* <p>
* For each pair of columns identified by a USING clause, the column from the
* right-hand dataset is omitted from the joined dataset. This is the only difference
* between a USING clause and its equivalent ON constraint.
*
* @param columns
* Columns to use in the USING clause
* @return Join clause
*/
@NonNull
@CheckResult
public final JoinClause using(@NonNull @Size(min = 1) final Column... columns) {
final int colLen = columns.length;
final StringBuilder sb = new StringBuilder(8 + colLen * 12);
sb.append("USING (");
for (int i = 0; i < colLen; i++) {
if (i > 0) {
sb.append(',');
}
sb.append(columns[i].name);
}
sb.append(')');
return new JoinClause(this, "", sb.toString()) {
@Override
boolean containsColumn(@NonNull Column<?, ?, ?, ?, ?> column) {
for (int i = 0; i < colLen; i++) {
if (columns[i].equals(column)) {
return true;
}
}
return false;
}
};
}
Table.java 文件源码
java
阅读 65
收藏 0
点赞 0
评论 0
项目:sqlitemagic
作者:
评论列表
文章目录