Skip to content

Commit

Permalink
pgvector: support postgres schema (#439)
Browse files Browse the repository at this point in the history
  • Loading branch information
tecnologer authored Dec 20, 2023
1 parent eb17026 commit 6ad961a
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions vectorstores/pgvector/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"errors"
"fmt"
"os"
"strings"

"github.com/jackc/pgx/v5"
"github.com/tmc/langchaingo/embeddings"
Expand Down Expand Up @@ -53,14 +54,14 @@ func WithCollectionName(name string) Option {
// WithEmbeddingTableName is an option for specifying the embedding table name.
func WithEmbeddingTableName(name string) Option {
return func(p *Store) {
p.embeddingTableName = pgx.Identifier{name}.Sanitize()
p.embeddingTableName = tableName(name)
}
}

// WithCollectionTableName is an option for specifying the collection table name.
func WithCollectionTableName(name string) Option {
return func(p *Store) {
p.collectionTableName = pgx.Identifier{name}.Sanitize()
p.collectionTableName = tableName(name)
}
}

Expand Down Expand Up @@ -90,3 +91,10 @@ func applyClientOptions(opts ...Option) (Store, error) {

return *o, nil
}

// tableName returns the table name with the schema sanitized.
func tableName(name string) string {
nameParts := strings.Split(name, ".")

return pgx.Identifier(nameParts).Sanitize()
}

0 comments on commit 6ad961a

Please sign in to comment.