MCPcopy Index your code
hub / github.com/pingcap/tidb / TestBuildPartitionClauses

Function TestBuildPartitionClauses

dumpling/export/sql_test.go:844–900  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

842}
843
844func TestBuildPartitionClauses(t *testing.T) {
845 const (
846 dbName = "test"
847 tbName = "t"
848 fields = "*"
849 partition = "p0"
850 where = "WHERE a > 10"
851 orderByClause = "ORDER BY a"
852 )
853 testCases := []struct {
854 partition string
855 where string
856 orderByClause string
857 expectedQuery string
858 }{
859 {
860 "",
861 "",
862 "",
863 "SELECT * FROM `test`.`t`",
864 },
865 {
866 partition,
867 "",
868 "",
869 "SELECT * FROM `test`.`t` PARTITION(`p0`)",
870 },
871 {
872 partition,
873 where,
874 "",
875 "SELECT * FROM `test`.`t` PARTITION(`p0`) WHERE a > 10",
876 },
877 {
878 partition,
879 "",
880 orderByClause,
881 "SELECT * FROM `test`.`t` PARTITION(`p0`) ORDER BY a",
882 },
883 {
884 partition,
885 where,
886 orderByClause,
887 "SELECT * FROM `test`.`t` PARTITION(`p0`) WHERE a > 10 ORDER BY a",
888 },
889 {
890 "",
891 where,
892 orderByClause,
893 "SELECT * FROM `test`.`t` WHERE a > 10 ORDER BY a",
894 },
895 }
896 for _, testCase := range testCases {
897 query := buildSelectQuery(dbName, tbName, fields, testCase.partition, testCase.where, testCase.orderByClause)
898 require.Equal(t, testCase.expectedQuery, query)
899 }
900}
901

Callers

nothing calls this directly

Calls 2

buildSelectQueryFunction · 0.85
EqualMethod · 0.65

Tested by

no test coverage detected