Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ require (
github.com/dolthub/dolt/go/gen/proto/dolt/services/eventsapi v0.0.0-20241119094239-f4e529af734d
github.com/dolthub/flatbuffers/v23 v23.3.3-dh.2
github.com/dolthub/go-icu-regex v0.0.0-20241215010122-db690dd53c90
github.com/dolthub/go-mysql-server v0.19.1-0.20250226231726-5b478d49db8b
github.com/dolthub/go-mysql-server v0.19.1-0.20250226235211-28fdce58501a
github.com/dolthub/sqllogictest/go v0.0.0-20240618184124-ca47f9354216
github.com/dolthub/vitess v0.0.0-20250214225328-a0ed4612b41c
github.com/fatih/color v1.13.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,8 @@ github.com/dolthub/fslock v0.0.3 h1:iLMpUIvJKMKm92+N1fmHVdxJP5NdyDK5bK7z7Ba2s2U=
github.com/dolthub/fslock v0.0.3/go.mod h1:QWql+P17oAAMLnL4HGB5tiovtDuAjdDTPbuqx7bYfa0=
github.com/dolthub/go-icu-regex v0.0.0-20241215010122-db690dd53c90 h1:Sni8jrP0sy/w9ZYXoff4g/ixe+7bFCZlfCqXKJSU+zM=
github.com/dolthub/go-icu-regex v0.0.0-20241215010122-db690dd53c90/go.mod h1:ylU4XjUpsMcvl/BKeRRMXSH7e7WBrPXdSLvnRJYrxEA=
github.com/dolthub/go-mysql-server v0.19.1-0.20250226231726-5b478d49db8b h1:eS/NoWQad2p1WmEe8ZrX3bD0tPtCujuFguLAhiXAKLA=
github.com/dolthub/go-mysql-server v0.19.1-0.20250226231726-5b478d49db8b/go.mod h1:JTlrabhq5TJqvlL+J3NKlm0EzTHQQugUAH6yAxWi4Ww=
github.com/dolthub/go-mysql-server v0.19.1-0.20250226235211-28fdce58501a h1:qnfMeVatyiW+kB4ujX0QN8WxbqYtjmxLADX3ul3kvtA=
github.com/dolthub/go-mysql-server v0.19.1-0.20250226235211-28fdce58501a/go.mod h1:JTlrabhq5TJqvlL+J3NKlm0EzTHQQugUAH6yAxWi4Ww=
github.com/dolthub/gozstd v0.0.0-20240423170813-23a2903bca63 h1:OAsXLAPL4du6tfbBgK0xXHZkOlos63RdKYS3Sgw/dfI=
github.com/dolthub/gozstd v0.0.0-20240423170813-23a2903bca63/go.mod h1:lV7lUeuDhH5thVGDCKXbatwKy2KW80L4rMT46n+Y2/Q=
github.com/dolthub/ishell v0.0.0-20240701202509-2b217167d718 h1:lT7hE5k+0nkBdj/1UOSFwjWpNxf+LCApbRHgnCA17XE=
Expand Down
5 changes: 5 additions & 0 deletions postgres/parser/parser/sql/sql_parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package sql
import (
"context"
"fmt"
"strings"

"github.com/dolthub/doltgresql/postgres/parser/parser"
"github.com/dolthub/doltgresql/server/ast"
Expand Down Expand Up @@ -82,3 +83,7 @@ func (p *PostgresParser) ParseOneWithOptions(_ context.Context, query string, _
}
return vitessAST, 0, nil
}

func (p *PostgresParser) QuoteIdentifier(identifier string) string {
return fmt.Sprintf("\"%s\"", strings.ReplaceAll(identifier, "\"", "\"\""))
Comment thread
zachmu marked this conversation as resolved.
Outdated
}
26 changes: 26 additions & 0 deletions testing/go/alter_table_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,32 @@ func TestAlterTable(t *testing.T) {
},
},
},
{
Name: "Add primary key with generated column",
SetUpScript: []string{
`CREATE TABLE t1 (
id uuid DEFAULT public.gen_random_uuid() NOT NULL,
data jsonb,
has_data boolean GENERATED ALWAYS AS ((data IS NOT NULL)) STORED
);`,
},
Assertions: []ScriptTestAssertion{
{
Query: " ALTER TABLE ONLY t1 ADD CONSTRAINT pk PRIMARY KEY (id);",
SkipResultsCheck: true, // only care if it doesn't error
},
{
Query: "insert into t1 (id, data) values (default, '{}');",
SkipResultsCheck: true, // only care if it doesn't error
},
{
Query: "Select has_data from t1;",
Expected: []sql.Row{
{"t"},
},
},
},
},
{
Name: "Add Column",
SetUpScript: []string{
Expand Down
43 changes: 43 additions & 0 deletions testing/go/create_table_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,49 @@ func TestCreateTable(t *testing.T) {
},
},
},
{
Name: "generated column with reference to another column",
SetUpScript: []string{
`create table t1 (
a varchar(10) primary key,
b varchar(20),
b_not_null bool generated always as ((b is not null)) stored
);`,
"insert into t1 (a, b) values ('foo', 'bar');",
"insert into t1 (a) values ('foo2');",
},
Assertions: []ScriptTestAssertion{
{
Query: "select * from t1 order by a;",
Expected: []sql.Row{
{"foo", "bar", "t"},
{"foo2", nil, "f"},
},
},
},
},
{
Name: "generated column with reference to another column that needs quote",
Skip: true, // generated columns are not being properly quoted, this is a bug in GMS
SetUpScript: []string{
`create table t1 (
a varchar(10) primary key,
"b 2" varchar(20),
b_not_null bool generated always as (("b 2" is not null)) stored
);`,
`insert into t1 (a, "b 2") values ('foo', 'bar');`,
"insert into t1 (a) values ('foo2');",
},
Assertions: []ScriptTestAssertion{
{
Query: "select * from t1 order by a;",
Expected: []sql.Row{
{"foo", "bar", "t"},
{"foo2", nil, "f"},
},
},
},
},
{
Name: "create table with default value",
SetUpScript: []string{
Expand Down