mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
fix datastore Put and added tests (#402)
This commit is contained in:
committed by
Travis Reeder
parent
0baf03841f
commit
9382f0b133
@@ -524,6 +524,10 @@ func buildFilterRouteQuery(filter *models.RouteFilter) string {
|
||||
}
|
||||
|
||||
func (ds *PostgresDatastore) Put(ctx context.Context, key, value []byte) error {
|
||||
if key == nil || len(key) == 0 {
|
||||
return models.ErrDatastoreEmptyKey
|
||||
}
|
||||
|
||||
_, err := ds.db.Exec(`
|
||||
INSERT INTO extras (
|
||||
key,
|
||||
@@ -531,7 +535,7 @@ func (ds *PostgresDatastore) Put(ctx context.Context, key, value []byte) error {
|
||||
)
|
||||
VALUES ($1, $2)
|
||||
ON CONFLICT (key) DO UPDATE SET
|
||||
value = $1;
|
||||
value = $2;
|
||||
`, string(key), string(value))
|
||||
|
||||
if err != nil {
|
||||
@@ -542,6 +546,10 @@ func (ds *PostgresDatastore) Put(ctx context.Context, key, value []byte) error {
|
||||
}
|
||||
|
||||
func (ds *PostgresDatastore) Get(ctx context.Context, key []byte) ([]byte, error) {
|
||||
if key == nil || len(key) == 0 {
|
||||
return nil, models.ErrDatastoreEmptyKey
|
||||
}
|
||||
|
||||
row := ds.db.QueryRow("SELECT value FROM extras WHERE key=$1", key)
|
||||
|
||||
var value string
|
||||
|
||||
Reference in New Issue
Block a user