Package org.teiid.language

Examples of org.teiid.language.Select


    }   

  private static TranslationUtility translationUtility = new TranslationUtility(exampleSalesforce());

  @Test public void testOr() throws Exception {
    Select command = (Select)translationUtility.parseCommand("select * from Account where Name = 'foo' or Stuff = 'bar'"); //$NON-NLS-1$
    SelectVisitor visitor = new SelectVisitor(translationUtility.createRuntimeMetadata());
    visitor.visit(command);
    assertEquals("SELECT Account.id, Account.AccountName, Account.Stuff, Account.Industry FROM Account WHERE (Account.AccountName = 'foo') OR (Account.Stuff = 'bar')", visitor.getQuery().toString().trim()); //$NON-NLS-1$
  }
View Full Code Here


    visitor.visit(command);
    assertEquals("SELECT Account.id, Account.AccountName, Account.Stuff, Account.Industry FROM Account WHERE (Account.AccountName = 'foo') OR (Account.Stuff = 'bar')", visitor.getQuery().toString().trim()); //$NON-NLS-1$
  }
 
  @Test public void testNot() throws Exception {
    Select command = (Select)translationUtility.parseCommand("select * from Account where not (Name = 'foo' and Stuff = 'bar')"); //$NON-NLS-1$
    SelectVisitor visitor = new SelectVisitor(translationUtility.createRuntimeMetadata());
    visitor.visit(command);
    assertEquals("SELECT Account.id, Account.AccountName, Account.Stuff, Account.Industry FROM Account WHERE (Account.AccountName != 'foo') OR (Account.Stuff != 'bar')", visitor.getQuery().toString().trim()); //$NON-NLS-1$
  }
View Full Code Here

    visitor.visit(command);
    assertEquals("SELECT Account.id, Account.AccountName, Account.Stuff, Account.Industry FROM Account WHERE (Account.AccountName != 'foo') OR (Account.Stuff != 'bar')", visitor.getQuery().toString().trim()); //$NON-NLS-1$
  }
 
  @Test public void testCountStart() throws Exception {
    Select command = (Select)translationUtility.parseCommand("select count(*) from Account"); //$NON-NLS-1$
    SelectVisitor visitor = new SelectVisitor(translationUtility.createRuntimeMetadata());
    visitor.visit(command);
    assertEquals("SELECT count() FROM Account", visitor.getQuery().toString().trim()); //$NON-NLS-1$
  }
View Full Code Here

    visitor.visit(command);
    assertEquals("SELECT count() FROM Account", visitor.getQuery().toString().trim()); //$NON-NLS-1$
  }
 
  @Test public void testNotLike() throws Exception {
    Select command = (Select)translationUtility.parseCommand("select * from Account where Name not like '%foo' or Stuff = 'bar'"); //$NON-NLS-1$
    SelectVisitor visitor = new SelectVisitor(translationUtility.createRuntimeMetadata());
    visitor.visit(command);
    assertEquals("SELECT Account.id, Account.AccountName, Account.Stuff, Account.Industry FROM Account WHERE (NOT (Account.AccountName LIKE '%foo')) OR (Account.Stuff = 'bar')", visitor.getQuery().toString().trim()); //$NON-NLS-1$
  }
