TestPostgresQueryFormat is a utility function to test how postgres parses and formats queries
(t *testing.T)
| 2035 | |
| 2036 | // TestPostgresQueryFormat is a utility function to test how postgres parses and formats queries |
| 2037 | func TestPostgresQueryFormat(t *testing.T) { |
| 2038 | type test struct { |
| 2039 | input string |
| 2040 | expected string |
| 2041 | } |
| 2042 | tests := []test{ |
| 2043 | { |
| 2044 | input: "CREATE TABLE foo (a INT primary key default nextval('myseq'))", |
| 2045 | expected: "CREATE TABLE foo (a INTEGER DEFAULT nextval('myseq') PRIMARY KEY)", |
| 2046 | }, |
| 2047 | } |
| 2048 | |
| 2049 | for _, test := range tests { |
| 2050 | t.Run(test.input, func(t *testing.T) { |
| 2051 | s, err := parser.Parse(test.input) |
| 2052 | require.NoError(t, err) |
| 2053 | |
| 2054 | ctx := formatNodeWithUnqualifiedTableNames(s[0].AST) |
| 2055 | query := ctx.String() |
| 2056 | require.Equal(t, test.expected, query) |
| 2057 | }) |
| 2058 | } |
| 2059 | } |
| 2060 | |
| 2061 | func TestConvertQuery(t *testing.T) { |
| 2062 | type test struct { |
nothing calls this directly
no test coverage detected