René's URL Explorer Experiment


Title: fix(postgresql): set query result column nullable if selected column contains json operator or null value in case expression by swallowstalker · Pull Request #3739 · sqlc-dev/sqlc · GitHub

Open Graph Title: fix(postgresql): set query result column nullable if selected column contains json operator or null value in case expression by swallowstalker · Pull Request #3739 · sqlc-dev/sqlc

X Title: fix(postgresql): set query result column nullable if selected column contains json operator or null value in case expression by swallowstalker · Pull Request #3739 · sqlc-dev/sqlc

Description: Trying to solve #3710 JSON traversal operator on selected columns Based on postgresql docs, operator ->> and #>> should return string, and since this is JSON and it could have null value on its field, it should return pgtype.Text. Other JSON operator should return interface{} since it returns JSON object Refactor AExpr and AConst on selected columns Since it is used on CaseExpr, I refactored both of them to allow it to be reusable in different location TypeCast null value checking If there is any selected columns which has null value to be casted to other type, for example null::text then it should return pgtype.Text to allow nullable text CaseExpr nullable + column type handling Previously, sqlc determines column type from default case and uses hardcoded NotNull to true. Relying on default case can be bad since it might not be declared, if user decides not to use ELSE keyword. This PR will determine column type + nullability from all sub-case, on list of THEN clause combined with ELSE clause considering data types involved on those multiple clause. If there is only one data type on any case expr clause, then it will be nullable of that data type If there are multiple data type, it will automatically generate interface{} type If all case expr clause have null result, then it will generate interface{} type Case expr without default clause, will be assumed to have null as its ELSE result and if any of those column are nullable, then the resulting column will be set to nullable.

Open Graph Description: Trying to solve #3710 JSON traversal operator on selected columns Based on postgresql docs, operator ->> and #>> should return string, and since this is JSON and it could have null valu...

X Description: Trying to solve #3710 JSON traversal operator on selected columns Based on postgresql docs, operator ->> and #>> should return string, and since this is JSON and it coul...

Opengraph URL: https://github.com/sqlc-dev/sqlc/pull/3739

X: @github

direct link