View Full Code Here

    assertEquals("SELECT Account.id, Account.AccountName, Account.Stuff, Account.Industry FROM Account WHERE (NOT (Account.AccountName LIKE '%foo')) OR (Account.Stuff = 'bar')", visitor.getQuery().toString().trim()); //$NON-NLS-1$
  }

 
  @Test public void testIN() throws Exception {
    Select command = (Select)translationUtility.parseCommand("select * from Account where Industry IN (1,2,3)"); //$NON-NLS-1$
    SelectVisitor visitor = new SelectVisitor(translationUtility.createRuntimeMetadata());
    visitor.visit(command);
    assertFalse(visitor.hasOnlyIDCriteria());
    assertEquals("SELECT Account.id, Account.AccountName, Account.Stuff, Account.Industry FROM Account WHERE Industry IN('1','2','3')", visitor.getQuery().toString().trim()); //$NON-NLS-1$
   
View Full Code Here

   
  }

  @Test public void testOnlyIDsIN() throws Exception {
    // this can resolve to a better performing retrieve call
    Select command = (Select)translationUtility.parseCommand("select * from Account where ID IN (1,2,3)"); //$NON-NLS-1$
    SelectVisitor visitor = new SelectVisitor(translationUtility.createRuntimeMetadata());
    visitor.visit(command);
    assertTrue(visitor.hasOnlyIdInCriteria());
    assertEquals("Account", visitor.getTableName());
    assertEquals("Account.id, Account.AccountName, Account.Stuff, Account.Industry", visitor.getRetrieveFieldList());
View Full Code Here

    assertEquals("Account.id, Account.AccountName, Account.Stuff, Account.Industry", visitor.getRetrieveFieldList());
    assertEquals(Arrays.asList(new String[]{"1", "2", "3"}), visitor.getIdInCriteria())
  }
 
  @Test public void testJoin() throws Exception {
    Select command = (Select)translationUtility.parseCommand("SELECT Account.Name, Contacts.Name FROM Contacts LEFT OUTER JOIN Account ON Account.Id = Contacts.AccountId"); //$NON-NLS-1$
    SelectVisitor visitor = new JoinQueryVisitor(translationUtility.createRuntimeMetadata());
    visitor.visit(command);
    assertEquals("SELECT Account.AccountName, Contact.ContactName FROM Contact", visitor.getQuery().toString().trim()); //$NON-NLS-1$
  }
View Full Code Here

    visitor.visit(command);
    assertEquals("SELECT Account.AccountName, Contact.ContactName FROM Contact", visitor.getQuery().toString().trim()); //$NON-NLS-1$
  }
 
  @Test public void testJoin2() throws Exception {
    Select command = (Select)translationUtility.parseCommand("SELECT Account.Name, Contacts.Name FROM Account LEFT OUTER JOIN Contacts ON Account.Id = Contacts.AccountId"); //$NON-NLS-1$
    SelectVisitor visitor = new JoinQueryVisitor(translationUtility.createRuntimeMetadata());
    visitor.visit(command);
    assertEquals("SELECT Account.AccountName, (SELECT Contact.ContactName FROM Contacts) FROM Account", visitor.getQuery().toString().trim()); //$NON-NLS-1$
  }
View Full Code Here

    visitor.visit(command);
    assertEquals("SELECT Account.AccountName, (SELECT Contact.ContactName FROM Contacts) FROM Account", visitor.getQuery().toString().trim()); //$NON-NLS-1$
  }
 
  @Test public void testJoin3() throws Exception {
    Select command = (Select)translationUtility.parseCommand("SELECT Contacts.Name FROM Account LEFT OUTER JOIN Contacts ON Account.Id = Contacts.AccountId"); //$NON-NLS-1$
    SelectVisitor visitor = new JoinQueryVisitor(translationUtility.createRuntimeMetadata());
    visitor.visit(command);
    assertEquals("SELECT (SELECT Contact.ContactName FROM Contacts) FROM Account", visitor.getQuery().toString().trim()); //$NON-NLS-1$
  }
View Full Code Here

    visitor.visit(command);
    assertEquals("SELECT (SELECT Contact.ContactName FROM Contacts) FROM Account", visitor.getQuery().toString().trim()); //$NON-NLS-1$
  }
 
  @Test public void testInWithNameInSourceDifferent() throws Exception {
    Select command = (Select)translationUtility.parseCommand("SELECT Contacts.Name FROM Contacts WHERE Contacts.Name in ('x', 'y')"); //$NON-NLS-1$
    SelectVisitor visitor = new SelectVisitor(translationUtility.createRuntimeMetadata());
    visitor.visit(command);
    assertEquals("SELECT Contact.ContactName FROM Contact WHERE ContactName IN('x','y')", visitor.getQuery().toString().trim()); //$NON-NLS-1$
  }
View Full Code Here

TOP

Related Classes of org.teiid.language.Select

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.