Skip to content

Commit

Permalink
update to reflect interface changes in go-reader v0.4.x
Browse files Browse the repository at this point in the history
  • Loading branch information
thisisaaronland committed Feb 23, 2021
1 parent 798f6b5 commit 8707874
Show file tree
Hide file tree
Showing 11 changed files with 319 additions and 25 deletions.
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module github.com/whosonfirst/go-reader-database-sql

go 1.12
go 1.16

require github.com/whosonfirst/go-reader v0.2.0
require github.com/whosonfirst/go-reader v0.4.1
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ github.com/whosonfirst/go-reader v0.1.1 h1:0fXoYQR/Yyh3PKk+9Huwoc6dCAt8l1tjg2dES
github.com/whosonfirst/go-reader v0.1.1/go.mod h1:w0AeU+Ojyfmxb7r+rcSYyxpCxrhxlHv+D9EgEwQsqcM=
github.com/whosonfirst/go-reader v0.2.0 h1:Et8rvkh+86msAo4Db4h88m1t2QDSMNr3rLy6RqJzeJc=
github.com/whosonfirst/go-reader v0.2.0/go.mod h1:qUhz3OWefOUX/G1nzCEUzJskDjkF+l9oKPOM3K2fAJI=
github.com/whosonfirst/go-reader v0.4.1 h1:gN73LR/gdtWtuCikOc84rtuMIbIu6fi7RPRZgssKL9I=
github.com/whosonfirst/go-reader v0.4.1/go.mod h1:ffg8ww1158rNNqStFx64EGmDL5m5WZPsoMqR6wohOWE=
github.com/whosonfirst/go-whosonfirst-reader v0.0.0-20191122203133-047f20452865/go.mod h1:xYzBn6llLD/uS6Zhh0H4LAqddEJHXdQSUIxywTnhpOU=
github.com/whosonfirst/go-whosonfirst-sources v0.1.0/go.mod h1:EUMHyGzUmqPPxlMmOp+28BFeoBdxxE0HCKRd67lkqGM=
github.com/whosonfirst/go-whosonfirst-uri v0.1.0/go.mod h1:8eaDVcc4v+HHHEDaRbApdmhPwM4/JQllw2PktvZcPVs=
Expand Down
30 changes: 26 additions & 4 deletions sql.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"errors"
"fmt"
wof_reader "github.com/whosonfirst/go-reader"
"github.com/whosonfirst/go-reader/ioutil"
"io"
"io/ioutil"
_ "log"
"net/url"
"regexp"
Expand Down Expand Up @@ -47,7 +47,7 @@ type SQLReader struct {
value string
}

// sql://sqlite/geojson/id/body/?dsn=....
// sql://sqlite/geojson/id/body?dsn=....

func NewSQLReader(ctx context.Context, uri string) (wof_reader.Reader, error) {

Expand Down Expand Up @@ -107,7 +107,7 @@ func NewSQLReader(ctx context.Context, uri string) (wof_reader.Reader, error) {
return r, nil
}

func (r *SQLReader) Read(ctx context.Context, raw_uri string) (io.ReadCloser, error) {
func (r *SQLReader) Read(ctx context.Context, raw_uri string) (io.ReadSeekCloser, error) {

uri := raw_uri

Expand Down Expand Up @@ -158,7 +158,29 @@ func (r *SQLReader) Read(ctx context.Context, raw_uri string) (io.ReadCloser, er
}

sr := strings.NewReader(body)
fh := ioutil.NopCloser(sr)
fh, err := ioutil.NewReadSeekCloser(sr)

if err != nil {
return nil, err
}

return fh, nil
}

func (r *SQLReader) ReaderURI(ctx context.Context, raw_uri string) string {

uri := raw_uri

if URI_READFUNC != nil {

new_uri, err := URI_READFUNC(raw_uri)

if err != nil {
return ""
}

uri = new_uri
}

return uri
}
8 changes: 4 additions & 4 deletions vendor/github.com/whosonfirst/go-reader/README.md

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

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

2 changes: 1 addition & 1 deletion vendor/github.com/whosonfirst/go-reader/go.mod

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

116 changes: 116 additions & 0 deletions vendor/github.com/whosonfirst/go-reader/ioutil/readseekcloser.go

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

Loading

0 comments on commit 8707874

Please sign in to comment.