Skip to content

Commit 2438707

Browse files
committed
Update Indexes() to also return column information
1 parent afc3cbe commit 2438707

File tree

8 files changed

+29
-12
lines changed

8 files changed

+29
-12
lines changed

README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ A Go library for accessing and using SQLite databases stored remotely on DBHub.i
99

1010
* Run read-only queries (eg SELECT statements) on databases, returning the results as JSON
1111
* List the databases in your account
12-
* List the names of tables, views, and indexes present in a database
13-
* List the columns present in a table or view, along with their details
12+
* List the tables, views, and indexes present in a database
13+
* List the columns in a table, view or index, along with their details
1414
* List the branches, releases, tags, and commits for a database
1515
* Generate diffs between two databases, or database revisions
1616
* Download a complete database
@@ -19,7 +19,6 @@ A Go library for accessing and using SQLite databases stored remotely on DBHub.i
1919
### Still to do
2020

2121
* Tests for each function
22-
* Retrieve index details for a database
2322
* Upload a complete database
2423
* Investigate what would be needed for this to work through the Go SQL API
2524
* Anything else people suggest and seems like a good idea :smile:

dbhub.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ func (c Connection) Download(dbOwner, dbName string, ident Identifier) (db io.Re
149149
}
150150

151151
// Indexes returns the list of indexes present in the database, along with the table they belong to
152-
func (c Connection) Indexes(dbOwner, dbName string, ident Identifier) (idx map[string]string, err error) {
152+
func (c Connection) Indexes(dbOwner, dbName string, ident Identifier) (idx []com.APIJSONIndex, err error) {
153153
// Prepare the API parameters
154154
data := c.PrepareVals(dbOwner, dbName, ident)
155155

examples/list_indexes/main.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,11 @@ func main() {
2222

2323
// Display the retrieved list of indexes
2424
fmt.Println("Indexes:")
25-
for i, j := range indexes {
26-
fmt.Printf(" * '%s' on table '%s'\n", i, j)
25+
for _, j := range indexes {
26+
fmt.Printf(" * '%s' on table '%s'\n", j.Name, j.Table)
27+
for _, l := range j.Columns {
28+
fmt.Printf(" Column name: %v\n", l.Name)
29+
fmt.Printf(" Column ID: %v\n", l.CID)
30+
}
2731
}
28-
fmt.Println()
2932
}

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ replace (
1010
github.com/Sirupsen/logrus v1.6.0 => github.com/sirupsen/logrus v1.6.0
1111
)
1212

13-
require github.com/sqlitebrowser/dbhub.io v0.0.10
13+
require github.com/sqlitebrowser/dbhub.io v0.0.11

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,8 @@ github.com/sourcegraph/syntaxhighlight v0.0.0-20170531221838-bd320f5d308e h1:qpG
123123
github.com/sourcegraph/syntaxhighlight v0.0.0-20170531221838-bd320f5d308e/go.mod h1:HuIsMU8RRBOtsCgI77wP899iHVBQpCmg4ErYMZB+2IA=
124124
github.com/sqlitebrowser/blackfriday v9.0.0+incompatible h1:ddH/UyzasooYgGIblVU4R8DdmBuJ7QXLvSqX/0chZv4=
125125
github.com/sqlitebrowser/blackfriday v9.0.0+incompatible/go.mod h1:/zga9sqpWzcewuI83AO5JZwe9+6F9GgPDdqqdNNEL/0=
126-
github.com/sqlitebrowser/dbhub.io v0.0.10 h1:Vg9LMABya1a/nHeUZ/YiMFEfKwmmDHM/f0vv0Iw0FWk=
127-
github.com/sqlitebrowser/dbhub.io v0.0.10/go.mod h1:GgZi8wkjdRGkkUVgYNuZp5i+Yps3jGt/jjRuLKRi6Po=
126+
github.com/sqlitebrowser/dbhub.io v0.0.11 h1:Ddkjiftx/q5+ZFbOHIvuK6mQk1ACs/3jea7AbwDJlYA=
127+
github.com/sqlitebrowser/dbhub.io v0.0.11/go.mod h1:GgZi8wkjdRGkkUVgYNuZp5i+Yps3jGt/jjRuLKRi6Po=
128128
github.com/sqlitebrowser/github_flavored_markdown v0.0.0-20190120045821-b8cf8f054e47 h1:s0+Ea95n1LrsKh6rtclU/9Qb2/5ofvnfnR7gDDiFTw8=
129129
github.com/sqlitebrowser/github_flavored_markdown v0.0.0-20190120045821-b8cf8f054e47/go.mod h1:8vPIKi5FslxCXEgfQxrFtWfdclGy6VWAc9NA1ZTYCJg=
130130
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=

vendor/github.com/sqlitebrowser/dbhub.io/common/responses.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/sqlitebrowser/dbhub.io/common/types.go

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/modules.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ github.com/sourcegraph/annotate
6363
github.com/sourcegraph/syntaxhighlight
6464
# github.com/sqlitebrowser/blackfriday v9.0.0+incompatible
6565
github.com/sqlitebrowser/blackfriday
66-
# github.com/sqlitebrowser/dbhub.io v0.0.10
66+
# github.com/sqlitebrowser/dbhub.io v0.0.11
6767
## explicit
6868
github.com/sqlitebrowser/dbhub.io/common
6969
# github.com/sqlitebrowser/github_flavored_markdown v0.0.0-20190120045821-b8cf8f054e47

0 commit comments

Comments
 (0)