空白和空白约束之间的区别 [英] Difference between blank and null constraints
本文介绍了空白和空白约束之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
空白和空限制有什么区别?
我有以下班级
<$ p $任务{
字符串标题
字符串笔记
TekUser分配给
日期dueDate
TekEvent事件
static constraints = {
title blank:false
notes blank:true,maxSize:5000
assignedTo可以为null:true
dueDate可以为null:true
}
static belongsTo = TekEvent
}
即使我指定了 notes blank:true
空白:true有没有影响?
解决方案
-
blank:true
字段接受一个空字符串或仅由空格组成的字符串作为有效值。例如:,
-
nullable:true
表示该字段接受null
作为有效值
它们可以一起使用。例如:
title blank:false,nullable:true
What is the difference between the blank and null constraints ?
I have the following class
class Task {
String title
String notes
TekUser assignedTo
Date dueDate
TekEvent event
static constraints = {
title blank:false
notes blank: true , maxSize: 5000
assignedTo nullable:true
dueDate nullable:true
}
static belongsTo = TekEvent
}
and the mysql table created has the notes set to not null even though I specified notes blank : true
What effect does blank : true have ?
解决方案
blank:true
means the field accepts an empty string or one composed only by spaces as valid values. Eg:""
," "
nullable:true
means the field acceptsnull
as valid value
They can be used together. Eg:
title blank:false, nullable: true
这篇关于空白和空白约束之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文