Skip to content

Commit a83184b

Browse files
authored
Remove the deprecated mysql package (#793)
* mysql: Make dolphin the default, remove mysql:beta * tests: s/mysql:beta/mysql/g * Remove the deprecated MySQL package
1 parent 0715169 commit a83184b

File tree

101 files changed

+106
-1338
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

101 files changed

+106
-1338
lines changed

examples/authors/sqlc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
{
1616
"schema": "mysql/schema.sql",
1717
"queries": "mysql/query.sql",
18-
"engine": "mysql:beta",
18+
"engine": "mysql",
1919
"gen": {
2020
"go": {
2121
"package": "authors",

examples/booktest/sqlc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"path": "mysql",
1414
"schema": "mysql/schema.sql",
1515
"queries": "mysql/query.sql",
16-
"engine": "mysql:beta"
16+
"engine": "mysql"
1717
}
1818
]
1919
}

examples/kotlin/sqlc.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
{
4949
"schema": "src/main/resources/authors/mysql/schema.sql",
5050
"queries": "src/main/resources/authors/mysql/query.sql",
51-
"engine": "mysql:beta",
51+
"engine": "mysql",
5252
"gen": {
5353
"kotlin": {
5454
"out": "src/main/kotlin/com/example/authors/mysql",
@@ -59,7 +59,7 @@
5959
{
6060
"schema": "src/main/resources/booktest/mysql/schema.sql",
6161
"queries": "src/main/resources/booktest/mysql/query.sql",
62-
"engine": "mysql:beta",
62+
"engine": "mysql",
6363
"gen": {
6464
"kotlin": {
6565
"out": "src/main/kotlin/com/example/booktest/mysql",
@@ -70,7 +70,7 @@
7070
{
7171
"schema": "src/main/resources/ondeck/mysql/schema",
7272
"queries": "src/main/resources/ondeck/mysql/query",
73-
"engine": "mysql:beta",
73+
"engine": "mysql",
7474
"gen": {
7575
"kotlin": {
7676
"out": "src/main/kotlin/com/example/ondeck/mysql",

examples/ondeck/sqlc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"name": "ondeck",
1717
"schema": "mysql/schema",
1818
"queries": "mysql/query",
19-
"engine": "mysql:beta",
19+
"engine": "mysql",
2020
"emit_json_tags": true,
2121
"emit_prepared_queries": true,
2222
"emit_interface": true

internal/cmd/generate.go

Lines changed: 13 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import (
1616
"github.com/kyleconroy/sqlc/internal/config"
1717
"github.com/kyleconroy/sqlc/internal/debug"
1818
"github.com/kyleconroy/sqlc/internal/multierr"
19-
"github.com/kyleconroy/sqlc/internal/mysql"
2019
"github.com/kyleconroy/sqlc/internal/opts"
2120
)
2221

@@ -147,32 +146,22 @@ func Generate(e Env, dir string, stderr io.Writer) (map[string]string, error) {
147146
name = combo.Kotlin.Package
148147
}
149148

149+
result, errored := parse(e, name, dir, sql.SQL, combo, parseOpts, stderr)
150+
if errored {
151+
break
152+
}
153+
150154
var files map[string]string
151155
var out string
152-
153-
// TODO: Note about how this will be going away
154-
if sql.Engine == config.EngineMySQL {
155-
result, errored := parseMySQL(e, name, dir, sql.SQL, combo, parseOpts, stderr)
156-
if errored {
157-
break
158-
}
156+
switch {
157+
case sql.Gen.Go != nil:
159158
out = combo.Go.Out
160-
files, err = golang.DeprecatedGenerate(result, combo)
161-
} else {
162-
result, errored := parse(e, name, dir, sql.SQL, combo, parseOpts, stderr)
163-
if errored {
164-
break
165-
}
166-
switch {
167-
case sql.Gen.Go != nil:
168-
out = combo.Go.Out
169-
files, err = golang.Generate(result, combo)
170-
case sql.Gen.Kotlin != nil:
171-
out = combo.Kotlin.Out
172-
files, err = kotlin.Generate(result, combo)
173-
default:
174-
panic("missing language backend")
175-
}
159+
files, err = golang.Generate(result, combo)
160+
case sql.Gen.Kotlin != nil:
161+
out = combo.Kotlin.Out
162+
files, err = kotlin.Generate(result, combo)
163+
default:
164+
panic("missing language backend")
176165
}
177166

178167
if err != nil {
@@ -193,23 +182,6 @@ func Generate(e Env, dir string, stderr io.Writer) (map[string]string, error) {
193182
return output, nil
194183
}
195184

196-
// Experimental MySQL support
197-
func parseMySQL(e Env, name, dir string, sql config.SQL, combo config.CombinedSettings, parserOpts opts.Parser, stderr io.Writer) (golang.Generateable, bool) {
198-
q, err := mysql.GeneratePkg(name, sql.Schema, sql.Queries, combo)
199-
if err != nil {
200-
fmt.Fprintf(stderr, "# package %s\n", name)
201-
if parserErr, ok := err.(*multierr.Error); ok {
202-
for _, fileErr := range parserErr.Errs() {
203-
printFileErr(stderr, dir, fileErr)
204-
}
205-
} else {
206-
fmt.Fprintf(stderr, "error parsing schema: %s\n", err)
207-
}
208-
return nil, true
209-
}
210-
return q, false
211-
}
212-
213185
func parse(e Env, name, dir string, sql config.SQL, combo config.CombinedSettings, parserOpts opts.Parser, stderr io.Writer) (*compiler.Result, bool) {
214186
c := compiler.NewCompiler(sql, combo)
215187
if err := c.ParseCatalog(sql.Schema); err != nil {

internal/codegen/golang/gen.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -372,10 +372,6 @@ func (t *tmplCtx) OutputQuery(sourceName string) bool {
372372
return t.SourceName == sourceName
373373
}
374374

375-
func DeprecatedGenerate(r Generateable, settings config.CombinedSettings) (map[string]string, error) {
376-
return generate(settings, r.Enums(settings), r.Structs(settings), r.GoQueries(settings))
377-
}
378-
379375
func Generate(r *compiler.Result, settings config.CombinedSettings) (map[string]string, error) {
380376
enums := buildEnums(r, settings)
381377
structs := buildStructs(r, settings)

internal/codegen/golang/go_type.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ func goInnerType(r *compiler.Result, col *compiler.Column, settings config.Combi
3333

3434
// TODO: Extend the engine interface to handle types
3535
switch settings.Package.Engine {
36-
case config.EngineMySQL, config.EngineMySQLBeta:
36+
case config.EngineMySQL:
3737
return mysqlType(r, col, settings)
3838
case config.EnginePostgreSQL:
3939
return postgresType(r, col, settings)

internal/codegen/kotlin/gen.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ func makeType(r *compiler.Result, col *compiler.Column, settings config.Combined
365365
func ktInnerType(r *compiler.Result, col *compiler.Column, settings config.CombinedSettings) (string, bool) {
366366
// TODO: Extend the engine interface to handle types
367367
switch settings.Package.Engine {
368-
case config.EngineMySQL, config.EngineMySQLBeta:
368+
case config.EngineMySQL:
369369
return mysqlType(r, col, settings)
370370
case config.EnginePostgreSQL:
371371
return postgresType(r, col, settings)

internal/compiler/engine.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ func NewCompiler(conf config.SQL, combo config.CombinedSettings) *Compiler {
2525
case config.EngineXLemon:
2626
c.parser = sqlite.NewParser()
2727
c.catalog = catalog.New("main")
28-
case config.EngineMySQL, config.EngineMySQLBeta:
28+
case config.EngineMySQL:
2929
c.parser = dolphin.NewParser()
3030
c.catalog = dolphin.NewCatalog()
3131
case config.EnginePostgreSQL:

internal/compiler/expand.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ func (c *Compiler) expand(qc *QueryCatalog, raw *ast.RawStmt) ([]source.Edit, er
3939
func (c *Compiler) quoteIdent(ident string) string {
4040
if c.parser.IsReservedKeyword(ident) {
4141
switch c.conf.Engine {
42-
case config.EngineMySQL, config.EngineMySQLBeta:
42+
case config.EngineMySQL:
4343
return "`" + ident + "`"
4444
default:
4545
return "\"" + ident + "\""

internal/config/config.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ func (p *Paths) UnmarshalYAML(unmarshal func(interface{}) error) error {
7070

7171
const (
7272
EngineMySQL Engine = "mysql"
73-
EngineMySQLBeta Engine = "mysql:beta"
7473
EnginePostgreSQL Engine = "postgresql"
7574

7675
// Experimental engines

internal/endtoend/testdata/alias/mysql/sqlc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"packages": [
44
{
55
"path": "go",
6-
"engine": "mysql:beta",
6+
"engine": "mysql",
77
"name": "querytest",
88
"schema": "query.sql",
99
"queries": "query.sql"

internal/endtoend/testdata/column_as/mysql/sqlc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"version": "1",
33
"packages": [
44
{
5-
"engine": "mysql:beta",
5+
"engine": "mysql",
66
"path": "go",
77
"name": "querytest",
88
"schema": "query.sql",

internal/endtoend/testdata/comment_syntax/mysql/sqlc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"packages": [
44
{
55
"path": "go",
6-
"engine": "mysql:beta",
6+
"engine": "mysql",
77
"name": "querytest",
88
"schema": "query.sql",
99
"queries": "query.sql"

internal/endtoend/testdata/create_table_like/mysql/sqlc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"path": "go",
77
"schema": "schema.sql",
88
"queries": "query.sql",
9-
"engine": "mysql:beta"
9+
"engine": "mysql"
1010
}
1111
]
1212
}

internal/endtoend/testdata/ddl_alter_table_column_drop_not_null/mysql/sqlc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"packages": [
44
{
55
"path": "go",
6-
"engine": "mysql:beta",
6+
"engine": "mysql",
77
"name": "querytest",
88
"schema": "schema.sql",
99
"queries": "query.sql"

internal/endtoend/testdata/ddl_alter_table_column_drop_not_null/postgresql/sqlc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@
99
"queries": "query.sql"
1010
}
1111
]
12-
}
12+
}

internal/endtoend/testdata/ddl_alter_table_drop_column/mysql/sqlc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"packages": [
44
{
55
"path": "go",
6-
"engine": "mysql:beta",
6+
"engine": "mysql",
77
"name": "querytest",
88
"schema": "schema.sql",
99
"queries": "query.sql"

internal/endtoend/testdata/ddl_alter_table_drop_column/postgresql/sqlc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@
99
"queries": "query.sql"
1010
}
1111
]
12-
}
12+
}

internal/endtoend/testdata/ddl_alter_table_drop_column_if_exists/mysql/sqlc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"packages": [
44
{
55
"path": "go",
6-
"engine": "mysql:beta",
6+
"engine": "mysql",
77
"name": "querytest",
88
"schema": "schema.sql",
99
"queries": "query.sql"

internal/endtoend/testdata/ddl_alter_table_drop_column_if_exists/postgresql/sqlc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@
99
"queries": "query.sql"
1010
}
1111
]
12-
}
12+
}

internal/endtoend/testdata/ddl_alter_table_drop_constraint/mysql/sqlc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"packages": [
44
{
55
"path": "go",
6-
"engine": "mysql:beta",
6+
"engine": "mysql",
77
"name": "querytest",
88
"schema": "schema.sql",
99
"queries": "query.sql"

internal/endtoend/testdata/ddl_alter_table_drop_constraint/postgresql/sqlc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@
99
"queries": "query.sql"
1010
}
1111
]
12-
}
12+
}

internal/endtoend/testdata/ddl_alter_table_rename/mysql/sqlc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"packages": [
44
{
55
"path": "go",
6-
"engine": "mysql:beta",
6+
"engine": "mysql",
77
"name": "querytest",
88
"schema": "schema.sql",
99
"queries": "query.sql"

internal/endtoend/testdata/ddl_alter_table_rename/postgresql/sqlc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@
99
"queries": "query.sql"
1010
}
1111
]
12-
}
12+
}

internal/endtoend/testdata/ddl_alter_table_rename_column/mysql/sqlc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"packages": [
44
{
55
"path": "go",
6-
"engine": "mysql:beta",
6+
"engine": "mysql",
77
"name": "querytest",
88
"schema": "schema.sql",
99
"queries": "query.sql"

internal/endtoend/testdata/ddl_alter_table_rename_column/postgresql/sqlc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@
99
"queries": "query.sql"
1010
}
1111
]
12-
}
12+
}

internal/endtoend/testdata/ddl_alter_table_set_data_type/mysql/sqlc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"packages": [
44
{
55
"path": "go",
6-
"engine": "mysql:beta",
6+
"engine": "mysql",
77
"name": "querytest",
88
"schema": "schema.sql",
99
"queries": "query.sql"

internal/endtoend/testdata/ddl_alter_table_set_data_type/postgresql/sqlc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@
99
"queries": "query.sql"
1010
}
1111
]
12-
}
12+
}

internal/endtoend/testdata/ddl_alter_table_set_not_null/mysql/sqlc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"packages": [
44
{
55
"path": "go",
6-
"engine": "mysql:beta",
6+
"engine": "mysql",
77
"name": "querytest",
88
"schema": "schema.sql",
99
"queries": "query.sql"

internal/endtoend/testdata/ddl_alter_table_set_not_null/postgresql/sqlc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@
99
"queries": "query.sql"
1010
}
1111
]
12-
}
12+
}

internal/endtoend/testdata/ddl_alter_table_set_schema/postgresql/sqlc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@
99
"queries": "query.sql"
1010
}
1111
]
12-
}
12+
}

internal/endtoend/testdata/ddl_alter_type_add_value/postgresql/sqlc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@
99
"queries": "query.sql"
1010
}
1111
]
12-
}
12+
}

internal/endtoend/testdata/ddl_alter_type_rename_value/postgresql/sqlc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@
99
"queries": "query.sql"
1010
}
1111
]
12-
}
12+
}

internal/endtoend/testdata/ddl_comment/mysql/sqlc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"packages": [
44
{
55
"path": "go",
6-
"engine": "mysql:beta",
6+
"engine": "mysql",
77
"name": "querytest",
88
"schema": "schema.sql",
99
"queries": "query.sql"

internal/endtoend/testdata/ddl_comment/postgresql/sqlc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@
99
"queries": "query.sql"
1010
}
1111
]
12-
}
12+
}

internal/endtoend/testdata/ddl_create_enum/mysql/sqlc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"packages": [
44
{
55
"path": "go",
6-
"engine": "mysql:beta",
6+
"engine": "mysql",
77
"name": "querytest",
88
"schema": "schema.sql",
99
"queries": "query.sql"

0 commit comments

Comments
 (0)