René's URL Explorer Experiment


Title: Add support for printing SQL of SQLAlchemy query · Issue #23 · pgvector/pgvector-python · GitHub

Open Graph Title: Add support for printing SQL of SQLAlchemy query · Issue #23 · pgvector/pgvector-python

X Title: Add support for printing SQL of SQLAlchemy query · Issue #23 · pgvector/pgvector-python

Description: pgvector.sqlalchemy.Vector doesn't provide a process_literal_param method, so any SQLALchemy query containing literal values for such column will fail to be rendered to final SQL including the values when literal_binds are enabled. Pleas...

Open Graph Description: pgvector.sqlalchemy.Vector doesn't provide a process_literal_param method, so any SQLALchemy query containing literal values for such column will fail to be rendered to final SQL including the valu...

X Description: pgvector.sqlalchemy.Vector doesn't provide a process_literal_param method, so any SQLALchemy query containing literal values for such column will fail to be rendered to final SQL including the ...

Opengraph URL: https://github.com/pgvector/pgvector-python/issues/23

X: @github

direct link

Domain: patch-diff.githubusercontent.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Add support for printing SQL of SQLAlchemy query","articleBody":"`pgvector.sqlalchemy.Vector` doesn't provide a `process_literal_param` method, so any SQLALchemy query containing literal values for such column will fail to be rendered to final SQL including the values when `literal_binds` are enabled. Please implement the method.\r\n\r\nRepro steps:\r\n```\r\nimport sqlalchemy as sa\r\nimport sqlalchemy.dialects.postgresql\r\nimport pgvector.sqlalchemy as pgv\r\n\r\nengine = sa.create_engine(\"postgresql+psycopg2://postgres:password@localhost:5432/neighbors-2\")\r\nconn = engine.connect()\r\ntable = sa.Table(\"foo\", sa.MetaData(), sa.Column(\"col1\", pgv.Vector(4)))\r\nquery = sa.select(table.c.col1).where((table.c.col1.max_inner_product([0.5, 0.5, 0.5, 0.5]) * -1) \u003e= 0.1)\r\nkwargs = {\"literal_binds\": True}\r\nsql = str(query.compile(dialect=sqlalchemy.dialects.postgresql.dialect()), compile_kwargs=kwargs)\r\n```\r\nraises\r\n```\r\nsqlalchemy.exc.CompileError: No literal value renderer is available for literal value \"[0.5, 0.5, 0.5, 0.5]\" with datatype VECTOR(4)\r\n```\r\n(The query itself is OK which can be verified by using `kwargs = {}` -- the compilation returns `'SELECT foo.col1 \\nFROM foo \\nWHERE (foo.col1 \u003c#\u003e %(col1_1)s) * %(param_1)s \u003e= %(param_2)s'`)\r\n\r\nWorkaround:\r\n```\r\nimport pgvector.utils\r\n\r\nclass Vector(pgv.Vector, sa.TypeDecorator):\r\n    impl = pgv.Vector\r\n    cache_ok = True\r\n\r\n    def process_literal_param(self, value, dialect):\r\n        return repr(pgvector.utils.to_db(value, self.dim))\r\n```\r\nand use this wrapper class in the table definition instead of the library-provided `pgv.Vector`. The SQL rendering then works:\r\n```\r\nstr(query.compile(dialect=sqlalchemy.dialects.postgresql.dialect(), compile_kwargs={\"literal_binds\": True}))\r\n\"SELECT foo.col1 \\nFROM foo \\nWHERE (foo.col1 \u003c#\u003e '[0.5,0.5,0.5,0.5]') * -1 \u003e= 0.1\"\r\n```","author":{"url":"https://github.com/sarimak","@type":"Person","name":"sarimak"},"datePublished":"2023-08-07T08:40:02.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":4},"url":"https://github.com/23/pgvector-python/issues/23"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:c0ebe844-13b2-4974-a235-8d21c4597e61
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idCA92:2A07B7:67329D1:85F86FB:69756B53
html-safe-nonce5d72ef68c4caf72ac95e6976c78943290bd9d4e5595704e62a7e6821d8d1bcc2
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDQTkyOjJBMDdCNzo2NzMyOUQxOjg1Rjg2RkI6Njk3NTZCNTMiLCJ2aXNpdG9yX2lkIjoiMzgxMzI5OTA2Nzg0ODg0NjE2MyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmacc92ca65160a4696c19893257527956b1bf105dcd46db23218b1a99049e7fe20c
hovercard-subject-tagissue:1838970589
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/pgvector/pgvector-python/23/issue_layout
twitter:imagehttps://opengraph.githubassets.com/0a84b26fd5ae7caacfac8dbed2398a490a465dcbf9d2d6372fd3235ecda63d58/pgvector/pgvector-python/issues/23
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/0a84b26fd5ae7caacfac8dbed2398a490a465dcbf9d2d6372fd3235ecda63d58/pgvector/pgvector-python/issues/23
og:image:altpgvector.sqlalchemy.Vector doesn't provide a process_literal_param method, so any SQLALchemy query containing literal values for such column will fail to be rendered to final SQL including the valu...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamesarimak
hostnamegithub.com
expected-hostnamegithub.com
None4a4bf5f4e28041a9d2e5c107d7d20b78b4294ba261cab243b28167c16a623a1f
turbo-cache-controlno-preview
go-importgithub.com/pgvector/pgvector-python git https://github.com/pgvector/pgvector-python.git
octolytics-dimension-user_id98363230
octolytics-dimension-user_loginpgvector
octolytics-dimension-repository_id376300726
octolytics-dimension-repository_nwopgvector/pgvector-python
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id376300726
octolytics-dimension-repository_network_root_nwopgvector/pgvector-python
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release488b30e96dfd057fbbe44c6665ccbc030b729dde
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://patch-diff.githubusercontent.com/pgvector/pgvector-python/issues/23#start-of-content
https://patch-diff.githubusercontent.com/
Sign in https://patch-diff.githubusercontent.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpgvector%2Fpgvector-python%2Fissues%2F23
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub SparkBuild and deploy intelligent appshttps://github.com/features/spark
GitHub ModelsManage and compare promptshttps://github.com/features/models
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
GitHub SponsorsFund open source developershttps://github.com/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/accelerator
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://patch-diff.githubusercontent.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpgvector%2Fpgvector-python%2Fissues%2F23
Sign up https://patch-diff.githubusercontent.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=pgvector%2Fpgvector-python
Reloadhttps://patch-diff.githubusercontent.com/pgvector/pgvector-python/issues/23
Reloadhttps://patch-diff.githubusercontent.com/pgvector/pgvector-python/issues/23
Reloadhttps://patch-diff.githubusercontent.com/pgvector/pgvector-python/issues/23
pgvector https://patch-diff.githubusercontent.com/pgvector
pgvector-pythonhttps://patch-diff.githubusercontent.com/pgvector/pgvector-python
Notifications https://patch-diff.githubusercontent.com/login?return_to=%2Fpgvector%2Fpgvector-python
Fork 86 https://patch-diff.githubusercontent.com/login?return_to=%2Fpgvector%2Fpgvector-python
Star 1.4k https://patch-diff.githubusercontent.com/login?return_to=%2Fpgvector%2Fpgvector-python
Code https://patch-diff.githubusercontent.com/pgvector/pgvector-python
Issues 2 https://patch-diff.githubusercontent.com/pgvector/pgvector-python/issues
Pull requests 4 https://patch-diff.githubusercontent.com/pgvector/pgvector-python/pulls
Actions https://patch-diff.githubusercontent.com/pgvector/pgvector-python/actions
Security 0 https://patch-diff.githubusercontent.com/pgvector/pgvector-python/security
Insights https://patch-diff.githubusercontent.com/pgvector/pgvector-python/pulse
Code https://patch-diff.githubusercontent.com/pgvector/pgvector-python
Issues https://patch-diff.githubusercontent.com/pgvector/pgvector-python/issues
Pull requests https://patch-diff.githubusercontent.com/pgvector/pgvector-python/pulls
Actions https://patch-diff.githubusercontent.com/pgvector/pgvector-python/actions
Security https://patch-diff.githubusercontent.com/pgvector/pgvector-python/security
Insights https://patch-diff.githubusercontent.com/pgvector/pgvector-python/pulse
New issuehttps://patch-diff.githubusercontent.com/login?return_to=https://github.com/pgvector/pgvector-python/issues/23
New issuehttps://patch-diff.githubusercontent.com/login?return_to=https://github.com/pgvector/pgvector-python/issues/23
Add support for printing SQL of SQLAlchemy queryhttps://patch-diff.githubusercontent.com/pgvector/pgvector-python/issues/23#top
https://github.com/sarimak
https://github.com/sarimak
sarimakhttps://github.com/sarimak
on Aug 7, 2023https://github.com/pgvector/pgvector-python/issues/23#issue-1838970589
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.