com.yahoo.squidb.sql.Query.requestValidation()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(4.9k)|赞(0)|评价(0)|浏览(198)

本文整理了Java中com.yahoo.squidb.sql.Query.requestValidation方法的一些代码示例,展示了Query.requestValidation的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query.requestValidation方法的具体详情如下:
包路径:com.yahoo.squidb.sql.Query
类名称:Query
方法名:requestValidation

Query.requestValidation介绍

[英]Mark that this query should be checked for syntactic anomalies in the WHERE clause (e.g. if a raw selection was applied)
[中]标记该查询应在WHERE子句中检查语法异常(例如,如果应用了原始选择)

代码示例

代码示例来源:origin: yahoo/squidb

/**
 * Build a {@link Query} combining this object's internal state with the arguments passed. If a
 * {@link ProjectionMap} is set, the projection elements will be evaluated and transformed accordingly. If the
 * sortOrder is null or empty, the default order will be used (if one was set).
 *
 * @param projection the raw column names to be selected
 * @param selection a raw selection string
 * @param selectionArgs array of strings which substitute replaceable arguments in the selection string
 * @param sortOrder a raw ordering clause
 * @return a {@link Query} using the projection, selection, selection args, and sort order
 */
public Query build(String[] projection, String selection, String[] selectionArgs, String sortOrder) {
  Query query = Query.select(computeProjection(projection)).from(dataSource);
  boolean hasUserSelection = !SqlUtils.isEmpty(selection);
  if (hasUserSelection) {
    query.where(Criterion.fromRawSelection(selection, selectionArgs));
  }
  if (!SqlUtils.isEmpty(sortOrder)) {
    query.orderBy(Order.fromExpression(sortOrder));
  } else if (defaultOrder != null && defaultOrder.length > 0) {
    query.orderBy(defaultOrder);
  }
  if (strictMode && hasUserSelection) {
    query.requestValidation();
  }
  return query;
}

代码示例来源:origin: yahoo/squidb

@Override
  public void run() {
    try {
      blockThread.acquire();
      Query query2 = Query.select().from(subqueryTable);
      query2.requestValidation();
      SquidCursor<Thing> cursor = database.query(Thing.class, query2);
      cursor.close();
      blockCriterion.release();
    } catch (InterruptedException e) {
      fail("InterruptedException");
    }
  }
});

代码示例来源:origin: yahoo/squidb

query.requestValidation();

代码示例来源:origin: yahoo/squidb

public void testNeedsValidationUpdatedByQueryFunction() {
  Query subquery = Query.select(Function.max(Thing.ID)).from(Thing.TABLE).where(Criterion.literal(123));
  subquery.requestValidation();
  assertTrue(subquery.compile(database.getCompileContext()).sql.contains("WHERE (?)"));
  Query baseTestQuery = Query.select().from(Thing.TABLE).where(Thing.FOO.isNotEmpty()).freeze();
  assertFalse(baseTestQuery.needsValidation());
  Query testQuery = baseTestQuery.selectMore(subquery.asFunction());
  assertTrue(testQuery.compile(database.getCompileContext()).needsValidation);
  assertTrue(testQuery.sqlForValidation(database.getCompileContext()).contains("WHERE ((?))"));
}

代码示例来源:origin: yahoo/squidb

public void testNeedsValidationUpdatedBySubqueryTable() {
  Query subquery = Query.select(Thing.PROPERTIES).from(Thing.TABLE).where(Criterion.literal(123));
  subquery.requestValidation();
  assertTrue(subquery.compile(database.getCompileContext()).sql.contains("WHERE (?)"));
  Query baseTestQuery = Query.select().from(Thing.TABLE).where(Thing.FOO.isNotEmpty()).freeze();
  assertFalse(baseTestQuery.needsValidation());
  Query testQuery = baseTestQuery.from(subquery.as("t1"));
  assertTrue(testQuery.compile(database.getCompileContext()).needsValidation);
  assertTrue(testQuery.sqlForValidation(database.getCompileContext()).contains("WHERE ((?))"));
  testQuery = baseTestQuery.innerJoin(subquery.as("t2"), (Criterion[]) null);
  assertTrue(testQuery.compile(database.getCompileContext()).needsValidation);
  assertTrue(testQuery.sqlForValidation(database.getCompileContext()).contains("WHERE ((?))"));
  testQuery = baseTestQuery.union(subquery);
  assertTrue(testQuery.compile(database.getCompileContext()).needsValidation);
  assertTrue(testQuery.sqlForValidation(database.getCompileContext()).contains("WHERE ((?))"));
}

代码示例来源:origin: com.yahoo.squidb/squidb

/**
 * Build a {@link Query} combining this object's internal state with the arguments passed. If a
 * {@link ProjectionMap} is set, the projection elements will be evaluated and transformed accordingly. If the
 * sortOrder is null or empty, the default order will be used (if one was set).
 *
 * @param projection the raw column names to be selected
 * @param selection a raw selection string
 * @param selectionArgs array of strings which substitute replaceable arguments in the selection string
 * @param sortOrder a raw ordering clause
 * @return a {@link Query} using the projection, selection, selection args, and sort order
 */
public Query build(String[] projection, String selection, String[] selectionArgs, String sortOrder) {
  Query query = Query.select(computeProjection(projection)).from(dataSource);
  boolean hasUserSelection = !SqlUtils.isEmpty(selection);
  if (hasUserSelection) {
    query.where(Criterion.fromRawSelection(selection, selectionArgs));
  }
  if (!SqlUtils.isEmpty(sortOrder)) {
    query.orderBy(Order.fromExpression(sortOrder));
  } else if (defaultOrder != null && defaultOrder.length > 0) {
    query.orderBy(defaultOrder);
  }
  if (strictMode && hasUserSelection) {
    query.requestValidation();
  }
  return query;
}

相关文章