Skip to content
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
29 changes: 29 additions & 0 deletions examples/booktest/mysql/db.go

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

35 changes: 35 additions & 0 deletions examples/booktest/mysql/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 examples/booktest/mysql/query.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/* name: GetAuthor :one */
SELECT * FROM authors
WHERE author_id = ?;

/* name: GetBook :one */
SELECT * FROM books
WHERE book_id = ?;

/* name: DeleteBook :exec */
DELETE FROM books
WHERE book_id = ?;

/* name: BooksByTitleYear :many */
SELECT * FROM books
WHERE title = ? AND yr = ?;

/* name: CreateAuthor :exec */
INSERT INTO authors (name) VALUES (?);

/* name: CreateBook :exec */
INSERT INTO books (
author_id,
isbn,
booktype,
title,
yr,
available,
tags
) VALUES (
?,
?,
?,
?,
?,
?,
?
);

/* name: UpdateBook :exec */
UPDATE books
SET title = ?, tags = ?
WHERE book_id = ?;

/* name: UpdateBookISBN :exec */
UPDATE books
SET title = ?, tags = ?, isbn = ?
WHERE book_id = ?;

189 changes: 189 additions & 0 deletions examples/booktest/mysql/query.sql.go

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

32 changes: 32 additions & 0 deletions examples/booktest/mysql/schema.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
SET FOREIGN_KEY_CHECKS=0;
DROP TABLE IF EXISTS authors;
DROP TABLE IF EXISTS books;
-- DROP FUNCTION IF EXISTS say_hello;
SET FOREIGN_KEY_CHECKS=1;

CREATE TABLE authors (
author_id integer NOT NULL AUTO_INCREMENT PRIMARY KEY,
name text NOT NULL DEFAULT ''
) ENGINE=InnoDB;

CREATE INDEX authors_name_idx ON authors(name(255));

CREATE TABLE books (
book_id integer NOT NULL AUTO_INCREMENT PRIMARY KEY,
author_id integer NOT NULL,
isbn varchar(255) NOT NULL DEFAULT '' UNIQUE,
book_type ENUM('FICTION', 'NONFICTION') NOT NULL DEFAULT 'FICTION',
title text NOT NULL DEFAULT '',
yr integer NOT NULL DEFAULT 2000,
available datetime NOT NULL DEFAULT NOW(),
tags text NOT NULL DEFAULT ''
-- CONSTRAINT FOREIGN KEY (author_id) REFERENCES authors(author_id)
) ENGINE=InnoDB;

CREATE INDEX books_title_idx ON books(title(255), yr);

/*
CREATE FUNCTION say_hello(s text) RETURNS text
DETERMINISTIC
RETURN CONCAT('hello ', s);
*/
29 changes: 29 additions & 0 deletions examples/booktest/postgresql/db.go

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

Loading