diff --git a/go.mod b/go.mod index 5f65ba07..7656460b 100644 --- a/go.mod +++ b/go.mod @@ -13,6 +13,6 @@ require ( github.com/whosonfirst/go-whosonfirst-spr/v2 v2.0.0 github.com/whosonfirst/go-whosonfirst-sqlite v0.1.7 github.com/whosonfirst/go-whosonfirst-sqlite-features v0.8.0 - github.com/whosonfirst/go-whosonfirst-sqlite-spr v0.0.6 + github.com/whosonfirst/go-whosonfirst-sqlite-spr v0.0.10 github.com/whosonfirst/go-whosonfirst-uri v1.0.1 ) diff --git a/go.sum b/go.sum index 6be0db6f..bc645118 100644 --- a/go.sum +++ b/go.sum @@ -151,6 +151,8 @@ github.com/whosonfirst/go-whosonfirst-flags v0.2.0/go.mod h1:ECd0AJJZIlybmjTGB9z github.com/whosonfirst/go-whosonfirst-flags v0.4.0/go.mod h1:kewFjxBiE00SqjjIanm5DPI81SYvx93wVb3ogwV/PMk= github.com/whosonfirst/go-whosonfirst-flags v0.4.2 h1:HWjy/0MfAQMdCj4M9hi3LAITgK/D+cuDWGHP37mFeZo= github.com/whosonfirst/go-whosonfirst-flags v0.4.2/go.mod h1:kewFjxBiE00SqjjIanm5DPI81SYvx93wVb3ogwV/PMk= +github.com/whosonfirst/go-whosonfirst-flags v0.4.3 h1:ef6IkgvYADL4kc750sl6i5hkReNq0Z6upLcqpK2CHLY= +github.com/whosonfirst/go-whosonfirst-flags v0.4.3/go.mod h1:pL17Ryo60FH8RYaQRgfu5XnxhrNRK3x+rn03TYD6Gc8= github.com/whosonfirst/go-whosonfirst-geojson-v2 v0.16.0 h1:o+Q4noTqXYKeDD+dMrf4lb1yFvly5PDAcF4ASKwHwpc= github.com/whosonfirst/go-whosonfirst-geojson-v2 v0.16.0/go.mod h1:cWVV68R2xgKtmOcAsQmWYsdv8QhIhT4k9DmqRbqrt/4= github.com/whosonfirst/go-whosonfirst-geojson-v2 v0.16.1 h1:zUJoEVZzmstNybujlUkLXMbJ4ucKIfLS9IgIX0XE/Sk= @@ -198,6 +200,8 @@ github.com/whosonfirst/go-whosonfirst-sqlite-spr v0.0.5 h1:DMuJjBjLeBOmK73sov+Gp github.com/whosonfirst/go-whosonfirst-sqlite-spr v0.0.5/go.mod h1:av6zq/jP7ACZqJ2dYjCmBH5Oea+eLLLq9u1agmYvMP8= github.com/whosonfirst/go-whosonfirst-sqlite-spr v0.0.6 h1:9Y3P9YAYGJQogi7ZNic3uPjsfRXWqhQGq5/PDXYe7ts= github.com/whosonfirst/go-whosonfirst-sqlite-spr v0.0.6/go.mod h1:av6zq/jP7ACZqJ2dYjCmBH5Oea+eLLLq9u1agmYvMP8= +github.com/whosonfirst/go-whosonfirst-sqlite-spr v0.0.10 h1:5bNZ8Wh1cip3GsWcUxx+vZPG0qbMl7/2nzPx+F1yp5Q= +github.com/whosonfirst/go-whosonfirst-sqlite-spr v0.0.10/go.mod h1:MV6kulNQDSiFMYD/mWJsL719ZO1WAoNn/SySp7+Jxx8= github.com/whosonfirst/go-whosonfirst-uri v0.2.0 h1:iODHdyvW+8IXqHZTixZ/9GEZy1dVKGj6dMRg7fn0d2M= github.com/whosonfirst/go-whosonfirst-uri v0.2.0/go.mod h1:8eaDVcc4v+HHHEDaRbApdmhPwM4/JQllw2PktvZcPVs= github.com/whosonfirst/go-whosonfirst-uri v1.0.1 h1:hVEDRuW9WhqvTksDi092OO9UecX7PAMDrD47KPEqAg0= diff --git a/vendor/github.com/whosonfirst/go-whosonfirst-flags/go.mod b/vendor/github.com/whosonfirst/go-whosonfirst-flags/go.mod index 2dac10ec..ad582803 100644 --- a/vendor/github.com/whosonfirst/go-whosonfirst-flags/go.mod +++ b/vendor/github.com/whosonfirst/go-whosonfirst-flags/go.mod @@ -3,7 +3,7 @@ module github.com/whosonfirst/go-whosonfirst-flags go 1.12 require ( - github.com/sfomuseum/go-edtf v0.2.2 + github.com/sfomuseum/go-edtf v0.2.3 github.com/whosonfirst/go-whosonfirst-placetypes v0.3.0 - github.com/whosonfirst/go-whosonfirst-uri v0.2.0 + github.com/whosonfirst/go-whosonfirst-uri v1.0.1 ) diff --git a/vendor/github.com/whosonfirst/go-whosonfirst-flags/go.sum b/vendor/github.com/whosonfirst/go-whosonfirst-flags/go.sum index a50ccb76..6e3d765e 100644 --- a/vendor/github.com/whosonfirst/go-whosonfirst-flags/go.sum +++ b/vendor/github.com/whosonfirst/go-whosonfirst-flags/go.sum @@ -6,6 +6,8 @@ github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfV github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/sfomuseum/go-edtf v0.2.2 h1:8n1UekTCU6fkgAf3bWqG5RyQxOd9hRhy4lg91aQ3kMk= github.com/sfomuseum/go-edtf v0.2.2/go.mod h1:1rP0EJZ/84j3HO80vGcnG2T9MFBDAFyTNtjrr8cv3T4= +github.com/sfomuseum/go-edtf v0.2.3 h1:wpcpwl1RD9W/sXFDi4zpoIpQcIwIk8em9CGwa7YWv4g= +github.com/sfomuseum/go-edtf v0.2.3/go.mod h1:1rP0EJZ/84j3HO80vGcnG2T9MFBDAFyTNtjrr8cv3T4= github.com/sfomuseum/go-flags v0.7.0/go.mod h1:ML3DTNbF9xnjExSdS/9FtVLjIUhRU5gm/ehzISv+t2w= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= github.com/smartystreets/goconvey v0.0.0-20190330032615-68dc04aab96a/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= @@ -20,6 +22,8 @@ github.com/whosonfirst/go-whosonfirst-sources v0.1.0 h1:JuKLa6KWke22jBfJ1pM9WQHo github.com/whosonfirst/go-whosonfirst-sources v0.1.0/go.mod h1:EUMHyGzUmqPPxlMmOp+28BFeoBdxxE0HCKRd67lkqGM= github.com/whosonfirst/go-whosonfirst-uri v0.2.0 h1:iODHdyvW+8IXqHZTixZ/9GEZy1dVKGj6dMRg7fn0d2M= github.com/whosonfirst/go-whosonfirst-uri v0.2.0/go.mod h1:8eaDVcc4v+HHHEDaRbApdmhPwM4/JQllw2PktvZcPVs= +github.com/whosonfirst/go-whosonfirst-uri v1.0.1 h1:hVEDRuW9WhqvTksDi092OO9UecX7PAMDrD47KPEqAg0= +github.com/whosonfirst/go-whosonfirst-uri v1.0.1/go.mod h1:8eaDVcc4v+HHHEDaRbApdmhPwM4/JQllw2PktvZcPVs= github.com/whosonfirst/warning v0.1.0/go.mod h1:cAez7FpC/UEUrbiOXZO15v2JM8eijtFHQlN93AGFy1k= github.com/whosonfirst/warning v0.1.1/go.mod h1:/unEMzhB9YaMeEwTJpzLN3kM5LiSxdJhKEsf/OQhn6s= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= diff --git a/vendor/github.com/whosonfirst/go-whosonfirst-sqlite-spr/go.mod b/vendor/github.com/whosonfirst/go-whosonfirst-sqlite-spr/go.mod index 36d539b4..dc3f68f8 100644 --- a/vendor/github.com/whosonfirst/go-whosonfirst-sqlite-spr/go.mod +++ b/vendor/github.com/whosonfirst/go-whosonfirst-sqlite-spr/go.mod @@ -4,8 +4,8 @@ go 1.16 require ( github.com/sfomuseum/go-edtf v0.2.3 - github.com/whosonfirst/go-whosonfirst-flags v0.4.2 + github.com/whosonfirst/go-whosonfirst-flags v0.4.3 github.com/whosonfirst/go-whosonfirst-spr/v2 v2.0.0 github.com/whosonfirst/go-whosonfirst-sqlite v0.1.7 - github.com/whosonfirst/go-whosonfirst-uri v0.2.0 + github.com/whosonfirst/go-whosonfirst-uri v1.0.1 ) diff --git a/vendor/github.com/whosonfirst/go-whosonfirst-sqlite-spr/go.sum b/vendor/github.com/whosonfirst/go-whosonfirst-sqlite-spr/go.sum index 86426e86..ee53284c 100644 --- a/vendor/github.com/whosonfirst/go-whosonfirst-sqlite-spr/go.sum +++ b/vendor/github.com/whosonfirst/go-whosonfirst-sqlite-spr/go.sum @@ -29,6 +29,8 @@ github.com/whosonfirst/go-whosonfirst-flags v0.4.0 h1:3qEz1v7rALk+TqVstW9DKQOWrM github.com/whosonfirst/go-whosonfirst-flags v0.4.0/go.mod h1:kewFjxBiE00SqjjIanm5DPI81SYvx93wVb3ogwV/PMk= github.com/whosonfirst/go-whosonfirst-flags v0.4.2 h1:HWjy/0MfAQMdCj4M9hi3LAITgK/D+cuDWGHP37mFeZo= github.com/whosonfirst/go-whosonfirst-flags v0.4.2/go.mod h1:kewFjxBiE00SqjjIanm5DPI81SYvx93wVb3ogwV/PMk= +github.com/whosonfirst/go-whosonfirst-flags v0.4.3 h1:ef6IkgvYADL4kc750sl6i5hkReNq0Z6upLcqpK2CHLY= +github.com/whosonfirst/go-whosonfirst-flags v0.4.3/go.mod h1:pL17Ryo60FH8RYaQRgfu5XnxhrNRK3x+rn03TYD6Gc8= github.com/whosonfirst/go-whosonfirst-placetypes v0.1.0/go.mod h1:Jdmug2QQLbrmg+UcYGz8k575GnrOEg63vZVS46e5fMs= github.com/whosonfirst/go-whosonfirst-placetypes v0.2.4/go.mod h1:yl0zZ5tfK80C0kl34pJcPB3mZC5XXR7ybQJ5OJyEcDU= github.com/whosonfirst/go-whosonfirst-placetypes v0.3.0/go.mod h1:ez0VFkGFbgT2/z2oi3PIuW6FewsZ2+5glyfDD79XEHk= @@ -44,6 +46,8 @@ github.com/whosonfirst/go-whosonfirst-sqlite v0.1.7 h1:WZOGRgD2UmQWYOITWNpTWcccd github.com/whosonfirst/go-whosonfirst-sqlite v0.1.7/go.mod h1:Vz7VscOjc7oS99GFGLJMyQj++nWuAQ/F/dCFzEzyYg0= github.com/whosonfirst/go-whosonfirst-uri v0.2.0 h1:iODHdyvW+8IXqHZTixZ/9GEZy1dVKGj6dMRg7fn0d2M= github.com/whosonfirst/go-whosonfirst-uri v0.2.0/go.mod h1:8eaDVcc4v+HHHEDaRbApdmhPwM4/JQllw2PktvZcPVs= +github.com/whosonfirst/go-whosonfirst-uri v1.0.1 h1:hVEDRuW9WhqvTksDi092OO9UecX7PAMDrD47KPEqAg0= +github.com/whosonfirst/go-whosonfirst-uri v1.0.1/go.mod h1:8eaDVcc4v+HHHEDaRbApdmhPwM4/JQllw2PktvZcPVs= github.com/whosonfirst/warning v0.1.0/go.mod h1:cAez7FpC/UEUrbiOXZO15v2JM8eijtFHQlN93AGFy1k= github.com/whosonfirst/warning v0.1.1/go.mod h1:/unEMzhB9YaMeEwTJpzLN3kM5LiSxdJhKEsf/OQhn6s= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= diff --git a/vendor/github.com/whosonfirst/go-whosonfirst-sqlite-spr/spr.go b/vendor/github.com/whosonfirst/go-whosonfirst-sqlite-spr/spr.go index 5e7907fd..6e7854e3 100644 --- a/vendor/github.com/whosonfirst/go-whosonfirst-sqlite-spr/spr.go +++ b/vendor/github.com/whosonfirst/go-whosonfirst-sqlite-spr/spr.go @@ -2,6 +2,7 @@ package spr import ( "context" + "database/sql" "fmt" "github.com/sfomuseum/go-edtf" "github.com/sfomuseum/go-edtf/parser" @@ -197,6 +198,34 @@ func RetrieveSPR(ctx context.Context, spr_db *wof_database.SQLiteDatabase, spr_t FROM %s WHERE id = ? AND alt_label = ?`, spr_table.Name()) row := conn.QueryRowContext(ctx, spr_q, args...) + return RetrieveSPRWithRow(ctx, row) +} + +// See notes below + +func RetrieveSPRWithRow(ctx context.Context, row *sql.Row) (wof_spr.StandardPlacesResult, error) { + return retrieveSPRWithScanner(ctx, row) +} + +// See notes below + +func RetrieveSPRWithRows(ctx context.Context, rows *sql.Rows) (wof_spr.StandardPlacesResult, error) { + return retrieveSPRWithScanner(ctx, rows) +} + +// We go to the trouble of all this indirection because neither *sql.Row or *sql.Rows implement +// the sql.Scanner interface. +// The latter expects: Scan(src interface{}) error +// But the former pxpect: Scan(src ...interface{}) error + +func retrieveSPRWithScanner(ctx context.Context, scanner interface{}) (wof_spr.StandardPlacesResult, error) { + + switch scanner.(type) { + case *sql.Row, *sql.Rows: + // pass + default: + return nil, fmt.Errorf("Unsupported scanner") + } var spr_id string var parent_id string @@ -228,19 +257,51 @@ func RetrieveSPR(ctx context.Context, spr_db *wof_database.SQLiteDatabase, spr_t var str_superseded_by string var str_belongs_to string + var is_alt int64 + var alt_label string + var lastmodified int64 // supersedes and superseding need to be added here pending // https://github.com/whosonfirst/go-whosonfirst-sqlite-features/issues/14 - err = row.Scan( - &spr_id, &parent_id, &name, &placetype, &country, &repo, - &inception, &cessation, - &latitude, &longitude, &min_latitude, &max_latitude, &min_longitude, &max_longitude, - &is_current, &is_deprecated, &is_ceased, &is_superseded, &is_superseding, - &str_supersedes, &str_superseded_by, &str_belongs_to, - &lastmodified, - ) + var scanner_err error + + switch scanner.(type) { + case *sql.Rows: + + scanner_err = scanner.(*sql.Rows).Scan( + &spr_id, &parent_id, &name, &placetype, + &inception, &cessation, + &country, &repo, + &latitude, &longitude, + &min_latitude, &max_latitude, &min_longitude, &max_longitude, + &is_current, &is_deprecated, &is_ceased, &is_superseded, &is_superseding, + &str_supersedes, &str_superseded_by, &str_belongs_to, + &is_alt, &alt_label, + &lastmodified, + ) + + default: + + scanner_err = scanner.(*sql.Row).Scan( + &spr_id, &parent_id, &name, &placetype, + &inception, &cessation, + &country, &repo, + &latitude, &longitude, + &min_latitude, &max_latitude, &min_longitude, &max_longitude, + &is_current, &is_deprecated, &is_ceased, &is_superseded, &is_superseding, + &str_supersedes, &str_superseded_by, &str_belongs_to, + &is_alt, &alt_label, + &lastmodified, + ) + } + + if scanner_err != nil { + return nil, scanner_err + } + + id, err := strconv.ParseInt(spr_id, 10, 64) if err != nil { return nil, err diff --git a/vendor/modules.txt b/vendor/modules.txt index c5ed28ea..1d68409e 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -60,7 +60,7 @@ github.com/whosonfirst/go-sanitize github.com/whosonfirst/go-spatialite # github.com/whosonfirst/go-whosonfirst-crawl v0.2.1 github.com/whosonfirst/go-whosonfirst-crawl -# github.com/whosonfirst/go-whosonfirst-flags v0.4.2 +# github.com/whosonfirst/go-whosonfirst-flags v0.4.3 github.com/whosonfirst/go-whosonfirst-flags github.com/whosonfirst/go-whosonfirst-flags/date github.com/whosonfirst/go-whosonfirst-flags/existential @@ -112,7 +112,7 @@ github.com/whosonfirst/go-whosonfirst-sqlite/utils ## explicit github.com/whosonfirst/go-whosonfirst-sqlite-features github.com/whosonfirst/go-whosonfirst-sqlite-features/tables -# github.com/whosonfirst/go-whosonfirst-sqlite-spr v0.0.6 +# github.com/whosonfirst/go-whosonfirst-sqlite-spr v0.0.10 ## explicit github.com/whosonfirst/go-whosonfirst-sqlite-spr # github.com/whosonfirst/go-whosonfirst-uri v1.0.1