Title: could not determine data type of parameter · Issue #2152 · sqlc-dev/sqlc · GitHub
Open Graph Title: could not determine data type of parameter · Issue #2152 · sqlc-dev/sqlc
X Title: could not determine data type of parameter · Issue #2152 · sqlc-dev/sqlc
Description: Version 1.16.0 What happened? Statements that cannot parse the column name can be executed, and the type cannot be inferred after changing the name of $2 Relevant log output # package commcarddb queries/commcard/commcard.sql:1:1: could n...
Open Graph Description: Version 1.16.0 What happened? Statements that cannot parse the column name can be executed, and the type cannot be inferred after changing the name of $2 Relevant log output # package commcarddb qu...
X Description: Version 1.16.0 What happened? Statements that cannot parse the column name can be executed, and the type cannot be inferred after changing the name of $2 Relevant log output # package commcarddb qu...
Opengraph URL: https://github.com/sqlc-dev/sqlc/issues/2152
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"could not determine data type of parameter","articleBody":"### Version\r\n\r\n1.16.0\r\n\r\n### What happened?\r\n\r\nStatements that cannot parse the column name can be executed, and the type cannot be inferred after changing the name of $2\r\n\r\n\r\n### Relevant log output\r\n\r\n```shell\r\n# package commcarddb\r\nqueries/commcard/commcard.sql:1:1: could not determine data type of parameter $2\r\n```\r\n\r\n\r\n### Database schema\r\n\r\n```sql\r\nCREATE TABLE public.solar_commcard_mapping (\r\n id integer NOT NULL,\r\n \"deviceId\" integer NOT NULL,\r\n version character varying(32) DEFAULT ''::character varying NOT NULL,\r\n sn character varying(32) DEFAULT ''::character varying NOT NULL,\r\n \"createdAt\" timestamp with time zone DEFAULT now(),\r\n \"updatedAt\" timestamp with time zone DEFAULT now()\r\n);\r\n```\r\n\r\n\r\n### SQL queries\r\n\r\n```sql\r\nThis will work, but $2 won't resolve the column name\r\n\r\n\r\n-- name: InsertMappping :batchexec \r\nWITH table1 AS\r\n(\r\n SELECT \"version\" from solar_commcard_mapping where \"deviceId\" = $1 order by \"updatedAt\" desc limit 1\r\n)\r\nINSERT INTO solar_commcard_mapping(\"deviceId\", \"version\", \"sn\",\"updatedAt\")\r\nSELECT $1,$2::text,$3,$4 WHERE not exists(SELECT * from table1 where table1.\"version\" = $2::text) or not exists (select * from table1) ;\r\n\r\n```\r\n\r\n# package commcarddb\r\nqueries/commcard/commcard.sql:1:1: could not determine data type of parameter $2\r\n```\r\nWITH table1 AS\r\n(\r\n SELECT \"version\" from solar_commcard_mapping where \"deviceId\" = $1 order by \"updatedAt\" desc limit 1\r\n)\r\nINSERT INTO solar_commcard_mapping(\"deviceId\", \"version\", \"sn\",\"updatedAt\")\r\nSELECT $1,@version::text,$3,$4 WHERE not exists(SELECT * from table1 where table1.\"version\" = @version::text) or not exists (select * from table1) ;\r\n```\r\n```\r\n```\r\n\r\n\r\n### Configuration\r\n\r\n```yaml\r\nversion: \"2\"\r\nsql:\r\n - schema: \"./schema/\"\r\n queries: \"./queries/dumpservice/\"\r\n engine: \"postgresql\"\r\n gen:\r\n go:\r\n package: \"dumpservicedb\"\r\n sql_package: \"pgx/v4\"\r\n out: \"./sql/queries/dumpservicedb\"\r\n emit_exact_table_names: true\r\n emit_json_tags: true\r\n - schema: \"./schema/\"\r\n queries: \"./queries/mapping/\"\r\n engine: \"postgresql\"\r\n gen:\r\n go:\r\n package: \"mappingdb\"\r\n sql_package: \"pgx/v4\"\r\n out: \"./sql/queries/mappingdb\"\r\n emit_exact_table_names: true\r\n emit_json_tags: true\r\n - schema: \"./schema/\"\r\n queries: \"./queries/sitemapping/\"\r\n engine: \"postgresql\"\r\n gen:\r\n go:\r\n package: \"sitemappingdb\"\r\n sql_package: \"pgx/v4\"\r\n out: \"./sql/queries/sitemappingdb\"\r\n emit_exact_table_names: true\r\n emit_json_tags: true\r\n - schema: \"./schema/\"\r\n queries: \"./queries/commcard/\"\r\n engine: \"postgresql\"\r\n gen:\r\n go:\r\n package: \"commcarddb\"\r\n sql_package: \"pgx/v4\"\r\n out: \"./sql/queries/commcarddb\"\r\n emit_exact_table_names: true\r\n emit_json_tags: true\r\n```\r\n\r\n\r\n### Playground URL\r\n\r\nhttps://play.sqlc.dev/p/5fbfef02281fb67691c3cec9b2d084e5fde4329dcef538c7c84013fb2be45663\r\n\r\n### What operating system are you using?\r\n\r\nLinux\r\n\r\n### What database engines are you using?\r\n\r\nPostgreSQL\r\n\r\n### What type of code are you generating?\r\n\r\nGo","author":{"url":"https://github.com/wj-stack","@type":"Person","name":"wj-stack"},"datePublished":"2023-03-17T01:11:51.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/2152/sqlc/issues/2152"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:4cee74d2-6d9d-4805-d0e3-3ebc8bc89627 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9BD0:1E8ACD:4C1A5C:681CF3:6A5132C7 |
| html-safe-nonce | c241970dc44c7e0a576cc46497ada6270284523d8b43763121914552e531efd9 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5QkQwOjFFOEFDRDo0QzFBNUM6NjgxQ0YzOjZBNTEzMkM3IiwidmlzaXRvcl9pZCI6IjUxODM3OTMxMjMwODAzNTI0NTUiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 921e4f3a36dc34c8759d01e540f7f4583a6941735cb09da8a5f3e62ba12b2561 |
| hovercard-subject-tag | issue:1628529415 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/sqlc-dev/sqlc/2152/issue_layout |
| twitter:image | https://opengraph.githubassets.com/a145a84830b6b1bf256707f0d778dccd0b45f5c0c2b647c0b7588edcd44c5363/sqlc-dev/sqlc/issues/2152 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/a145a84830b6b1bf256707f0d778dccd0b45f5c0c2b647c0b7588edcd44c5363/sqlc-dev/sqlc/issues/2152 |
| og:image:alt | Version 1.16.0 What happened? Statements that cannot parse the column name can be executed, and the type cannot be inferred after changing the name of $2 Relevant log output # package commcarddb qu... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | wj-stack |
| hostname | github.com |
| expected-hostname | github.com |
| None | e840f405b2718e8f2d55aafa9ff27dbce17e29d0c253011d05ea0fea3c78baff |
| turbo-cache-control | no-preview |
| go-import | github.com/sqlc-dev/sqlc git https://github.com/sqlc-dev/sqlc.git |
| octolytics-dimension-user_id | 136738596 |
| octolytics-dimension-user_login | sqlc-dev |
| octolytics-dimension-repository_id | 193160679 |
| octolytics-dimension-repository_nwo | sqlc-dev/sqlc |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 193160679 |
| octolytics-dimension-repository_network_root_nwo | sqlc-dev/sqlc |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 4ae6027e8ba70c79dc08249bb6cdc1a09d788496 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width