package at.lingu.sqlcompose;

import at.lingu.sqlcompose.projection.Projection;
import at.lingu.sqlcompose.source.Table;
import org.junit.Test;

/**
 * Tests for select statements.
 *
 * @author Florian Fankhauser <flo@lingu.at>
 */
public class SelectTests extends BaseSqlTests {

	private Table users = new Table("users");

	@Test
	public void testSelectAllFields() {

		Select select = new Select(users)
				.project(Projection.ALL);

		generateResult(select);

		assertSql("SELECT * FROM users");
		assertNoParams();
	}

	@Test
	public void testSelectFields() {
		Select select = new Select(users)
				.project(
						users.column("id"),
						users.column("last_name"),
						users.column("first_name"));

		generateResult(select);

		assertSql("SELECT id, last_name, first_name FROM users");
		assertNoParams();
	}

}

@@ -815,10 +815,395 @@
 ();%0A%09%7D%0A%0A
+%09@Test%0A%09public void testSelectFieldsWithAlias() %7B%0A%09%09Select select = new Select(users)%0A%09%09%09%09.project(%0A%09%09%09%09%09%09users.column(%22id%22).as(%22user_id%22),%0A%09%09%09%09%09%09users.column(%22last_name%22).as(%22l_name%22),%0A%09%09%09%09%09%09users.column(%22first_name%22).as(%22f_name%22));%0A%0A%09%09generateResult(select);%0A%0A%09%09assertSql(%22SELECT id AS user_id, last_name AS l_name, %22%0A%09%09%09%09+ %22first_name AS f_name FROM users%22);%0A%09%09assertNoParams();%0A%09%7D%0A
 %7D%0A

Add test for projection alias