Domain: github.com

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/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:3cc47530-724e-2828-fea4-f9f89edd6fbf
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-id97FA:311640:26AACD7:3122F46:6B01973C
html-safe-nonceb0b8d64043df06829661990821a58271d767193d3920cff71f3baa965e19e550
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5N0ZBOjMxMTY0MDoyNkFBQ0Q3OjMxMjJGNDY6NkIwMTk3M0MiLCJ2aXNpdG9yX2lkIjoiNDczNTc1ODcxMzM0Njk1NTA2OCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac4f8543779c75a665e203b4c63d83316270f3761cddb69a98afbfdbaee01057f6
hovercard-subject-tagpull_request:2225628996
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/sqlc-dev/sqlc/pull/3739/files
twitter:imagehttps://avatars.githubusercontent.com/u/1897818?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/1897818?s=400&v=4
og:image:altTrying to solve #3710 JSON traversal operator on selected columns Based on postgresql docs, operator ->> and #>> should return string, and since this is JSON and it could have null valu...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
Nonecc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/sqlc-dev/sqlc git https://github.com/sqlc-dev/sqlc.git
octolytics-dimension-user_id136738596
octolytics-dimension-user_loginsqlc-dev
octolytics-dimension-repository_id193160679
octolytics-dimension-repository_nwosqlc-dev/sqlc
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id193160679
octolytics-dimension-repository_network_root_nwosqlc-dev/sqlc
turbo-body-classeslogged-out env-production page-responsive full-width
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release8c77c9e8439031ad54c75a250694842892f693e1
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/sqlc-dev/sqlc/pull/3739/files#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fsqlc-dev%2Fsqlc%2Fpull%2F3739%2Ffiles
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://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fsqlc-dev%2Fsqlc%2Fpull%2F3739%2Ffiles
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=sqlc-dev%2Fsqlc
Reloadhttps://github.com/sqlc-dev/sqlc/pull/3739/files
Reloadhttps://github.com/sqlc-dev/sqlc/pull/3739/files
Reloadhttps://github.com/sqlc-dev/sqlc/pull/3739/files
sqlc-devhttps://github.com/sqlc-dev
sqlchttps://github.com/sqlc-dev/sqlc
Codehttps://github.com/sqlc-dev/sqlc
Issues600 (600)https://github.com/sqlc-dev/sqlc/issues
Pull requests132 (132)https://github.com/sqlc-dev/sqlc/pulls
Discussionshttps://github.com/sqlc-dev/sqlc/discussions
Actionshttps://github.com/sqlc-dev/sqlc/actions
Projectshttps://github.com/sqlc-dev/sqlc/projects
Security and qualityhttps://github.com/sqlc-dev/sqlc/security
Insightshttps://github.com/sqlc-dev/sqlc/insights
Sign up for GitHub https://github.com/signup?return_to=%2Fsqlc-dev%2Fsqlc%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2Fsqlc-dev%2Fsqlc%2Fissues%2Fnew%2Fchoose
swallowstalkerhttps://github.com/swallowstalker
sqlc-dev:mainhttps://github.com/sqlc-dev/sqlc/tree/main
swallowstalker:text-aliashttps://github.com/swallowstalker/sqlc/tree/text-alias
Conversation 12 https://github.com/sqlc-dev/sqlc/pull/3739
Commits 11 https://github.com/sqlc-dev/sqlc/pull/3739/commits
Checks 0 https://github.com/sqlc-dev/sqlc/pull/3739/checks
Files changed https://github.com/sqlc-dev/sqlc/pull/3739/files
Please reload this pagehttps://github.com/sqlc-dev/sqlc/pull/3739/files
fix(postgresql): set query result column nullable if selected column contains json operator or null value in case expression https://github.com/sqlc-dev/sqlc/pull/3739/files#top
Show all changes 11 commits https://github.com/sqlc-dev/sqlc/pull/3739/files
9ea4ce3 feat: adding nullable text if selected column is json operator and ca… swallowstalker Dec 10, 2024 https://github.com/sqlc-dev/sqlc/pull/3739/commits/9ea4ce36057388dbc4bdcf34ab68697261807bff
25274e8 test: fix fmt swallowstalker Dec 10, 2024 https://github.com/sqlc-dev/sqlc/pull/3739/commits/25274e88cbe21328480a13749b241a5528851abe
f61bfcc test: delete fourth column swallowstalker Dec 10, 2024 https://github.com/sqlc-dev/sqlc/pull/3739/commits/f61bfcc6721e6c71786bbb6f64ad039c74a2ccb9
049fb49 test: avoid test format because the reversed query from raw statement… swallowstalker Dec 10, 2024 https://github.com/sqlc-dev/sqlc/pull/3739/commits/049fb49304b7a7b5fda2448469fbf9b7e210ed13
ebc8a77 feat: case expr handling and json operator handling swallowstalker Dec 12, 2024 https://github.com/sqlc-dev/sqlc/pull/3739/commits/ebc8a772cff26624f985b77196371803887bdfda
f154a2f fix: change managed-db to base swallowstalker Dec 12, 2024 https://github.com/sqlc-dev/sqlc/pull/3739/commits/f154a2fbf450bfa673e71fafda93086234ee90e2
822e73f test: add null::text as default case expr swallowstalker Dec 13, 2024 https://github.com/sqlc-dev/sqlc/pull/3739/commits/822e73fb30eaca38b41f8b585da4deaee0522ad5
e7ddabf test: changing author email swallowstalker Dec 13, 2024 https://github.com/sqlc-dev/sqlc/pull/3739/commits/e7ddabf111cb76ac7999fb01f1faaf8c4f404000
d0cbfe4 Merge branch 'main' into text-alias swallowstalker Dec 19, 2024 https://github.com/sqlc-dev/sqlc/pull/3739/commits/d0cbfe473ddce2e0e4f87a672265582c345a744f
409d2fb fix: change type precedence auto-selection to data type any, to allow… swallowstalker Dec 19, 2024 https://github.com/sqlc-dev/sqlc/pull/3739/commits/409d2fbdf81ebb483ed9ba58cd935b3d4e4119f1
19ab642 test: uncommitted test case for GetNullable2G swallowstalker Dec 19, 2024 https://github.com/sqlc-dev/sqlc/pull/3739/commits/19ab64230cc3c03f6e29eb96ecbf8cada50df75d
Clear filters https://github.com/sqlc-dev/sqlc/pull/3739/files
Please reload this pagehttps://github.com/sqlc-dev/sqlc/pull/3739/files
Please reload this pagehttps://github.com/sqlc-dev/sqlc/pull/3739/files
output_columns.go https://github.com/sqlc-dev/sqlc/pull/3739/files#diff-10352986f0bc3f9bd887ba90e50c3ff0d93f284b24a9a8c059f1f1bc0aaba061
issue.md https://github.com/sqlc-dev/sqlc/pull/3739/files#diff-b489b57ef23bcbdf3255d9dd3d42ab26326c9cdba7977976784eb8c8bab7bfe3
exec.json https://github.com/sqlc-dev/sqlc/pull/3739/files#diff-c13da38c3e210518877c219a21cdb1ad50723de67b2f361299a042330abee9d7
db.go https://github.com/sqlc-dev/sqlc/pull/3739/files#diff-d0fc529ad88ae6f9693092aab08f3de58374bb7fa12ae47d085cc2ff76c41982
models.go https://github.com/sqlc-dev/sqlc/pull/3739/files#diff-603639316c5a316d0f7b646c7432991c5c98b784dfbca137b87bfe0c02cd853b
query.sql.go https://github.com/sqlc-dev/sqlc/pull/3739/files#diff-cbe35806176a73c9668c4e4db284b685018700ffba5ef88a7305d8b40868cd63
query.sql https://github.com/sqlc-dev/sqlc/pull/3739/files#diff-4d28d2be93ce622edfc9da96baa58da5bae23fd4915c09cf4c8f3769d94db8c1
schema.sql https://github.com/sqlc-dev/sqlc/pull/3739/files#diff-64a0a7f16c4880c1162bdd1b29ab44a47e1496ce91fee2ea31475ac5c74a6ef8
sqlc.yaml https://github.com/sqlc-dev/sqlc/pull/3739/files#diff-ba34734f67c2b554bd8af4848631af62fa75b0a1f794b942d94cf67834ccedfa
operator.go https://github.com/sqlc-dev/sqlc/pull/3739/files#diff-2f63e3ac259e41d484627e82f04bcc0b37463078f40da37cc70822001d52347b
internal/compiler/output_columns.gohttps://github.com/sqlc-dev/sqlc/pull/3739/files#diff-10352986f0bc3f9bd887ba90e50c3ff0d93f284b24a9a8c059f1f1bc0aaba061
View file https://github.com/sqlc-dev/sqlc/blob/19ab64230cc3c03f6e29eb96ecbf8cada50df75d/internal/compiler/output_columns.go
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/sqlc-dev/sqlc/pull/3739/{{ revealButtonHref }}
https://github.com/sqlc-dev/sqlc/pull/3739/files#diff-10352986f0bc3f9bd887ba90e50c3ff0d93f284b24a9a8c059f1f1bc0aaba061
https://github.com/sqlc-dev/sqlc/pull/3739/files#diff-10352986f0bc3f9bd887ba90e50c3ff0d93f284b24a9a8c059f1f1bc0aaba061
swallowstalkerhttps://github.com/swallowstalker
Dec 19, 2024https://github.com/sqlc-dev/sqlc/pull/3739/files#r1891532476
Learn morehttps://docs.github.com/articles/managing-disruptive-comments/#hiding-a-comment
Please reload this pagehttps://github.com/sqlc-dev/sqlc/pull/3739/files
https://github.com/sqlc-dev/sqlc/pull/3739/files#diff-10352986f0bc3f9bd887ba90e50c3ff0d93f284b24a9a8c059f1f1bc0aaba061
https://github.com/sqlc-dev/sqlc/pull/3739/files#diff-10352986f0bc3f9bd887ba90e50c3ff0d93f284b24a9a8c059f1f1bc0aaba061
https://github.com/sqlc-dev/sqlc/pull/3739/files#diff-10352986f0bc3f9bd887ba90e50c3ff0d93f284b24a9a8c059f1f1bc0aaba061
https://github.com/sqlc-dev/sqlc/pull/3739/files#diff-10352986f0bc3f9bd887ba90e50c3ff0d93f284b24a9a8c059f1f1bc0aaba061
https://github.com/sqlc-dev/sqlc/pull/3739/files#diff-10352986f0bc3f9bd887ba90e50c3ff0d93f284b24a9a8c059f1f1bc0aaba061
https://github.com/sqlc-dev/sqlc/pull/3739/files#diff-10352986f0bc3f9bd887ba90e50c3ff0d93f284b24a9a8c059f1f1bc0aaba061
swallowstalkerhttps://github.com/swallowstalker
Dec 19, 2024https://github.com/sqlc-dev/sqlc/pull/3739/files#r1891530078
Learn morehttps://docs.github.com/articles/managing-disruptive-comments/#hiding-a-comment
Please reload this pagehttps://github.com/sqlc-dev/sqlc/pull/3739/files
internal/endtoend/testdata/json_traversal_as_select_expr_with_type_cast/issue.mdhttps://github.com/sqlc-dev/sqlc/pull/3739/files#diff-b489b57ef23bcbdf3255d9dd3d42ab26326c9cdba7977976784eb8c8bab7bfe3
View file https://github.com/sqlc-dev/sqlc/blob/19ab64230cc3c03f6e29eb96ecbf8cada50df75d/internal/endtoend/testdata/json_traversal_as_select_expr_with_type_cast/issue.md
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/sqlc-dev/sqlc/pull/3739/{{ revealButtonHref }}
...l/endtoend/testdata/json_traversal_as_select_expr_with_type_cast/postgresql/pgx/exec.jsonhttps://github.com/sqlc-dev/sqlc/pull/3739/files#diff-c13da38c3e210518877c219a21cdb1ad50723de67b2f361299a042330abee9d7
View file https://github.com/sqlc-dev/sqlc/blob/19ab64230cc3c03f6e29eb96ecbf8cada50df75d/internal/endtoend/testdata/json_traversal_as_select_expr_with_type_cast/postgresql/pgx/exec.json
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/sqlc-dev/sqlc/pull/3739/{{ revealButtonHref }}
...al/endtoend/testdata/json_traversal_as_select_expr_with_type_cast/postgresql/pgx/go/db.gohttps://github.com/sqlc-dev/sqlc/pull/3739/files#diff-d0fc529ad88ae6f9693092aab08f3de58374bb7fa12ae47d085cc2ff76c41982
View file https://github.com/sqlc-dev/sqlc/blob/19ab64230cc3c03f6e29eb96ecbf8cada50df75d/internal/endtoend/testdata/json_traversal_as_select_expr_with_type_cast/postgresql/pgx/go/db.go
Open in desktop https://desktop.github.com
how customized files appear on GitHubhttps://docs.github.com/github/administering-a-repository/customizing-how-changed-files-appear-on-github
Please reload this pagehttps://github.com/sqlc-dev/sqlc/pull/3739/files
...ndtoend/testdata/json_traversal_as_select_expr_with_type_cast/postgresql/pgx/go/models.gohttps://github.com/sqlc-dev/sqlc/pull/3739/files#diff-603639316c5a316d0f7b646c7432991c5c98b784dfbca137b87bfe0c02cd853b
View file https://github.com/sqlc-dev/sqlc/blob/19ab64230cc3c03f6e29eb96ecbf8cada50df75d/internal/endtoend/testdata/json_traversal_as_select_expr_with_type_cast/postgresql/pgx/go/models.go
Open in desktop https://desktop.github.com
how customized files appear on GitHubhttps://docs.github.com/github/administering-a-repository/customizing-how-changed-files-appear-on-github
Please reload this pagehttps://github.com/sqlc-dev/sqlc/pull/3739/files
Please reload this pagehttps://github.com/sqlc-dev/sqlc/pull/3739/files
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.