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: redirect.github.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) >= 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#> %(col1_1)s) * %(param_1)s >= %(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#> '[0.5,0.5,0.5,0.5]') * -1 >= 0.1\"\r\n```","author":{"url":"https://github.com/sarimak","@type":"Person","name":"sarimak"},"datePublished":"2023-08-07T08:40:02Z","url":"https://github.com/pgvector/pgvector-python/issues/23"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:718f10b1-9a81-ff8c-d320-17bb0b702f52
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idE1C8:15A424:F8E368:1549FFC:6AFE9A9A
html-safe-nonce38affed2a9cea6718a9af718d084b9966b50b09f3a834c2d44aa571e34689cdc
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFMUM4OjE1QTQyNDpGOEUzNjg6MTU0OUZGQzo2QUZFOUE5QSIsInZpc2l0b3JfaWQiOiI3ODAyMzU1OTY1MzAyMzE1Njc0IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmac216dc0b3440a4eee7dbb4ddec7babd6c6f4795de0dea6146f193d6d546fa77a2
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
Noneb3c0f155eafc27e60db6e254d1ffff0e072e9ab3b4018a5ee518797c19d89f86
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
release4a10310af51a1bfffbedc4fd81cb582acf0cb0ff
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://redirect.github.com/pgvector/pgvector-python/issues/23#start-of-content
https://redirect.github.com/
Sign inhttps://redirect.github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpgvector%2Fpgvector-python%2Fissues%2F23
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
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
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://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/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://redirect.github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpgvector%2Fpgvector-python%2Fissues%2F23
Sign uphttps://redirect.github.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://redirect.github.com/pgvector/pgvector-python/issues/23
Reloadhttps://redirect.github.com/pgvector/pgvector-python/issues/23
Reloadhttps://redirect.github.com/pgvector/pgvector-python/issues/23
pgvectorhttps://redirect.github.com/pgvector
pgvector-pythonhttps://redirect.github.com/pgvector/pgvector-python
Codehttps://redirect.github.com/pgvector/pgvector-python
Issues2 (2)https://redirect.github.com/pgvector/pgvector-python/issues
Pull requests8 (8)https://redirect.github.com/pgvector/pgvector-python/pulls
Actionshttps://redirect.github.com/pgvector/pgvector-python/actions
Security and qualityhttps://redirect.github.com/pgvector/pgvector-python/security
Insightshttps://redirect.github.com/pgvector/pgvector-python/insights
https://redirect.github.com/pgvector/pgvector-python
New issuehttps://redirect.github.com/login?return_to=https://github.com/pgvector/pgvector-python/issues/23
New issuehttps://redirect.github.com/login?return_to=https://github.com/pgvector/pgvector-python/issues/23
Add support for printing SQL of SQLAlchemy queryhttps://redirect.github.com/pgvector/pgvector-python/issues/23#top
https://github.com/sarimak
sarimakhttps://github.com/sarimak
on Aug 7, 2023https://github.com/pgvector/pgvector-python/issues/23#issue-1838970589
https://redirect.github.com/sarimak
sarimakhttps://redirect.github.com/sarimak
on Aug 7, 2023https://github.com/pgvector/pgvector-python/issues/23#issuecomment-1667448273
https://redirect.github.com/ankane
ankanehttps://redirect.github.com/ankane
on Aug 20, 2023https://github.com/pgvector/pgvector-python/issues/23#issuecomment-1685141587
@sarimakhttps://github.com/sarimak
ankanehttps://redirect.github.com/ankane
completedhttps://redirect.github.com/pgvector/pgvector-python/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
on Aug 20, 2023https://github.com/pgvector/pgvector-python/issues/23#event-10137246060
https://redirect.github.com/sarimak
sarimakhttps://redirect.github.com/sarimak
on Sep 6, 2023https://github.com/pgvector/pgvector-python/issues/23#issuecomment-1709007564
https://redirect.github.com/ankane
ankanehttps://redirect.github.com/ankane
on Jan 19, 2024https://github.com/pgvector/pgvector-python/issues/23#issuecomment-1899461337
@sarimakhttps://github.com/sarimak
#51https://github.com/pgvector/pgvector-python/pull/51
Sign up for freehttps://redirect.github.com/signup?return_to=https://github.com/pgvector/pgvector-python/issues/23
Sign in to commenthttps://redirect.github.com/login?return_to=https://github.com/pgvector/pgvector-python/issues/23
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.