Repository: sqlc-dev/sqlc
Pull request #3016 (2023-11-28 10:03:13)

build(deps): bump sphinx-rtd-theme from 1.3.0 to 2.0.0 in /docs
Bumps [sphinx-rtd-theme](https://github.com/readthedocs/sphinx_rtd_theme) from 1.3.0 to 2.0.0.
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a href="https://github.com/readthedocs/sphinx_rtd_theme/blob/master/docs/changelog.rst">sphinx-rtd-theme's changelog</a>.</em></p>
<blockquote>
<h1>2.0.0</h1>
<h2>Added</h2>
<ul>
<li>Support for Sphinx versions <code>6.x</code> and <code>7.x</code></li>
<li>Support for docutils <code>&lt;=0.20</code></li>
</ul>
<h2>Deprecations</h2>
<ul>
<li>The HTML4 writer is now officially deprecated. An error will be thrown if your
project configuration still uses the HTML4 writer.</li>
<li>Support for Sphinx versions &lt; 5.0 was removed.</li>
<li>In addition, our supported dependencies will match the dependencies from our
lowest supported Sphinx release, version 5.0: Python &gt;= 3.6 and docutils &gt; 0.14 and &lt; 0.19</li>
</ul>
<p>.. _release-1.3.0:</p>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="https://github.com/readthedocs/sphinx_rtd_theme/commit/7c9b1b5d391f6d7fae72274393eb25d1df96e546"><code>7c9b1b5</code></a> Release 2.0 final (<a href="https://redirect.github.com/readthedocs/sphinx_rtd_theme/issues/1544">#1544</a>)</li>
<li><a href="https://github.com/readthedocs/sphinx_rtd_theme/commit/c1044107602faf9be43e4358bc4f8b6abff9b420"><code>c104410</code></a> Bump for next potential release, 2.0.0rc5 (<a href="https://redirect.github.com/readthedocs/sphinx_rtd_theme/issues/1539">#1539</a>)</li>
<li><a href="https://github.com/readthedocs/sphinx_rtd_theme/commit/53ca116ef64123735e5e445258b8b103ad31a26e"><code>53ca116</code></a> Release 2.0.0rc4 (<a href="https://redirect.github.com/readthedocs/sphinx_rtd_theme/issues/1538">#1538</a>)</li>
<li><a href="https://github.com/readthedocs/sphinx_rtd_theme/commit/4498e97b462688bac2ff3615ac1da1b867b21842"><code>4498e97</code></a> Fix AttributeError when one of <code>css_files</code> is a string (<a href="https://redirect.github.com/readthedocs/sphinx_rtd_theme/issues/1537">#1537</a>)</li>
<li><a href="https://github.com/readthedocs/sphinx_rtd_theme/commit/84aea9b0ba78b7f07df4b624e5200ed4c842794c"><code>84aea9b</code></a> Increment for next potential release (<a href="https://redirect.github.com/readthedocs/sphinx_rtd_theme/issues/1536">#1536</a>)</li>
<li><a href="https://github.com/readthedocs/sphinx_rtd_theme/commit/febde39c7cd5f56fe19979adeee05e1e16eadfe2"><code>febde39</code></a> Release 2.0.0rc3 (<a href="https://redirect.github.com/readthedocs/sphinx_rtd_theme/issues/1535">#1535</a>)</li>
<li><a href="https://github.com/readthedocs/sphinx_rtd_theme/commit/32310a819012589211a68db8d8060fd1e3a499f5"><code>32310a8</code></a> Fix <a href="https://redirect.github.com/readthedocs/sphinx_rtd_theme/issues/1522">#1522</a>: fix <code>'str' object has no attribute 'attributes'</code> (<a href="https://redirect.github.com/readthedocs/sphinx_rtd_theme/issues/1528">#1528</a>)</li>
<li><a href="https://github.com/readthedocs/sphinx_rtd_theme/commit/8ce23cec96f628ac0d29737bf1cf8cc2e750f068"><code>8ce23ce</code></a> Version bump for 2.0rc3 development (<a href="https://redirect.github.com/readthedocs/sphinx_rtd_theme/issues/1521">#1521</a>)</li>
<li><a href="https://github.com/readthedocs/sphinx_rtd_theme/commit/46f5307dbd32ebb339c3a76514ce5791826ec381"><code>46f5307</code></a> Release 2.0rc2 (<a href="https://redirect.github.com/readthedocs/sphinx_rtd_theme/issues/1520">#1520</a>)</li>
<li><a href="https://github.com/readthedocs/sphinx_rtd_theme/commit/5838e6aa545863fac10c08314f90feb6d7ac7757"><code>5838e6a</code></a> Add support for <code>docutils==0.20.x</code> (<a href="https://redirect.github.com/readthedocs/sphinx_rtd_theme/issues/1517">#1517</a>)</li>
<li>Additional commits viewable in <a href="https://github.com/readthedocs/sphinx_rtd_theme/compare/1.3.0...2.0.0">compare view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=sphinx-rtd-theme&package-manager=pip&previous-version=1.3.0&new-version=2.0.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)


</details>


Patch:
diff --git a/docs/requirements.txt b/docs/requirements.txt
index 7157d1114..c0f606fa8 100644
--- a/docs/requirements.txt
+++ b/docs/requirements.txt
@@ -17,7 +17,7 @@ pytz==2023.3.post1
 requests==2.31.0
 snowballstemmer==2.2.0
 sphinx-favicon==1.0.1
-sphinx-rtd-theme==1.3.0
+sphinx-rtd-theme==2.0.0
 sphinxcontrib-applehelp==1.0.7
 sphinxcontrib-devhelp==1.0.5
 sphinxcontrib-htmlhelp==2.0.4
diff --git a/internal/codegen/golang/gen.go b/internal/codegen/golang/gen.go
index 54b742763..cbb86857b 100644
--- a/internal/codegen/golang/gen.go
+++ b/internal/codegen/golang/gen.go
@@ -39,6 +39,7 @@ type tmplCtx struct {
 	EmitAllEnumValues         bool
 	UsesCopyFrom              bool
 	UsesBatch                 bool
+	OmitSqlcVersion           bool
 	BuildTags                 string
 }
 
@@ -185,6 +186,7 @@ func generate(req *plugin.GenerateRequest, options *opts.Options, enums []Enum,
 		Structs:                   structs,
 		SqlcVersion:               req.SqlcVersion,
 		BuildTags:                 options.BuildTags,
+		OmitSqlcVersion:           options.OmitSqlcVersion,
 	}
 
 	if tctx.UsesCopyFrom && !tctx.SQLDriver.IsPGX() && options.SqlDriver != SQLDriverGoSQLDriverMySQL {
diff --git a/internal/codegen/golang/opts/options.go b/internal/codegen/golang/opts/options.go
index 6a1ed2a02..7325520e7 100644
--- a/internal/codegen/golang/opts/options.go
+++ b/internal/codegen/golang/opts/options.go
@@ -39,6 +39,7 @@ type Options struct {
 	OutputFilesSuffix           string            `json:"output_files_suffix,omitempty" yaml:"output_files_suffix"`
 	InflectionExcludeTableNames []string          `json:"inflection_exclude_table_names,omitempty" yaml:"inflection_exclude_table_names"`
 	QueryParameterLimit         *int32            `json:"query_parameter_limit,omitempty" yaml:"query_parameter_limit"`
+	OmitSqlcVersion             bool              `json:"omit_sqlc_version,omitempty" yaml:"omit_sqlc_version"`
 	OmitUnusedStructs           bool              `json:"omit_unused_structs,omitempty" yaml:"omit_unused_structs"`
 	BuildTags                   string            `json:"build_tags,omitempty" yaml:"build_tags"`
 }
diff --git a/internal/codegen/golang/templates/template.tmpl b/internal/codegen/golang/templates/template.tmpl
index 29f29801c..95400049c 100644
--- a/internal/codegen/golang/templates/template.tmpl
+++ b/internal/codegen/golang/templates/template.tmpl
@@ -3,8 +3,9 @@
 //go:build {{.BuildTags}}
 
 {{end}}// Code generated by sqlc. DO NOT EDIT.
-// versions:
+{{if not .OmitSqlcVersion}}// versions:
 //   sqlc {{.SqlcVersion}}
+{{end}}
 
 package {{.Package}}
 
@@ -33,8 +34,9 @@ import (
 //go:build {{.BuildTags}}
 
 {{end}}// Code generated by sqlc. DO NOT EDIT.
-// versions:
+{{if not .OmitSqlcVersion}}// versions:
 //   sqlc {{.SqlcVersion}}
+{{end}}
 
 package {{.Package}}
 
@@ -61,8 +63,9 @@ import (
 //go:build {{.BuildTags}}
 
 {{end}}// Code generated by sqlc. DO NOT EDIT.
-// versions:
+{{if not .OmitSqlcVersion}}// versions:
 //   sqlc {{.SqlcVersion}}
+{{end}}
 
 package {{.Package}}
 
@@ -158,9 +161,9 @@ type {{.Name}} struct { {{- range .Fields}}
 //go:build {{.BuildTags}}
 
 {{end}}// Code generated by sqlc. DO NOT EDIT.
-// versions:
+{{if not .OmitSqlcVersion}}// versions:
 //   sqlc {{.SqlcVersion}}
-// source: {{.SourceName}}
+{{end}}// source: {{.SourceName}}
 
 package {{.Package}}
 
@@ -187,9 +190,9 @@ import (
 //go:build {{.BuildTags}}
 
 {{end}}// Code generated by sqlc. DO NOT EDIT.
-// versions:
+{{if not .OmitSqlcVersion}}// versions:
 //   sqlc {{.SqlcVersion}}
-// source: {{.SourceName}}
+{{end}}// source: {{.SourceName}}
 
 package {{.Package}}
 
@@ -216,9 +219,9 @@ import (
 //go:build {{.BuildTags}}
 
 {{end}}// Code generated by sqlc. DO NOT EDIT.
-// versions:
+{{if not .OmitSqlcVersion}}// versions:
 //   sqlc {{.SqlcVersion}}
-// source: {{.SourceName}}
+{{end}}// source: {{.SourceName}}
 
 package {{.Package}}
 
diff --git a/internal/config/v_one.go b/internal/config/v_one.go
index a67511869..17c4fcffa 100644
--- a/internal/config/v_one.go
+++ b/internal/config/v_one.go
@@ -54,6 +54,7 @@ type v1PackageSettings struct {
 	StrictFunctionChecks      bool              `json:"strict_function_checks" yaml:"strict_function_checks"`
 	StrictOrderBy             *bool             `json:"strict_order_by" yaml:"strict_order_by"`
 	QueryParameterLimit       *int32            `json:"query_parameter_limit,omitempty" yaml:"query_parameter_limit"`
+	OmitSqlcVersion           bool              `json:"omit_sqlc_version,omitempty" yaml:"omit_sqlc_version"`
 	OmitUnusedStructs         bool              `json:"omit_unused_structs,omitempty" yaml:"omit_unused_structs"`
 	Rules                     []string          `json:"rules" yaml:"rules"`
 	BuildTags                 string            `json:"build_tags,omitempty" yaml:"build_tags"`
@@ -162,6 +163,7 @@ func (c *V1GenerateSettings) Translate() Config {
 					OutputCopyfromFileName:    pkg.OutputCopyFromFileName,
 					OutputFilesSuffix:         pkg.OutputFilesSuffix,
 					QueryParameterLimit:       pkg.QueryParameterLimit,
+					OmitSqlcVersion:           pkg.OmitSqlcVersion,
 					OmitUnusedStructs:         pkg.OmitUnusedStructs,
 					BuildTags:                 pkg.BuildTags,
 				},


Test patch:
diff --git a/internal/endtoend/testdata/omit_sqlc_version/db/db.go b/internal/endtoend/testdata/omit_sqlc_version/db/db.go
new file mode 100644
index 000000000..c3c034ae3
--- /dev/null
+++ b/internal/endtoend/testdata/omit_sqlc_version/db/db.go
@@ -0,0 +1,29 @@
+// Code generated by sqlc. DO NOT EDIT.
+
+package db
+
+import (
+	"context"
+	"database/sql"
+)
+
+type DBTX interface {
+	ExecContext(context.Context, string, ...interface{}) (sql.Result, error)
+	PrepareContext(context.Context, string) (*sql.Stmt, error)
+	QueryContext(context.Context, string, ...interface{}) (*sql.Rows, error)
+	QueryRowContext(context.Context, string, ...interface{}) *sql.Row
+}
+
+func New(db DBTX) *Queries {
+	return &Queries{db: db}
+}
+
+type Queries struct {
+	db DBTX
+}
+
+func (q *Queries) WithTx(tx *sql.Tx) *Queries {
+	return &Queries{
+		db: tx,
+	}
+}
diff --git a/internal/endtoend/testdata/omit_sqlc_version/db/models.go b/internal/endtoend/testdata/omit_sqlc_version/db/models.go
new file mode 100644
index 000000000..3bc48237e
--- /dev/null
+++ b/internal/endtoend/testdata/omit_sqlc_version/db/models.go
@@ -0,0 +1,13 @@
+// Code generated by sqlc. DO NOT EDIT.
+
+package db
+
+import (
+	"database/sql"
+)
+
+type Author struct {
+	ID   int64
+	Name string
+	Bio  sql.NullString
+}
diff --git a/internal/endtoend/testdata/omit_sqlc_version/db/query.sql.go b/internal/endtoend/testdata/omit_sqlc_version/db/query.sql.go
new file mode 100644
index 000000000..147cb4b15
--- /dev/null
+++ b/internal/endtoend/testdata/omit_sqlc_version/db/query.sql.go
@@ -0,0 +1,80 @@
+// Code generated by sqlc. DO NOT EDIT.
+// source: query.sql
+
+package db
+
+import (
+	"context"
+	"database/sql"
+)
+
+const createAuthor = `-- name: CreateAuthor :one
+INSERT INTO authors (
+  name, bio
+) VALUES (
+  $1, $2
+)
+RETURNING id, name, bio
+`
+
+type CreateAuthorParams struct {
+	Name string
+	Bio  sql.NullString
+}
+
+func (q *Queries) CreateAuthor(ctx context.Context, arg CreateAuthorParams) (Author, error) {
+	row := q.db.QueryRowContext(ctx, createAuthor, arg.Name, arg.Bio)
+	var i Author
+	err := row.Scan(&i.ID, &i.Name, &i.Bio)
+	return i, err
+}
+
+const deleteAuthor = `-- name: DeleteAuthor :exec
+DELETE FROM authors
+WHERE id = $1
+`
+
+func (q *Queries) DeleteAuthor(ctx context.Context, id int64) error {
+	_, err := q.db.ExecContext(ctx, deleteAuthor, id)
+	return err
+}
+
+const getAuthor = `-- name: GetAuthor :one
+SELECT id, name, bio FROM authors
+WHERE id = $1 LIMIT 1
+`
+
+func (q *Queries) GetAuthor(ctx context.Context, id int64) (Author, error) {
+	row := q.db.QueryRowContext(ctx, getAuthor, id)
+	var i Author
+	err := row.Scan(&i.ID, &i.Name, &i.Bio)
+	return i, err
+}
+
+const listAuthors = `-- name: ListAuthors :many
+SELECT id, name, bio FROM authors
+ORDER BY name
+`
+
+func (q *Queries) ListAuthors(ctx context.Context) ([]Author, error) {
+	rows, err := q.db.QueryContext(ctx, listAuthors)
+	if err != nil {
+		return nil, err
+	}
+	defer rows.Close()
+	var items []Author
+	for rows.Next() {
+		var i Author
+		if err := rows.Scan(&i.ID, &i.Name, &i.Bio); err != nil {
+			return nil, err
+		}
+		items = append(items, i)
+	}
+	if err := rows.Close(); err != nil {
+		return nil, err
+	}
+	if err := rows.Err(); err != nil {
+		return nil, err
+	}
+	return items, nil
+}
diff --git a/internal/endtoend/testdata/omit_sqlc_version/query.sql b/internal/endtoend/testdata/omit_sqlc_version/query.sql
new file mode 100644
index 000000000..971b8f902
--- /dev/null
+++ b/internal/endtoend/testdata/omit_sqlc_version/query.sql
@@ -0,0 +1,19 @@
+-- name: GetAuthor :one
+SELECT * FROM authors
+WHERE id = $1 LIMIT 1;
+
+-- name: ListAuthors :many
+SELECT * FROM authors
+ORDER BY name;
+
+-- name: CreateAuthor :one
+INSERT INTO authors (
+  name, bio
+) VALUES (
+  $1, $2
+)
+RETURNING *;
+
+-- name: DeleteAuthor :exec
+DELETE FROM authors
+WHERE id = $1;
diff --git a/internal/endtoend/testdata/omit_sqlc_version/schema.sql b/internal/endtoend/testdata/omit_sqlc_version/schema.sql
new file mode 100644
index 000000000..69b607d90
--- /dev/null
+++ b/internal/endtoend/testdata/omit_sqlc_version/schema.sql
@@ -0,0 +1,5 @@
+CREATE TABLE authors (
+  id   BIGSERIAL PRIMARY KEY,
+  name text      NOT NULL,
+  bio  text
+);
diff --git a/internal/endtoend/testdata/omit_sqlc_version/sqlc.json b/internal/endtoend/testdata/omit_sqlc_version/sqlc.json
new file mode 100644
index 000000000..f86d2b7b9
--- /dev/null
+++ b/internal/endtoend/testdata/omit_sqlc_version/sqlc.json
@@ -0,0 +1,15 @@
+{
+  "version": "2",
+  "sql": [{
+    "schema": "schema.sql",
+    "queries": "query.sql",
+    "engine": "postgresql",
+    "gen": {
+      "go": {
+        "out": "db",
+        "omit_sqlc_version": true
+      }
+    }
+  }]
+}
+