Skip to content

Commit

Permalink
Rerun examples with new checksum
Browse files Browse the repository at this point in the history
  • Loading branch information
kaashyapan committed May 29, 2023
1 parent d09d6d4 commit 4816c97
Show file tree
Hide file tree
Showing 15 changed files with 411 additions and 406 deletions.
61 changes: 31 additions & 30 deletions examples/authors/postgresql/Queries.fs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Code generated by sqlc. DO NOT EDIT.
// version: sqlc v1.18.0
// for nuget package Npgsql.FSharp --version 5.7.0

namespace Authors

Expand All @@ -10,6 +11,20 @@ open Authors.Readers

module Sqls =

[<Literal>]
let getAuthor =
"""
SELECT id, name, bio FROM authors
WHERE id = @id LIMIT 1
"""

[<Literal>]
let listAuthors =
"""
SELECT id, name, bio FROM authors
ORDER BY name
"""

[<Literal>]
let createAuthor =
"""
Expand All @@ -27,24 +42,26 @@ module Sqls =
WHERE id = @id
"""

[<Literal>]
let getAuthor =
"""
SELECT id, name, bio FROM authors
WHERE id = @id LIMIT 1
"""

[<Literal>]
let listAuthors =
"""
SELECT id, name, bio FROM authors
ORDER BY name
"""

[<RequireQualifiedAccessAttribute>]
type DB(conn: string) =
// https://www.connectionstrings.com/npgsql

/// This SQL will select a single author from the table
member this.getAuthor(id: int64) =

let parameters = [ ("id", Sql.int64 id) ]

conn
|> Sql.connect
|> Sql.query Sqls.getAuthor
|> Sql.parameters parameters
|> Sql.executeRow authorReader

/// This SQL will list all authors from the authors table
member this.listAuthors() =

conn |> Sql.connect |> Sql.query Sqls.listAuthors |> Sql.execute authorReader

/// This SQL will insert a single author into the table
member this.createAuthor(name: string, ?bio: string) =

Expand All @@ -66,19 +83,3 @@ type DB(conn: string) =
|> Sql.query Sqls.deleteAuthor
|> Sql.parameters parameters
|> Sql.executeNonQuery

/// This SQL will select a single author from the table
member this.getAuthor(id: int64) =

let parameters = [ ("id", Sql.int64 id) ]

conn
|> Sql.connect
|> Sql.query Sqls.getAuthor
|> Sql.parameters parameters
|> Sql.executeRow authorReader

/// This SQL will list all authors from the authors table
member this.listAuthors() =

conn |> Sql.connect |> Sql.query Sqls.listAuthors |> Sql.execute authorReader
1 change: 1 addition & 0 deletions examples/authors/postgresql/Readers.fs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Code generated by sqlc. DO NOT EDIT.
// version: sqlc v1.18.0
// for nuget package Npgsql.FSharp --version 5.7.0

namespace Authors

Expand Down
60 changes: 29 additions & 31 deletions examples/authors/sqlite/Queries.fs
Original file line number Diff line number Diff line change
@@ -1,17 +1,29 @@
// Code generated by sqlc. DO NOT EDIT.
// version: sqlc v1.18.0
// for nuget package Fumble --version 1.0.1

namespace Authors

open System
open Fumble
open Authors.Readers

module Sql = Sqlite
type Sql = Sqlite

module Sqls =

[<Literal>]
let getAuthor =
"""
SELECT id, name, bio FROM authors
WHERE id = @id LIMIT 1
"""

[<Literal>]
let listAuthors =
"""
SELECT id, name, bio FROM authors
ORDER BY name
"""

[<Literal>]
let createAuthor =
"""
Expand All @@ -29,54 +41,40 @@ module Sqls =
WHERE id = @id
"""

[<Literal>]
let getAuthor =
"""
SELECT id, name, bio FROM authors
WHERE id = @id LIMIT 1
"""

[<Literal>]
let listAuthors =
"""
SELECT id, name, bio FROM authors
ORDER BY name
"""

