Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pgvector WithEmbeddingTableName sanitization conflicts with index creation #605

Closed
rajaiswal opened this issue Feb 5, 2024 · 2 comments · Fixed by #617
Closed

pgvector WithEmbeddingTableName sanitization conflicts with index creation #605

rajaiswal opened this issue Feb 5, 2024 · 2 comments · Fixed by #617

Comments

@rajaiswal
Copy link
Contributor

When I initialize pgvector like this:

pgv, err := pgvector.New(
                ...
		pgvector.WithEmbeddingTableName("custom_name"),
	)

The WithEmbeddingTableName sanitizes the input and its value becomes "\"custom_name\"", which is set on Store.embeddingTableName.
This then raises an error when the init method is called and it tries to create an index:

sql = fmt.Sprintf(`CREATE INDEX IF NOT EXISTS %s_collection_id ON %s (collection_id)`, s.embeddingTableName, s.embeddingTableName)

The generated error is:

ERROR: syntax error at or near "_collection_id" (SQLSTATE 42601)

I believe we could do away with the sanitization part in WithEmbeddingTableName

@rajaiswal rajaiswal changed the title pgvector EmbeddingTableName setter sanitization conflicts with index creation pgvector WithEmbeddingTableName sanitization conflicts with index creation Feb 5, 2024
@rajaiswal rajaiswal changed the title pgvector WithEmbeddingTableName sanitization conflicts with index creation pgvector WithEmbeddingTableName sanitization conflicts with index creation Feb 5, 2024
@nkwangleiGIT
Copy link

nkwangleiGIT commented Feb 18, 2024

@Abirdcfly I think we can remove the sanitization logic for WithEmbeddingTableName, pls help confirm

@Abirdcfly
Copy link
Contributor

Abirdcfly commented Feb 20, 2024

pls help confirm

Why use https://pkg.go.dev/github.com/jackc/pgx#Identifier.Sanitize, the relevant context is here: #377 (comment)

IMO, Modify the CREATE INDEX statement or deprecate Sanitize() are both acceptable.

cc @tmc @eliben

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants