@Test
  public void testUpdateTableAlias() throws Exception {
    UpdateAnalyzedStatement.NestedAnalyzedStatement expectedAnalysis =
        analyze("update users set awesome=true where awesome=false").nestedStatements().get(0);
    UpdateAnalyzedStatement.NestedAnalyzedStatement actualAnalysis =
        analyze("update users as u set awesome=true where awesome=false").nestedStatements().get(0);

    assertEquals(expectedAnalysis.assignments(), actualAnalysis.assignments());
    assertEquals(
        ((Function) expectedAnalysis.whereClause().query()).arguments().get(0),
        ((Function) actualAnalysis.whereClause().query()).arguments().get(0));
  }
 @Test
 public void testUpdateWhereClause() throws Exception {
   UpdateAnalyzedStatement.NestedAnalyzedStatement analysis =
       analyze("update users set other_id=9 where name='Trillian'").nestedStatements().get(0);
   assertThat(analysis.whereClause().hasQuery(), is(true));
   assertThat(analysis.whereClause().noMatch(), is(false));
 }
  @Test
  public void testUpdateWithParameter() throws Exception {
    Map[] friends =
        new Map[] {
          new HashMap<String, Object>() {
            {
              put("name", "Slartibartfast");
            }
          },
          new HashMap<String, Object>() {
            {
              put("name", "Marvin");
            }
          }
        };
    UpdateAnalyzedStatement.NestedAnalyzedStatement analysis =
        analyze(
                "update users set name=?, other_id=?, friends=? where id=?",
                new Object[] {"Jeltz", 0, friends, "9"})
            .nestedStatements()
            .get(0);
    assertThat(analysis.assignments().size(), is(3));
    assertThat(
        analysis
            .assignments()
            .get(new Reference(USER_TABLE_INFO.getReferenceInfo(new ColumnIdent("name")))),
        isLiteral("Jeltz"));
    assertThat(
        analysis
            .assignments()
            .get(new Reference(USER_TABLE_INFO.getReferenceInfo(new ColumnIdent("friends")))),
        isLiteral(friends, new ArrayType(DataTypes.OBJECT)));
    assertThat(
        analysis
            .assignments()
            .get(new Reference(USER_TABLE_INFO.getReferenceInfo(new ColumnIdent("other_id")))),
        isLiteral(0L));

    assertThat(((Function) analysis.whereClause().query()).arguments().get(1), isLiteral(9L));
  }
 @Test
 public void testNoMatchWhereClause() throws Exception {
   UpdateAnalyzedStatement.NestedAnalyzedStatement analysis =
       analyze("update users set other_id=9 where true=false").nestedStatements().get(0);
   assertThat(analysis.whereClause().noMatch(), is(true));
 }
 @Test
 public void testNoWhereClause() throws Exception {
   UpdateAnalyzedStatement.NestedAnalyzedStatement analysis =
       analyze("update users set other_id=9").nestedStatements().get(0);
   assertThat(analysis.whereClause(), is(WhereClause.MATCH_ALL));
 }