[<RequireQualifiedAccessAttribute>]
type DB(conn: string) =
// https://www.connectionstrings.com/sqlite-net-provider

member this.createAuthor(name: string, ?bio: string) =
member this.getAuthor(id: int) =

let parameters = [ ("name", Sql.string name); ("bio", Sql.stringOrNone bio) ]
let parameters = [ ("id", Sql.int id) ]

conn
|> Sql.connect
|> Sql.query Sqls.createAuthor
|> Sql.query Sqls.getAuthor
|> Sql.parameters parameters
|> Sql.executeNonQuery
|> Sql.execute authorReader

member this.deleteAuthor(id: int) =
member this.listAuthors() =

let parameters = [ ("id", Sql.int id) ]
conn |> Sql.connect |> Sql.query Sqls.listAuthors |> Sql.execute authorReader

member this.createAuthor(name: string, ?bio: string) =

let parameters = [ ("name", Sql.string name); ("bio", Sql.stringOrNone bio) ]

conn
|> Sql.connect
|> Sql.query Sqls.deleteAuthor
|> Sql.query Sqls.createAuthor
|> Sql.parameters parameters
|> Sql.executeNonQuery

member this.getAuthor(id: int) =
member this.deleteAuthor(id: int) =

let parameters = [ ("id", Sql.int id) ]

conn
|> Sql.connect
|> Sql.query Sqls.getAuthor
|> Sql.query Sqls.deleteAuthor
|> Sql.parameters parameters
|> Sql.execute authorReader

member this.listAuthors() =

conn |> Sql.connect |> Sql.query Sqls.listAuthors |> Sql.execute authorReader
|> Sql.executeNonQuery
1 change: 1 addition & 0 deletions examples/authors/sqlite/Readers.fs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Code generated by sqlc. DO NOT EDIT.
// version: sqlc v1.18.0
// for nuget package Fumble --version 1.0.1

namespace Authors

Expand Down
1 change: 0 additions & 1 deletion examples/booktest/postgresql/Models.fs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

// Code generated by sqlc. DO NOT EDIT.
// version: sqlc v1.18.0

Expand Down
110 changes: 55 additions & 55 deletions examples/booktest/postgresql/Queries.fs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

// Code generated by sqlc. DO NOT EDIT.
// version: sqlc v1.18.0
// for nuget package Npgsql.FSharp --version 5.7.0

namespace Booktest

Expand All @@ -11,6 +11,34 @@ open Booktest.Readers

module Sqls =

[<Literal>]
let getAuthor =
"""
SELECT author_id, name FROM authors
WHERE author_id = @author_id
"""

[<Literal>]
let getBook =
"""
SELECT book_id, author_id, isbn, book_type, title, year, available, tags FROM books
WHERE book_id = @book_id
"""

[<Literal>]
let deleteBook =
"""
DELETE FROM books
WHERE book_id = @book_id
"""

[<Literal>]
let booksByTitleYear =
"""
SELECT book_id, author_id, isbn, book_type, title, year, available, tags FROM books
WHERE title = @title AND year = @year
"""

[<Literal>]
let booksByTags =
"""
Expand All @@ -25,13 +53,6 @@ LEFT JOIN authors ON books.author_id = authors.author_id
WHERE tags && @::varchar[]
"""

[<Literal>]
let booksByTitleYear =
"""
SELECT book_id, author_id, isbn, book_type, title, year, available, tags FROM books
WHERE title = @title AND year = @year
"""

[<Literal>]
let createAuthor =
"""
Expand Down Expand Up @@ -62,27 +83,6 @@ RETURNING author_id, name
RETURNING book_id, author_id, isbn, book_type, title, year, available, tags
"""

[<Literal>]
let deleteBook =
"""
DELETE FROM books
WHERE book_id = @book_id
"""

[<Literal>]
let getAuthor =
"""
SELECT author_id, name FROM authors
WHERE author_id = @author_id
"""

[<Literal>]
let getBook =
"""
SELECT book_id, author_id, isbn, book_type, title, year, available, tags FROM books
WHERE book_id = @book_id
"""

