Repository: sqlc-dev/sqlc
Pull request #2641 (2023-08-21 10:21:48)

build(deps): bump sphinxcontrib-serializinghtml from 1.1.5 to 1.1.9 in /docs
Bumps [sphinxcontrib-serializinghtml](https://github.com/sphinx-doc/sphinxcontrib-serializinghtml) from 1.1.5 to 1.1.9.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a href="https://github.com/sphinx-doc/sphinxcontrib-serializinghtml/releases">sphinxcontrib-serializinghtml's releases</a>.</em></p>
<blockquote>
<h2>sphinxcontrib-serializinghtml 1.1.9</h2>
<p>Changelog: <a href="https://www.sphinx-doc.org/en/master/changes.html">https://www.sphinx-doc.org/en/master/changes.html</a></p>
<h2>sphinxcontrib-serializinghtml 1.1.8</h2>
<p>Changelog: <a href="https://www.sphinx-doc.org/en/master/changes.html">https://www.sphinx-doc.org/en/master/changes.html</a></p>
<h2>sphinxcontrib-serializinghtml 1.1.7</h2>
<p>Changelog: <a href="https://www.sphinx-doc.org/en/master/changes.html">https://www.sphinx-doc.org/en/master/changes.html</a></p>
<h2>sphinxcontrib-serializinghtml 1.1.6</h2>
<p>Changelog: <a href="https://www.sphinx-doc.org/en/master/changes.html">https://www.sphinx-doc.org/en/master/changes.html</a></p>
</blockquote>
</details>
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a href="https://github.com/sphinx-doc/sphinxcontrib-serializinghtml/blob/master/CHANGES">sphinxcontrib-serializinghtml's changelog</a>.</em></p>
<blockquote>
<h1>Release 1.1.9 (2023-08-20)</h1>
<ul>
<li>Serialise context[&quot;script_files&quot;] and context[&quot;css_files&quot;] as their filenames
on Sphinx 7.2.0.</li>
</ul>
<h1>Release 1.1.8 (2023-08-14)</h1>
<ul>
<li>Use <code>os.PathLike</code> over <code>pathlib.Path</code></li>
</ul>
<h1>Release 1.1.7 (2023-08-09)</h1>
<ul>
<li>Fix tests for Sphinx 7.1 and below</li>
</ul>
<h1>Release 1.1.6 (2023-08-07)</h1>
<ul>
<li>Drop support for Python 3.5, 3.6, 3.7, and 3.8</li>
<li>Raise minimum required Sphinx version to 5.0</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="https://github.com/sphinx-doc/sphinxcontrib-serializinghtml/commit/ff4bcae545fb6e5b923cc51cc37944c18307a49a"><code>ff4bcae</code></a> Bump to 1.1.9 final</li>
<li><a href="https://github.com/sphinx-doc/sphinxcontrib-serializinghtml/commit/5c62ad4219698d410426e99495203e9484d77f29"><code>5c62ad4</code></a> Properly serialise css_files and script_files</li>
<li><a href="https://github.com/sphinx-doc/sphinxcontrib-serializinghtml/commit/fde139af6b2bfad8a6b8d20886b657a174f05c22"><code>fde139a</code></a> Bump to 1.1.8 final</li>
<li><a href="https://github.com/sphinx-doc/sphinxcontrib-serializinghtml/commit/b3ed89b4b2bf9eee553ff2272ae97fc5c0a9bc31"><code>b3ed89b</code></a> Use <code>os.PathLike</code> over <code>pathlib.Path</code></li>
<li><a href="https://github.com/sphinx-doc/sphinxcontrib-serializinghtml/commit/957d087692515b6cdd918ebd0c99591b7d04f76f"><code>957d087</code></a> Bump to 1.1.7 final</li>
<li><a href="https://github.com/sphinx-doc/sphinxcontrib-serializinghtml/commit/4ba0bbc9cd166a2512d7e3a502fa8159f3669685"><code>4ba0bbc</code></a> Restore support in tests for <code>Sphinx&lt;7.2</code></li>
<li><a href="https://github.com/sphinx-doc/sphinxcontrib-serializinghtml/commit/5c00ac15e2ade99e99f36402b1f6befb1be1affa"><code>5c00ac1</code></a> Run pytest with <code>-vv</code></li>
<li><a href="https://github.com/sphinx-doc/sphinxcontrib-serializinghtml/commit/010ed5629dd70e77c6df7cf753e6c93270254811"><code>010ed56</code></a> Test Sphinx's master branch distinctly from ordinary tests</li>
<li><a href="https://github.com/sphinx-doc/sphinxcontrib-serializinghtml/commit/5b964aed7db1368cc203fbfcb618b655cb2177b1"><code>5b964ae</code></a> Fix GitHub Release workflow</li>
<li><a href="https://github.com/sphinx-doc/sphinxcontrib-serializinghtml/commit/9ad2844331739f18e59177dce02c749459f08e18"><code>9ad2844</code></a> Bump to 1.1.6 final</li>
<li>Additional commits viewable in <a href="https://github.com/sphinx-doc/sphinxcontrib-serializinghtml/compare/1.1.5...1.1.9">compare view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=sphinxcontrib-serializinghtml&package-manager=pip&previous-version=1.1.5&new-version=1.1.9)](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 25d6e174d..eeb70a317 100644
--- a/docs/requirements.txt
+++ b/docs/requirements.txt
@@ -20,7 +20,7 @@ sphinx-favicon==1.0.1
 sphinx-rtd-theme==1.2.2
 sphinxcontrib-applehelp==1.0.7
 sphinxcontrib-devhelp==1.0.2
-sphinxcontrib-serializinghtml==1.1.5
+sphinxcontrib-serializinghtml==1.1.9
 sphinxcontrib-htmlhelp==2.0.1
 sphinxcontrib-jsmath==1.0.1
 sphinxcontrib-qthelp==1.0.6
diff --git a/go.mod b/go.mod
index fd2f91a41..0c9f4e145 100644
--- a/go.mod
+++ b/go.mod
@@ -33,6 +33,7 @@ require (
 
 require (
 	github.com/cznic/mathutil v0.0.0-20181122101859-297441e03548 // indirect
+	github.com/fatih/structtag v1.2.0 // indirect
 	github.com/golang/protobuf v1.5.3 // indirect
 	github.com/inconshreveable/mousetrap v1.1.0 // indirect
 	github.com/jackc/chunkreader/v2 v2.0.1 // indirect
diff --git a/go.sum b/go.sum
index 92cda9085..7ac2f0456 100644
--- a/go.sum
+++ b/go.sum
@@ -20,6 +20,8 @@ github.com/cznic/mathutil v0.0.0-20181122101859-297441e03548/go.mod h1:e6NPNENfs
 github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
 github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
 github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
+github.com/fatih/structtag v1.2.0 h1:/OdNE99OxoI/PqaW/SuSK9uxxT3f/tcSZgon/ssNSx4=
+github.com/fatih/structtag v1.2.0/go.mod h1:mBJUNpUnHmRKrKlQQlmCrh5PuhftFbNv8Ys4/aAZl94=
 github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY=
 github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A=
 github.com/go-sql-driver/mysql v1.7.1 h1:lUIinVbN1DY0xBg0eMOzmmtGoHwWBbvnWubQUrtU8EI=
diff --git a/internal/config/go_type.go b/internal/config/go_type.go
index 078360e57..14765e5f3 100644
--- a/internal/config/go_type.go
+++ b/internal/config/go_type.go
@@ -6,6 +6,8 @@ import (
 	"go/types"
 	"regexp"
 	"strings"
+
+	"github.com/fatih/structtag"
 )
 
 type GoType struct {
@@ -171,16 +173,12 @@ type GoStructTag string
 // `a:"b" x:"y,z"`   {"a": "b", "x": "y,z"}
 func (s GoStructTag) Parse() (map[string]string, error) {
 	m := make(map[string]string)
-	fields := strings.Fields(string(s))
-	for _, f := range fields {
-		k, v, ok := strings.Cut(f, ":")
-		if !ok {
-			return nil, fmt.Errorf("Failed to parse Go struct tag: no colon in field %q", f)
-		}
-		if len(v) < 2 || v[0] != '"' || v[len(v)-1] != '"' {
-			return nil, fmt.Errorf("Failed to parse Go struct tag: missing quotes around value in field %q", f)
-		}
-		m[k] = v[1 : len(v)-1] // trim quotes off of v
+	tags, err := structtag.Parse(string(s))
+	if err != nil {
+		return nil, err
+	}
+	for _, tag := range tags.Tags() {
+		m[tag.Key] = tag.Value()
 	}
 	return m, nil
 }


Test patch:
diff --git a/internal/endtoend/testdata/overrides_go_struct_tags/invalid_tags/stderr.txt b/internal/endtoend/testdata/overrides_go_struct_tags/invalid_tags/stderr.txt
index 4624d612a..cb6fb84ae 100644
--- a/internal/endtoend/testdata/overrides_go_struct_tags/invalid_tags/stderr.txt
+++ b/internal/endtoend/testdata/overrides_go_struct_tags/invalid_tags/stderr.txt
@@ -1,1 +1,1 @@
-error parsing sqlc.json: Failed to parse Go struct tag: no colon in field "abc"
+error parsing sqlc.json: bad syntax for struct tag pair
diff --git a/internal/endtoend/testdata/overrides_go_struct_tags/sqlite/go/models.go b/internal/endtoend/testdata/overrides_go_struct_tags/sqlite/go/models.go
index 5942323c9..bb63a04c3 100644
--- a/internal/endtoend/testdata/overrides_go_struct_tags/sqlite/go/models.go
+++ b/internal/endtoend/testdata/overrides_go_struct_tags/sqlite/go/models.go
@@ -9,14 +9,17 @@ import ()
 type Bar struct {
 	Other      string
 	AlsoTagged string `also:"tagged"`
+	Tag3       string `tag_with_space:" it's legal!"`
 }
 
 type Baz struct {
 	Other      string
 	AlsoTagged string `also:"tagged"`
+	Tag3       string `tag_with_space:" it's legal!"`
 }
 
 type Foo struct {
 	Other  string
 	Tagged string `a:"b" x:"y,z"`
+	Tag3   string `tag_with_space:" it's legal!"`
 }
diff --git a/internal/endtoend/testdata/overrides_go_struct_tags/sqlite/schema.sql b/internal/endtoend/testdata/overrides_go_struct_tags/sqlite/schema.sql
index 4d5233cc3..f908060db 100644
--- a/internal/endtoend/testdata/overrides_go_struct_tags/sqlite/schema.sql
+++ b/internal/endtoend/testdata/overrides_go_struct_tags/sqlite/schema.sql
@@ -1,14 +1,17 @@
 CREATE TABLE foo (
     other     text NOT NULL,
-    tagged    text NOT NULL
+    tagged    text NOT NULL,
+    tag3      text NOT NULL
 );
 
 CREATE TABLE bar (
     other          text NOT NULL,
-    also_tagged    text NOT NULL
+    also_tagged    text NOT NULL,
+    tag3           text NOT NULL
 );
 
 CREATE TABLE baz (
     other          text NOT NULL,
-    also_tagged    text NOT NULL
+    also_tagged    text NOT NULL,
+    tag3           text NOT NULL
 );
diff --git a/internal/endtoend/testdata/overrides_go_struct_tags/sqlite/sqlc.json b/internal/endtoend/testdata/overrides_go_struct_tags/sqlite/sqlc.json
index 0be626d44..a4d54cc3d 100644
--- a/internal/endtoend/testdata/overrides_go_struct_tags/sqlite/sqlc.json
+++ b/internal/endtoend/testdata/overrides_go_struct_tags/sqlite/sqlc.json
@@ -15,6 +15,10 @@
         {
           "go_struct_tag": "also:\"tagged\"",
           "column": "*.also_tagged"
+        },
+        {
+          "go_struct_tag": "tag_with_space:\" it's legal!\"",
+          "column": "*.tag3"
         }
       ]
     }