MCPcopy Create free account
hub / github.com/dolthub/doltgresql / TestPostgresQueryFormat

Function TestPostgresQueryFormat

testing/go/enginetest/query_converter_test.go:2037–2059  ·  view source on GitHub ↗

TestPostgresQueryFormat is a utility function to test how postgres parses and formats queries

(t *testing.T)

Source from the content-addressed store, hash-verified

2035
2036// TestPostgresQueryFormat is a utility function to test how postgres parses and formats queries
2037func 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
2061func TestConvertQuery(t *testing.T) {
2062 type test struct {

Callers

nothing calls this directly

Calls 5

ParseFunction · 0.92
RunMethod · 0.80
StringMethod · 0.65
EqualMethod · 0.45

Tested by

no test coverage detected