scopes

Paddy 2015-12-13

2:a64a25ae2db1 Go to Latest

scopes/postgres.go

Port over Postgres storage and tests. Do the minimum possible port of the code from auth to get Postgres working and make the tests run and pass again. This leaves a bug where the ErrScopeAlreadyExists type, when populatd from Postgres, contains the entire error string returned from the database, instead of parsing the ID itself out. Which is a thing we should do and add a test for.

History
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/postgres.go	Sun Dec 13 20:42:48 2015 -0800
     1.3 @@ -0,0 +1,17 @@
     1.4 +package scopes
     1.5 +
     1.6 +import (
     1.7 +	"database/sql"
     1.8 +)
     1.9 +
    1.10 +func NewPostgres(conn string) (postgres, error) {
    1.11 +	db, err := sql.Open("postgres", conn)
    1.12 +	if err != nil {
    1.13 +		return postgres{}, err
    1.14 +	}
    1.15 +	return postgres{db: db}, nil
    1.16 +}
    1.17 +
    1.18 +type postgres struct {
    1.19 +	db *sql.DB
    1.20 +}