Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
2b6105d
How long does starting PostgreSQL take?
kyleconroy Jan 2, 2024
6b6cd74
Update ddl_test to talk to local server
kyleconroy Jan 2, 2024
231b085
Re-run
kyleconroy Jan 2, 2024
2657f38
Create a new local sqltest package
kyleconroy Jan 2, 2024
7805817
Re-enabled some tests
kyleconroy Jan 3, 2024
83aab1a
Disable some tests again
kyleconroy Jan 3, 2024
840a4b7
Remove unused package
kyleconroy Jan 3, 2024
d265bc0
PostgreSQL 16
kyleconroy Jan 3, 2024
8998b20
fix
kyleconroy Jan 3, 2024
d79f780
start mysql too
kyleconroy Jan 3, 2024
5e3837b
Try to use the MySQL server
kyleconroy Jan 3, 2024
e8f553a
oops
kyleconroy Jan 3, 2024
0f3d476
SSL?
kyleconroy Jan 3, 2024
5607ecd
disable tls
kyleconroy Jan 3, 2024
e6868b6
Only run a small set of tests
kyleconroy Jan 3, 2024
1c1b5bb
Fix MySQL failures
kyleconroy Jan 3, 2024
d0cb520
Run all the tests
kyleconroy Jan 3, 2024
2c9edc1
A bunch of invalid MySQL schemas
kyleconroy Jan 3, 2024
f18905c
Get all the tests passing
kyleconroy Jan 3, 2024
e758085
Are they passing?
kyleconroy Jan 3, 2024
a0877f3
Fix last test
kyleconroy Jan 3, 2024
47294da
Test on all platforms
kyleconroy Jan 3, 2024
891ff92
fix Windows build
kyleconroy Jan 3, 2024
e7c32e9
Add new metadata key to exec.json
kyleconroy Jan 3, 2024
f742a02
Mark pg_vector as invalid for now
kyleconroy Jan 3, 2024
b0dad14
Skip two tests on Windows
kyleconroy Jan 3, 2024
452abd5
Only run Windows / MacOS on main
kyleconroy Jan 3, 2024
0c168ad
Merge branch 'main' into kyle/setup-postgresql
kyleconroy Jan 3, 2024
760e044
clean up
kyleconroy Jan 3, 2024
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
Prev Previous commit
Next Next commit
A bunch of invalid MySQL schemas
  • Loading branch information
kyleconroy committed Jan 3, 2024
commit 2c9edc175ab4bd970b15cf58ba1699a0a2f49caf
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"contexts": ["managed-db"]
"contexts": ["unknown"]
}
3 changes: 3 additions & 0 deletions internal/endtoend/testdata/ddl_drop_schema/mysql/exec.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"contexts": ["base"]
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
CREATE TABLE foo (bar text);

-- name: InsertFoo :exec
INSERT INTO foo (bar)
SELECT 1, ?, ?;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CREATE TABLE foo (bar text);
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"engine": "mysql",
"path": "go",
"name": "querytest",
"schema": "query.sql",
"schema": "schema.sql",
"queries": "query.sql"
}
]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
CREATE TABLE authors (
id BIGINT PRIMARY KEY,
bio TEXT
);

-- name: ListAuthors :one
SELECT *
FROM authors
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
CREATE TABLE authors (
id BIGINT PRIMARY KEY,
bio TEXT
);
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
-- https://github.com/sqlc-dev/sqlc/issues/437
CREATE TABLE authors (
id INT PRIMARY KEY,
name VARCHAR(255) NOT NULL,
bio text
);