[<Literal>]
let updateBook =
"""
Expand All @@ -103,73 +103,73 @@ WHERE book_id = @book_id
type DB (conn: string) =
// https://www.connectionstrings.com/npgsql

member this.booksByTags (dollar1: List&lt;string&gt;) =
member this.getAuthor (authorId: int) =

let parameters = [ ("", Sql.string dollar1) ]
let parameters = [ ("author_id", Sql.int authorId) ]

conn
|> Sql.connect
|> Sql.query Sqls.booksByTags
|> Sql.query Sqls.getAuthor
|> Sql.parameters parameters
|> Sql.execute booksByTagsRowReader
|> Sql.executeRow authorReader

member this.booksByTitleYear (title: string, year: int) =
member this.getBook (bookId: int) =

let parameters = [ ("title", Sql.text title); ("year", Sql.int year) ]
let parameters = [ ("book_id", Sql.int bookId) ]

conn
|> Sql.connect
|> Sql.query Sqls.booksByTitleYear
|> Sql.query Sqls.getBook
|> Sql.parameters parameters
|> Sql.execute bookReader
|> Sql.executeRow bookReader

member this.createAuthor (name: string) =
member this.deleteBook (bookId: int) =

let parameters = [ ("name", Sql.text name) ]
let parameters = [ ("book_id", Sql.int bookId) ]

conn
|> Sql.connect
|> Sql.query Sqls.createAuthor
|> Sql.query Sqls.deleteBook
|> Sql.parameters parameters
|> Sql.executeRow authorReader
|> Sql.executeNonQuery

member this.createBook (authorId: int, isbn: string, bookType: book_type, title: string, year: int, available: DateTimeOffset, tags: List&lt;string&gt;) =
member this.booksByTitleYear (title: string, year: int) =

let parameters = [ ("author_id", Sql.int authorId); ("isbn", Sql.text isbn); ("book_type", Sql.unhandled_report_issue bookType); ("title", Sql.text title); ("year", Sql.int year); ("available", Sql.timestamptz available); ("tags", Sql.string tags) ]
let parameters = [ ("title", Sql.text title); ("year", Sql.int year) ]

conn
|> Sql.connect
|> Sql.query Sqls.createBook
|> Sql.query Sqls.booksByTitleYear
|> Sql.parameters parameters
|> Sql.executeRow bookReader
|> Sql.execute bookReader

member this.deleteBook (bookId: int) =
member this.booksByTags (dollar1: List&lt;string&gt;) =

let parameters = [ ("book_id", Sql.int bookId) ]
let parameters = [ ("", Sql.string dollar1) ]

conn
|> Sql.connect
|> Sql.query Sqls.deleteBook
|> Sql.query Sqls.booksByTags
|> Sql.parameters parameters
|> Sql.executeNonQuery
|> Sql.execute booksByTagsRowReader

member this.getAuthor (authorId: int) =
member this.createAuthor (name: string) =

let parameters = [ ("author_id", Sql.int authorId) ]
let parameters = [ ("name", Sql.text name) ]

conn
|> Sql.connect
|> Sql.query Sqls.getAuthor
|> Sql.query Sqls.createAuthor
|> Sql.parameters parameters
|> Sql.executeRow authorReader

member this.getBook (bookId: int) =
member this.createBook (authorId: int, isbn: string, bookType: book_type, title: string, year: int, available: DateTimeOffset, tags: List&lt;string&gt;) =

let parameters = [ ("book_id", Sql.int bookId) ]
let parameters = [ ("author_id", Sql.int authorId); ("isbn", Sql.text isbn); ("book_type", Sql.book_type_unhandled_report_issue bookType); ("title", Sql.text title); ("year", Sql.int year); ("available", Sql.timestamptz available); ("tags", Sql.string tags) ]

conn
|> Sql.connect
|> Sql.query Sqls.getBook
|> Sql.query Sqls.createBook
|> Sql.parameters parameters
|> Sql.executeRow bookReader

Expand Down
Loading

0 comments on commit 4816c97

Please sign in to comment.