Title: Incorrect type generated for `SMALLINT` · Issue #3088 · sqlc-dev/sqlc · GitHub
Open Graph Title: Incorrect type generated for `SMALLINT` · Issue #3088 · sqlc-dev/sqlc
X Title: Incorrect type generated for `SMALLINT` · Issue #3088 · sqlc-dev/sqlc
Description: Version 1.24.0 What happened? When creating a table that includes a column of type SMALLINT, the generated model that represents the column's field as int32 instead of int16. This can lead to unexpected errors from the database. Got type...
Open Graph Description: Version 1.24.0 What happened? When creating a table that includes a column of type SMALLINT, the generated model that represents the column's field as int32 instead of int16. This can lead to unexp...
X Description: Version 1.24.0 What happened? When creating a table that includes a column of type SMALLINT, the generated model that represents the column's field as int32 instead of int16. This can lead to u...
Opengraph URL: https://github.com/sqlc-dev/sqlc/issues/3088
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Incorrect type generated for `SMALLINT`","articleBody":"### Version\r\n\r\n1.24.0\r\n\r\n### What happened?\r\n\r\nWhen creating a table that includes a column of type `SMALLINT`, the generated model that represents the column's field as int32 instead of int16. This can lead to unexpected errors from the database.\r\n\r\n#### Got\r\n```go\r\ntype Account struct {\r\n ID string\r\n Userid string\r\n Balance float64\r\n Pin int32\r\n Currency AccountsCurrency\r\n Createdat time.Time\r\n Upatedat time.Time\r\n}\r\n\r\n```\r\n\r\n#### Expected\r\n```go\r\ntype Account struct {\r\n ID string\r\n Userid string\r\n Balance float64\r\n Pin int16\r\n Currency AccountsCurrency\r\n Createdat time.Time\r\n Upatedat time.Time\r\n}\r\n```\r\n\r\n### Relevant log output\r\n\r\n_No response_\r\n\r\n### Database schema\r\n\r\n```sql\r\nCREATE TABLE IF NOT EXISTS accounts (\r\n id VARCHAR(80) NOT NULL,\r\n userId VARCHAR(80) NOT NULL,\r\n balance FLOAT DEFAULT 0.0 NOT NULL,\r\n pin SMALLINT NOT NULL,\r\n currency ENUM('LRD', 'USD') NOT NULL,\r\n createdAt DATETIME NOT NULL,\r\n upatedAt DATETIME NOT NULL,\r\n PRIMARY KEY(id),\r\n FOREIGN KEY(userId) REFERENCES users(id)\r\n);\r\n```\r\n\r\n\r\n### SQL queries\r\n\r\n_No response_\r\n\r\n### Configuration\r\n\r\n```yaml\r\nversion: \"2\"\r\nsql:\r\n - engine: \"mysql\"\r\n queries: \"sql/queries\"\r\n schema: \"sql/schema\"\r\n gen:\r\n go:\r\n out: \"model\"\r\n```\r\n\r\n\r\n### Playground URL\r\n\r\nhttps://play.sqlc.dev/p/486276076a4aae590e56c6a81de718232c89d551c51dfbcea042246b56f430a5\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\nMySQL\r\n\r\n### What type of code are you generating?\r\n\r\nGo","author":{"url":"https://github.com/maxwelldorliea","@type":"Person","name":"maxwelldorliea"},"datePublished":"2023-12-30T14:57:28.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":3},"url":"https://github.com/3088/sqlc/issues/3088"}
| 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:7ec5ae4c-d022-218f-f562-ff012ff6918e |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B14E:6F3CF:89A0B9E:C1C1E79:6A50D9B6 |
| html-safe-nonce | d36e6aa283037791137d1eeb3454fe2f3d839250db3a65bf57ff1450831ed9f9 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCMTRFOjZGM0NGOjg5QTBCOUU6QzFDMUU3OTo2QTUwRDlCNiIsInZpc2l0b3JfaWQiOiIzODMyOTI0ODA5MjUzMTQ5MTEwIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 6f305698164f42e77b4ee6e812ec91e4456e0041ab2d4c27974eb23a5e19da77 |
| hovercard-subject-tag | issue:2060769163 |
| 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/3088/issue_layout |
| twitter:image | https://opengraph.githubassets.com/57ac658522cb44c1d5f98c39138b1fe9fd0419758088fa268957bb5e592202d7/sqlc-dev/sqlc/issues/3088 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/57ac658522cb44c1d5f98c39138b1fe9fd0419758088fa268957bb5e592202d7/sqlc-dev/sqlc/issues/3088 |
| og:image:alt | Version 1.24.0 What happened? When creating a table that includes a column of type SMALLINT, the generated model that represents the column's field as int32 instead of int16. This can lead to unexp... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | maxwelldorliea |
| hostname | github.com |
| expected-hostname | github.com |
| None | 72b13e0e8d0319acdd27a145cfe73f4f06c791713d0ac4690e41fb68ad28cac0 |
| 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 | 73ad5c4eaffed7bb3637024653eabdbca84a855e |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width