-- name: GetAuthor :one
SELECT *
FROM authors a
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
-- https://github.com/sqlc-dev/sqlc/issues/437
CREATE TABLE authors (
id INT PRIMARY KEY,
name VARCHAR(255) NOT NULL,
bio text
);

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"path": "go",
"engine": "mysql",
"name": "querytest",
"schema": "query.sql",
"schema": "schema.sql",
"queries": "query.sql"
}
]
Expand Down
6 changes: 3 additions & 3 deletions internal/endtoend/testdata/join_left/mysql/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ CREATE TABLE super_authors (
CREATE TABLE users_2 (
user_id INT PRIMARY KEY,
user_nickname VARCHAR(30) UNIQUE NOT NULL,
user_email TEXT UNIQUE NOT NULL,
user_email VARCHAR(20) UNIQUE NOT NULL,
user_display_name TEXT NOT NULL,
user_password TEXT NULL,
user_google_id TEXT UNIQUE NULL,
user_apple_id TEXT UNIQUE NULL,
user_google_id VARCHAR(20) UNIQUE NULL,
user_apple_id VARCHAR(20) UNIQUE NULL,
user_bio VARCHAR(160) NOT NULL DEFAULT '',
user_created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
user_avatar_id INT UNIQUE NULL
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
CREATE TABLE bar (id serial not null);
CREATE TABLE foo (id serial not null, bar serial references bar(id));
CREATE TABLE foo (id serial not null, bar integer references bar(id));

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CREATE TABLE foo (bar_id serial not null, baz_id serial not null);
CREATE TABLE foo (bar_id serial not null, baz_id integer not null);
CREATE TABLE bar (id serial not null);
CREATE TABLE baz (id serial not null);

5 changes: 5 additions & 0 deletions internal/endtoend/testdata/mix_param_types/mysql/schema.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
CREATE TABLE bar (
id serial not null,
name text not null,
phone text not null
);
2 changes: 1 addition & 1 deletion internal/endtoend/testdata/mix_param_types/mysql/sqlc.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{
"path": "go",
"name": "querytest",
"schema": "test.sql",
"schema": "schema.sql",
"queries": "test.sql",
"engine": "mysql"
}
Expand Down
6 changes: 0 additions & 6 deletions internal/endtoend/testdata/mix_param_types/mysql/test.sql
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
CREATE TABLE bar (
id serial not null,
name text not null,
phone text not null
);

-- name: CountOne :one
SELECT count(1) FROM bar WHERE id = sqlc.arg(id) AND name <> ?;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
CREATE TABLE student (
student_name VARCHAR(255),
score DOUBLE
);

-- name: GroupConcat :many
SELECT student_name, GROUP_CONCAT(test_score)
FROM student
Expand Down
4 changes: 4 additions & 0 deletions internal/endtoend/testdata/mysql_reference_manual/schema.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
CREATE TABLE student (
student_name VARCHAR(255),
test_score DOUBLE
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"contexts": ["base"]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"contexts": ["base"]
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"contexts": ["base"]
}
3 changes: 3 additions & 0 deletions internal/endtoend/testdata/schema_scoped_list/mysql/exec.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"contexts": ["base"]
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
CREATE TABLE bar (name text);

-- name: GetBars :many
SELECT FROM bar;
SELECT FROM bar;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CREATE TABLE bar (name text);
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"path": "go",
"engine": "mysql",
"name": "querytest",
"schema": "query.sql",
"schema": "schema.sql",
"queries": "query.sql"
}
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ CREATE TABLE authors (

-- https://github.com/sqlc-dev/sqlc/issues/1290
CREATE TABLE users (
sub TEXT PRIMARY KEY
sub VARCHAR(10) PRIMARY KEY
);
5 changes: 0 additions & 5 deletions internal/endtoend/testdata/sqlc_arg_invalid/mysql/query.sql
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
CREATE TABLE users (
id serial,
first_name text not null
);

-- name: WrongFunc :one
select id, first_name from users where id = sqlc.argh(target_id);

Expand Down
4 changes: 4 additions & 0 deletions internal/endtoend/testdata/sqlc_arg_invalid/mysql/schema.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
CREATE TABLE users (
id serial,
first_name text not null
);
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
CREATE TABLE authors (
id BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY,
name text NOT NULL,
name VARCHAR(10) NOT NULL,
bio text,
UNIQUE(name)
);
Expand Down
4 changes: 4 additions & 0 deletions internal/sqltest/local/mysql.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"database/sql"
"fmt"
"os"
"strings"
"sync"
"testing"

Expand Down Expand Up @@ -79,6 +80,9 @@ func MySQL(t *testing.T, migrations []string) string {
defer db.Close()

for _, q := range seed {
if len(strings.TrimSpace(q)) == 0 {
continue
}
if _, err := db.ExecContext(ctx, q); err != nil {
t.Fatalf("%s: %s", q, err)
}
Expand Down
4 changes: 4 additions & 0 deletions internal/sqltest/local/postgres.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"net/url"
"os"
"strings"
"sync"
"testing"

Expand Down Expand Up @@ -79,6 +80,9 @@ func PostgreSQL(t *testing.T, migrations []string) string {
defer conn.Close(ctx)

for _, q := range seed {
if len(strings.TrimSpace(q)) == 0 {
continue
}
if _, err := conn.Exec(ctx, q); err != nil {
t.Fatalf("%s: %s", q, err)
}
Expand Down