错误 4.5 Expression must be a group key or aggregate
Error in 4.5 Expression must be a group key or aggregate
升级到 Couchbase 4.5 后,我开始收到此错误 "Expression must be a group key or aggregate (write
.timestamp
)","code":4210}。我在这里做错了什么?这是我的查询
select max(timestamp) as lastDetect, count(timestamp) as detectCount
from write
where docType is not missing AND docType = 'DetectRecord' AND proximityUUID = $uuid AND major = $major AND minor = $minor AND timestamp BETWEEN $startTime AND $endTime ORDER BY timestamp desc limit 1;
示例文档:
{
"id": "1234k",
"docType": "DetectRecord",
"proximityUUID": "12kdf",
"major": "dkf",
"minor": "ad",
"timestamp": 1464954200000
}
这是由添加到 couchbase 4.5 (http://developer.couchbase.com/documentation/server/4.5/release-notes/relnotes.html) 的更改引起的。将查询更改为以下内容为我解决了这个问题。
select max(timestamp) as lastDetect, count(timestamp) as detectCount
from write
where docType is not missing AND docType = 'DetectRecord' AND proximityUUID = $uuid AND major = $major AND minor = $minor AND timestamp BETWEEN $startTime AND $endTime
GROUP BY timestamp
ORDER BY timestamp desc limit 1;
是的,Marquis,N1QL 在 4.5 中强制执行正确的 GROUP BY syntax/semantics。发行说明 "behavior changes" 中提到了这一点:http://developer.couchbase.com/documentation/server/4.5/release-notes/relnotes.html
升级到 Couchbase 4.5 后,我开始收到此错误 "Expression must be a group key or aggregate (write
.timestamp
)","code":4210}。我在这里做错了什么?这是我的查询
select max(timestamp) as lastDetect, count(timestamp) as detectCount
from write
where docType is not missing AND docType = 'DetectRecord' AND proximityUUID = $uuid AND major = $major AND minor = $minor AND timestamp BETWEEN $startTime AND $endTime ORDER BY timestamp desc limit 1;
示例文档:
{
"id": "1234k",
"docType": "DetectRecord",
"proximityUUID": "12kdf",
"major": "dkf",
"minor": "ad",
"timestamp": 1464954200000
}
这是由添加到 couchbase 4.5 (http://developer.couchbase.com/documentation/server/4.5/release-notes/relnotes.html) 的更改引起的。将查询更改为以下内容为我解决了这个问题。
select max(timestamp) as lastDetect, count(timestamp) as detectCount
from write
where docType is not missing AND docType = 'DetectRecord' AND proximityUUID = $uuid AND major = $major AND minor = $minor AND timestamp BETWEEN $startTime AND $endTime
GROUP BY timestamp
ORDER BY timestamp desc limit 1;
是的,Marquis,N1QL 在 4.5 中强制执行正确的 GROUP BY syntax/semantics。发行说明 "behavior changes" 中提到了这一点:http://developer.couchbase.com/documentation/server/4.5/release-notes/relnotes.html