Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/text.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib/Db
diff options
context:
space:
mode:
authorJulius Härtl <jus@bitgrid.net>2019-05-08 18:44:09 +0300
committerJulius Härtl <jus@bitgrid.net>2019-05-08 18:44:09 +0300
commitd24b3fadb43810cf94bc652e8710a02019e1a801 (patch)
tree068bc6f0d14fad706db837e7d175c1dd20e98ecb /lib/Db
parenta868aca3e6c1f8669398ac4a747fa40a496319e7 (diff)
Proper conflict handling in the backend
Signed-off-by: Julius Härtl <jus@bitgrid.net>
Diffstat (limited to 'lib/Db')
-rw-r--r--lib/Db/Document.php2
-rw-r--r--lib/Db/StepMapper.php11
2 files changed, 11 insertions, 2 deletions
diff --git a/lib/Db/Document.php b/lib/Db/Document.php
index 5c1e30c06..07a1e64ce 100644
--- a/lib/Db/Document.php
+++ b/lib/Db/Document.php
@@ -33,6 +33,8 @@ class Document extends Entity implements \JsonSerializable {
protected $lastSavedVersion = 0;
protected $initialVersion = 0;
protected $lastSavedVersionTime = 0;
+ protected $lastSavedVersionEtag = '';
+ protected $baseVersionEtag = '';
public function __construct() {
$this->addType('id', 'integer');
diff --git a/lib/Db/StepMapper.php b/lib/Db/StepMapper.php
index 847409750..6b580ee9b 100644
--- a/lib/Db/StepMapper.php
+++ b/lib/Db/StepMapper.php
@@ -34,13 +34,20 @@ class StepMapper extends QBMapper {
parent::__construct($db, 'text_steps', Step::class);
}
- public function find($documentId, $fromVersion) {
+ public function find($documentId, $fromVersion, $lastAckedVersion = null) {
/* @var $qb IQueryBuilder */
$qb = $this->db->getQueryBuilder();
$qb->select('*')
->from($this->getTableName())
->where($qb->expr()->eq('document_id', $qb->createNamedParameter($documentId)))
- ->andWhere($qb->expr()->gt('version', $qb->createNamedParameter($fromVersion)))
+ ->andWhere($qb->expr()->gt('version', $qb->createNamedParameter($fromVersion)));
+ // WIP: only return steps that were persisted completely
+ if ($lastAckedVersion) {
+ $qb->andWhere($qb->expr()->lte('version', $qb->createNamedParameter($lastAckedVersion)));
+ }
+ $qb
+ // TODO: limiting results currently causes the loading detection to fail
+ // ->setMaxResults(500)
->execute();
return $this->findEntities($qb);