Skip to content

feat(mysql): Add a test for VECTOR column type #3734

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Dec 24, 2024
Merged
Show file tree
Hide file tree
Changes from all 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 .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ jobs:
# Start a MySQL server
- uses: shogo82148/actions-setup-mysql@v1
with:
mysql-version: "8.1"
mysql-version: "9.0"

- name: test ./...
run: gotestsum --junitfile junit.xml -- --tags=examples -timeout 20m ./...
Expand Down
2 changes: 1 addition & 1 deletion examples/ondeck/mysql/schema/0002_venue.sql
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ CREATE TABLE venues (
statuses text, -- status[],
slug text not null COMMENT 'This value appears in public URLs',
name varchar(255) not null,
city text not null references city(slug),
city varchar(255) not null references city(slug),
spotify_playlist varchar(255) not null,
songkick_id text,
tags text -- text[]
Expand Down
4 changes: 2 additions & 2 deletions internal/endtoend/testdata/join_right/mysql/go/models.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions internal/endtoend/testdata/join_right/mysql/go/query.sql.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 7 additions & 2 deletions internal/endtoend/testdata/join_right/mysql/schema.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
CREATE TABLE foo (id serial not null, bar_id int references bar(id));
CREATE TABLE bar (id serial not null);
CREATE TABLE bar (
id integer not null,
UNIQUE(id)
);

CREATE TABLE foo (id integer not null, bar_id integer references bar(id));


4 changes: 2 additions & 2 deletions internal/endtoend/testdata/join_table_name/mysql/go/models.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions internal/endtoend/testdata/join_table_name/mysql/schema.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
CREATE TABLE bar (id serial not null);
CREATE TABLE foo (id serial not null, bar integer references bar(id));
CREATE TABLE bar (
id integer not null,
UNIQUE (id)
);

CREATE TABLE foo (id integer not null, bar integer references bar(id));

31 changes: 31 additions & 0 deletions internal/endtoend/testdata/mysql_vector/mysql/go/db.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions internal/endtoend/testdata/mysql_vector/mysql/go/models.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

48 changes: 48 additions & 0 deletions internal/endtoend/testdata/mysql_vector/mysql/go/query.sql.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions internal/endtoend/testdata/mysql_vector/mysql/query.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
-- name: InsertVector :exec
INSERT INTO foo(embedding) VALUES (STRING_TO_VECTOR('[0.1, 0.2, 0.3, 0.4]'));

-- name: SelectVector :many
SELECT id FROM foo
ORDER BY DISTANCE(STRING_TO_VECTOR('[1.2, 3.4, 5.6]'), embedding, 'L2_squared')
LIMIT 10;
4 changes: 4 additions & 0 deletions internal/endtoend/testdata/mysql_vector/mysql/schema.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
CREATE TABLE foo(
id INT PRIMARY KEY auto_increment,
embedding VECTOR(4)
);
14 changes: 14 additions & 0 deletions internal/endtoend/testdata/mysql_vector/mysql/sqlc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"version": "1",
"packages": [
{
"path": "go",
"sql_package": "database/sql",
"sql_driver": "github.com/go-sql-driver/mysql",
"engine": "mysql",
"name": "querytest",
"schema": "schema.sql",
"queries": "query.sql"
}
]
}
Loading