Skip to content

Commit 078b10c

Browse files
committed
Formatting and tests
1 parent ac100d7 commit 078b10c

File tree

5 files changed

+28
-10
lines changed

5 files changed

+28
-10
lines changed

server/analyzer/init.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ const (
3737
ruleId_ResolveType // resolveType
3838
ruleId_ReplaceArithmeticExpressions // replaceArithmeticExpressions
3939
ruleId_OptimizeFunctions // optimizeFunctions
40-
ruleId_ValidateColumnDefaults // validateColumnDefaults
40+
ruleId_ValidateColumnDefaults // validateColumnDefaults
4141
)
4242

4343
// Init adds additional rules to the analyzer to handle Doltgres-specific functionality.

server/analyzer/validate_column_defaults.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,13 @@
1515
package analyzer
1616

1717
import (
18-
pgnode "github.com/dolthub/doltgresql/server/node"
1918
"github.com/dolthub/go-mysql-server/sql"
2019
"github.com/dolthub/go-mysql-server/sql/analyzer"
2120
"github.com/dolthub/go-mysql-server/sql/expression"
2221
"github.com/dolthub/go-mysql-server/sql/plan"
2322
"github.com/dolthub/go-mysql-server/sql/transform"
23+
24+
pgnode "github.com/dolthub/doltgresql/server/node"
2425
)
2526

2627
// validateColumnDefaults ensures that newly created column defaults from a DDL statement are legal for the type of
@@ -198,4 +199,4 @@ func getResolvedTable(node sql.Node) *plan.ResolvedTable {
198199
return true
199200
})
200201
return table
201-
}
202+
}

server/functions/gen_random_uuid.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,11 @@
1515
package functions
1616

1717
import (
18+
"github.com/dolthub/go-mysql-server/sql"
19+
1820
"github.com/dolthub/doltgresql/postgres/parser/uuid"
1921
"github.com/dolthub/doltgresql/server/functions/framework"
2022
pgtypes "github.com/dolthub/doltgresql/server/types"
21-
"github.com/dolthub/go-mysql-server/sql"
2223
)
2324

2425
// initRadians registers the functions to the catalog.
@@ -27,9 +28,9 @@ func initGenRandomUuid() {
2728
}
2829

2930
var gen_random_uuid = framework.Function0{
30-
Name: "gen_random_uuid",
31-
Return: pgtypes.Uuid,
32-
Strict: true,
31+
Name: "gen_random_uuid",
32+
Return: pgtypes.Uuid,
33+
Strict: true,
3334
Callable: func(ctx *sql.Context) (any, error) {
3435
return uuid.NewV4()
3536
},

server/node/create_table.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,8 @@ func (c CreateTable) WithTargetSchema(schema sql.Schema) (sql.Node, error) {
112112
if err != nil {
113113
return nil, err
114114
}
115-
115+
116116
c.gmsCreateTable = n.(*plan.CreateTable)
117-
117+
118118
return &c, nil
119119
}

testing/go/alter_table_test.go

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,12 +437,24 @@ func TestAlterTable(t *testing.T) {
437437
created_at timestamp with time zone DEFAULT now() NOT NULL,
438438
updated_at timestamp with time zone DEFAULT now() NOT NULL
439439
);`,
440-
"INSERT INTO t1 (id, uid) VALUES (1, '00000000-0000-0000-0000-000000000001');",
440+
"INSERT INTO t1 (id, uid) VALUES (1, '00000000-0000-0000-0000-000000000001');",
441441
},
442442
Assertions: []ScriptTestAssertion{
443443
{
444444
Query: "ALTER TABLE ONLY public.t1 ADD CONSTRAINT t1_pkey PRIMARY KEY (id);",
445445
},
446+
{
447+
Query: "select created_at is not null from t1 where id = 1;",
448+
Expected: []sql.Row{{"t"}},
449+
},
450+
{
451+
Query: "select updated_at is not null from t1 where id = 1;",
452+
Expected: []sql.Row{{"t"}},
453+
},
454+
{
455+
Query: "select created_at = updated_at from t1 where id = 1;",
456+
Expected: []sql.Row{{"t"}},
457+
},
446458
},
447459
},
448460
{
@@ -458,6 +470,10 @@ func TestAlterTable(t *testing.T) {
458470
{
459471
Query: "ALTER TABLE ONLY public.t1 ADD CONSTRAINT t1_pkey PRIMARY KEY (id);",
460472
},
473+
{
474+
Query: "select uid is not null from t1 where id = 1;",
475+
Expected: []sql.Row{{"t"}},
476+
},
461477
},
462478
},
463479
})

0 commit comments

Comments
 (0)