typescript - TypeORM 属性可以为空,但收到“不能为不可为空的字段 xx 返回 null”
问题描述
鉴于数据集现在不一致,我有一个所有字段都可以为空的数据模型,但我仍然想使用数据。
这是模型的一个片段:
@ObjectType()
@Entity()
export class SomeEntity extends BaseEntity {
@PrimaryGeneratedColumn({
type: 'bigint',
})
@Field()
id: number;
@Column({
nullable: true,
type: 'text'
})
@Field()
var1: string
@Column({
nullable: true,
type: 'text'
})
@Field()
var2: string
}
但是在执行 graphQL 查询时,我收到以下错误:
"message": "Cannot return null for non-nullable field SomeEntity.var1",
该字段为空,因为我可以在数据库上检查它,但鉴于我已将 nullable 设置为 true,我不会期待此错误。
有人有线索吗?多谢你们。
解决方案
推荐阅读
- pdf - 如何在 Powerbuilder 中为使用 OLE 控件添加的 PDF 设置标题?
- c# - 具有包含/任何功能的类型和实例的集合
- vba - 插入查询未在循环内执行
- java - 单元测试方法在运行测试时不使用模拟对象。而是调用实际的类和方法
- php - PHP GMP:将字符串转换为数字(更改基数)
- llvm - ld:架构 arm64 的无效记录
- javascript - 仅从 JavaScript 中的值的子部分显示
- css - CSS 摆脱 Wordpress 29 主题中的空白?
- node.js - 使用 API 编辑 Azure Blob 存储中的文件
- php - 尝试访问多维数组中的元素时 PHP 获取“未定义的偏移量”