-
Notifications
You must be signed in to change notification settings - Fork 213
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* [ADDED] Support for getting column identifiers from AliasExpressions. #203
- Loading branch information
1 parent
a8f0c36
commit 417f438
Showing
7 changed files
with
173 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package exp | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/suite" | ||
) | ||
|
||
type aliasExpressionSuite struct { | ||
suite.Suite | ||
} | ||
|
||
func TestAliasExpressionSuite(t *testing.T) { | ||
suite.Run(t, &aliasExpressionSuite{}) | ||
} | ||
|
||
func (aes *aliasExpressionSuite) TestClone() { | ||
ae := aliased(NewIdentifierExpression("", "", "col"), "c") | ||
aes.Equal(ae, ae.Clone()) | ||
} | ||
|
||
func (aes *aliasExpressionSuite) TestExpression() { | ||
ae := aliased(NewIdentifierExpression("", "", "col"), "c") | ||
aes.Equal(ae, ae.Expression()) | ||
} | ||
|
||
func (aes *aliasExpressionSuite) TestAliased() { | ||
ident := NewIdentifierExpression("", "", "col") | ||
ae := aliased(ident, "c") | ||
aes.Equal(ident, ae.Aliased()) | ||
} | ||
|
||
func (aes *aliasExpressionSuite) TestGetAs() { | ||
ae := aliased(NewIdentifierExpression("", "", "col"), "c") | ||
aes.Equal(NewIdentifierExpression("", "", "c"), ae.GetAs()) | ||
} | ||
|
||
func (aes *aliasExpressionSuite) TestSchema() { | ||
si := aliased( | ||
NewIdentifierExpression("", "t", nil), | ||
NewIdentifierExpression("", "t", nil), | ||
).Schema("s") | ||
aes.Equal(NewIdentifierExpression("s", "t", nil), si) | ||
} | ||
|
||
func (aes *aliasExpressionSuite) TestTable() { | ||
si := aliased( | ||
NewIdentifierExpression("schema", "", nil), | ||
NewIdentifierExpression("s", "", nil), | ||
).Table("t") | ||
aes.Equal(NewIdentifierExpression("s", "t", nil), si) | ||
} | ||
|
||
func (aes *aliasExpressionSuite) TestCol() { | ||
si := aliased( | ||
NewIdentifierExpression("", "table", nil), | ||
NewIdentifierExpression("", "t", nil), | ||
).Col("c") | ||
aes.Equal(NewIdentifierExpression("", "t", "c"), si) | ||
} | ||
|
||
func (aes *aliasExpressionSuite) TestAll() { | ||
si := aliased( | ||
NewIdentifierExpression("", "table", nil), | ||
NewIdentifierExpression("", "t", nil), | ||
).All() | ||
aes.Equal(NewIdentifierExpression("", "t", Star()), si) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters