Add ColumnAs for 'SELECT col AS name' queries. (#24)

Add As helper for 'SELECT col AS name' queries

Clients could do this hackily before by manually passing "col AS name",
but it isn't clearly supported.
This commit is contained in:
Josh Giles
2017-12-15 03:53:37 -05:00
committed by Michał Matczuk
parent 439bce4bdc
commit 6051038fa5
2 changed files with 10 additions and 0 deletions

View File

@@ -28,6 +28,11 @@ func TestSelectBuilder(t *testing.T) {
B: Select("cycling.cyclist_name").Columns("id", "user_uuid", "firstname"),
S: "SELECT id,user_uuid,firstname FROM cycling.cyclist_name ",
},
// Add a SELECT AS column
{
B: Select("cycling.cyclist_name").Columns("id", "user_uuid", As("firstname", "name")),
S: "SELECT id,user_uuid,firstname AS name FROM cycling.cyclist_name ",
},
// Basic test for select distinct
{
B: Select("cycling.cyclist_name").Distinct("id"),