我遇到的问题是结果集中返回的tx没有设置所有字段。无法弄清楚为什么?它在实际的数据库表中具有价值。// request object supplied in FetchTransactionWithHighestExpiry:type ProvisionRequest struct { Identity string `json:"identity"` IdentityType string `json:"identityType"`}// struct to model database tabletype Transactions struct { Identity string `gorm:"index;not null"` IdentityType string }// method where there is problemfunc (c *DBClient) FetchTransactionWithHighestExpiry(req *model.ProvisionRequest) (model.Transactions, error) { var tx model.Transactions res := c.client.Model(&model.Transactions{}).Where("identity = ? AND endDate > ?", req.Identity, time.Now().Unix()).Order("endDate desc").First(&tx) return tx, res.Error}我的 tx 只有身份集的值,而 identityType 是一个空字符串。任何想法我在这里做错了什么?编辑 1:事务表架构-- rp.transactions definitionCREATE TABLE `transactions` ( `transaction_id` varchar(255) NOT NULL, `identity` varchar(255) DEFAULT NULL, `identityType` varchar(15) DEFAULT NULL, `serviceId` varchar(255) DEFAULT NULL, `partnerId` varchar(255) DEFAULT NULL, `countryId` varchar(255) DEFAULT NULL, `updatedAt` timestamp NULL DEFAULT NULL, `createdAt` timestamp NULL DEFAULT NULL, `startDate` int NOT NULL, `endDate` int NOT NULL, PRIMARY KEY (`transaction_id`), KEY `identity_idx` (`identity`)) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
- 1 回答
- 0 关注
- 147 浏览
添加回答
举报
0/150
提交
取消