选择具有空值的对象
如何在 GQL 中仅选择具有空值的对象。我有一个对象,对于我的软件的新版本,我包含 LastUpdate 字段,并且我只想更新最旧的更新对象,但是当我使用“ ORDER BY LastUpdate ASC”进行查询时,应始终使用此查询! ,它总是只返回 LastUpdate 中具有某些值的对象。
如何在查询中包含具有空值的对象的最佳方式?
How can I select only objects with null values in GQL. I have a object that for a new version of my software I include a LastUpdate fields, and I want to update only the oldest updated object, but when I made the query using " ORDER BY LastUpdate ASC", this query should always be used!, it always return only the objects with some value in LastUpdate.
How the best way I can include in a query the objects with null value?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果数据存储中的实体没有设置新属性,则无法对其进行查询。
实体的属性不会有
null
值,该属性根本不存在,因此不会包含在您用来查询实体的任何索引中。查找需要更新的实体的唯一方法是映射所有实体并查找缺少值的实体。If an entity in the datastore does not have the new attribute set, then it is impossible to query on it.
The entities will not have a
null
value for the property, the property simply will not exist, therfore will not be included in any indexes that you would use to query your entities. The only way to find your entities that need updating is to map over ALL entities and find the ones with missing values.您对记录创建有多少控制权?您始终可以创建一条新记录,并将 LastUpdate 字段设置为与 RecordCreated 字段相同的值。这样该字段就永远不会为空,并且始终可以查询。
缺点:您还会选取很久以前创建且此后未更新的记录。
How much control do you have over record creation? You could always create a new record with the LastUpdate field set to the same value as the RecordCreated field. That way the field would never be blank and could always be queried.
Disadvantage: you would also pick up records that were created a long time ago and not updated since.
也许使用 NVL 包装器...
NVL( LastUpdate, sysdate )
maybe use an NVL wrapper ...
NVL( LastUpdate, sysdate )