sqlc
sqlc copied to clipboard
not null is converted to sql.nullstring in the left connection
Version
1.15.0
What happened?
use left join ,the generate list struct column is sql.NullString,but in mysql server the column define not null
Relevant log output
type GetAccountAmountListRow struct {
ID sql.NullString `json:"id"`
Email sql.NullString `json:"email"`
Avatar sql.NullString `json:"avatar"`
Coin string `json:"coin"`
Balance string `json:"balance"`
}
Database schema
CREATE TABLE `account` (
`id` varchar(64) NOT NULL DEFAULT '',
`email` varchar(255) NOT NULL DEFAULT '',
`name` varchar(255) NOT NULL DEFAULT 'Practice Singer' COMMENT '''name''',
`avatar` varchar(1024) NOT NULL DEFAULT 'avatar/20220713/06f393193bfc555aeadfbb793eb1fb41.png' COMMENT '''头å''',
PRIMARY KEY (`id`),
KEY `idx_email` (`email`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
CREATE TABLE `account_amount` (
`id` varchar(64) NOT NULL DEFAULT '',
`account_id` varchar(64) NOT NULL DEFAULT '',
`coin` varchar(32) NOT NULL DEFAULT '' COMMENT '''coin''',
`balance` decimal(20,6) NOT NULL DEFAULT '0.000000' COMMENT 'balance',
PRIMARY KEY (`id`),
KEY `idx_r_account_amount_coin` (`coin`),
KEY `idx_r_account_amount_account_id` (`account_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
SQL queries
-- name: GetAccountAmountList :many
select a.id,
a.email,
a.avatar,
account_amount.coin,
account_amount.balance
from account_amount
left join account a on a.id = account_amount.account_id
where account_id = ?;
Configuration
version: 2
overrides:
go:
overrides:
- column: "*.id"
go_type: "github.com/google/uuid.UUID"
- db_type: "decimal"
go_type: "github.com/shopspring/decimal.Decimal"
sql:
- engine: "mysql"
schema: "./schema"
queries: "./query"
strict_function_checks: false
gen:
go:
package: "model"
out: "model"
emit_json_tags: true
emit_prepared_queries: false
emit_interface: true
emit_exact_table_names: false
emit_result_struct_pointers: true
json_tags_case_style: "snake"
Playground URL
https://play.sqlc.dev/p/3e2653c5b55fd486fb1734f991ae005b3142d3651afebfddd9e2041343081a18
What operating system are you using?
macOS
What database engines are you using?
MySQL
What type of code are you generating?
Go