Merge pull request #22573 from owncloud/issue-22568-allow-string-object-ids
Make sure we can store strings as per the interface
This commit is contained in:
commit
2ec1c738d0
|
@ -1249,11 +1249,10 @@
|
||||||
<!-- object id (ex: file id for files)-->
|
<!-- object id (ex: file id for files)-->
|
||||||
<field>
|
<field>
|
||||||
<name>objectid</name>
|
<name>objectid</name>
|
||||||
<type>integer</type>
|
<type>text</type>
|
||||||
<default>0</default>
|
<default></default>
|
||||||
<notnull>true</notnull>
|
<notnull>true</notnull>
|
||||||
<unsigned>true</unsigned>
|
<length>64</length>
|
||||||
<length>4</length>
|
|
||||||
</field>
|
</field>
|
||||||
|
|
||||||
<!-- object type (ex: "files")-->
|
<!-- object type (ex: "files")-->
|
||||||
|
|
|
@ -103,7 +103,7 @@ class SystemTagObjectMapper implements ISystemTagObjectMapper {
|
||||||
$this->assertTagsExist($tagIds);
|
$this->assertTagsExist($tagIds);
|
||||||
|
|
||||||
$query = $this->connection->getQueryBuilder();
|
$query = $this->connection->getQueryBuilder();
|
||||||
$query->select($query->createFunction('DISTINCT(`objectid`)'))
|
$query->selectDistinct('objectid')
|
||||||
->from(self::RELATION_TABLE)
|
->from(self::RELATION_TABLE)
|
||||||
->where($query->expr()->in('systemtagid', $query->createNamedParameter($tagIds, IQueryBuilder::PARAM_INT_ARRAY)))
|
->where($query->expr()->in('systemtagid', $query->createNamedParameter($tagIds, IQueryBuilder::PARAM_INT_ARRAY)))
|
||||||
->andWhere($query->expr()->eq('objecttype', $query->createNamedParameter($objectType)));
|
->andWhere($query->expr()->eq('objecttype', $query->createNamedParameter($objectType)));
|
||||||
|
@ -219,7 +219,7 @@ class SystemTagObjectMapper implements ISystemTagObjectMapper {
|
||||||
->where($query->expr()->in('objectid', $query->createParameter('objectids')))
|
->where($query->expr()->in('objectid', $query->createParameter('objectids')))
|
||||||
->andWhere($query->expr()->eq('objecttype', $query->createParameter('objecttype')))
|
->andWhere($query->expr()->eq('objecttype', $query->createParameter('objecttype')))
|
||||||
->andWhere($query->expr()->eq('systemtagid', $query->createParameter('tagid')))
|
->andWhere($query->expr()->eq('systemtagid', $query->createParameter('tagid')))
|
||||||
->setParameter('objectids', $objIds, IQueryBuilder::PARAM_INT_ARRAY)
|
->setParameter('objectids', $objIds, IQueryBuilder::PARAM_STR_ARRAY)
|
||||||
->setParameter('tagid', $tagId)
|
->setParameter('tagid', $tagId)
|
||||||
->setParameter('objecttype', $objectType);
|
->setParameter('objecttype', $objectType);
|
||||||
|
|
||||||
|
|
|
@ -102,10 +102,10 @@ class SystemTagObjectMapperTest extends TestCase {
|
||||||
return $result;
|
return $result;
|
||||||
}));
|
}));
|
||||||
|
|
||||||
$this->tagMapper->assignTags(1, 'testtype', $this->tag1->getId());
|
$this->tagMapper->assignTags('1', 'testtype', $this->tag1->getId());
|
||||||
$this->tagMapper->assignTags(1, 'testtype', $this->tag2->getId());
|
$this->tagMapper->assignTags('1', 'testtype', $this->tag2->getId());
|
||||||
$this->tagMapper->assignTags(2, 'testtype', $this->tag1->getId());
|
$this->tagMapper->assignTags('2', 'testtype', $this->tag1->getId());
|
||||||
$this->tagMapper->assignTags(3, 'anothertype', $this->tag1->getId());
|
$this->tagMapper->assignTags('3', 'anothertype', $this->tag1->getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function tearDown() {
|
public function tearDown() {
|
||||||
|
@ -121,15 +121,15 @@ class SystemTagObjectMapperTest extends TestCase {
|
||||||
|
|
||||||
public function testGetTagsForObjects() {
|
public function testGetTagsForObjects() {
|
||||||
$tagIdMapping = $this->tagMapper->getTagIdsForObjects(
|
$tagIdMapping = $this->tagMapper->getTagIdsForObjects(
|
||||||
[1, 2, 3, 4],
|
['1', '2', '3', '4'],
|
||||||
'testtype'
|
'testtype'
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->assertEquals([
|
$this->assertEquals([
|
||||||
1 => [$this->tag1->getId(), $this->tag2->getId()],
|
'1' => [$this->tag1->getId(), $this->tag2->getId()],
|
||||||
2 => [$this->tag1->getId()],
|
'2' => [$this->tag1->getId()],
|
||||||
3 => [],
|
'3' => [],
|
||||||
4 => [],
|
'4' => [],
|
||||||
], $tagIdMapping);
|
], $tagIdMapping);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -140,8 +140,8 @@ class SystemTagObjectMapperTest extends TestCase {
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->assertEquals([
|
$this->assertEquals([
|
||||||
1,
|
'1',
|
||||||
2,
|
'2',
|
||||||
], $objectIds);
|
], $objectIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -192,29 +192,29 @@ class SystemTagObjectMapperTest extends TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testAssignUnassignTags() {
|
public function testAssignUnassignTags() {
|
||||||
$this->tagMapper->unassignTags(1, 'testtype', [$this->tag1->getId()]);
|
$this->tagMapper->unassignTags('1', 'testtype', [$this->tag1->getId()]);
|
||||||
|
|
||||||
$tagIdMapping = $this->tagMapper->getTagIdsForObjects(1, 'testtype');
|
$tagIdMapping = $this->tagMapper->getTagIdsForObjects('1', 'testtype');
|
||||||
$this->assertEquals([
|
$this->assertEquals([
|
||||||
1 => [$this->tag2->getId()],
|
1 => [$this->tag2->getId()],
|
||||||
], $tagIdMapping);
|
], $tagIdMapping);
|
||||||
|
|
||||||
$this->tagMapper->assignTags(1, 'testtype', [$this->tag1->getId()]);
|
$this->tagMapper->assignTags('1', 'testtype', [$this->tag1->getId()]);
|
||||||
$this->tagMapper->assignTags(1, 'testtype', $this->tag3->getId());
|
$this->tagMapper->assignTags('1', 'testtype', $this->tag3->getId());
|
||||||
|
|
||||||
$tagIdMapping = $this->tagMapper->getTagIdsForObjects(1, 'testtype');
|
$tagIdMapping = $this->tagMapper->getTagIdsForObjects('1', 'testtype');
|
||||||
|
|
||||||
$this->assertEquals([
|
$this->assertEquals([
|
||||||
1 => [$this->tag1->getId(), $this->tag2->getId(), $this->tag3->getId()],
|
'1' => [$this->tag1->getId(), $this->tag2->getId(), $this->tag3->getId()],
|
||||||
], $tagIdMapping);
|
], $tagIdMapping);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testReAssignUnassignTags() {
|
public function testReAssignUnassignTags() {
|
||||||
// reassign tag1
|
// reassign tag1
|
||||||
$this->tagMapper->assignTags(1, 'testtype', [$this->tag1->getId()]);
|
$this->tagMapper->assignTags('1', 'testtype', [$this->tag1->getId()]);
|
||||||
|
|
||||||
// tag 3 was never assigned
|
// tag 3 was never assigned
|
||||||
$this->tagMapper->unassignTags(1, 'testtype', [$this->tag3->getId()]);
|
$this->tagMapper->unassignTags('1', 'testtype', [$this->tag3->getId()]);
|
||||||
|
|
||||||
$this->assertTrue(true, 'No error when reassigning/unassigning');
|
$this->assertTrue(true, 'No error when reassigning/unassigning');
|
||||||
}
|
}
|
||||||
|
@ -223,13 +223,13 @@ class SystemTagObjectMapperTest extends TestCase {
|
||||||
* @expectedException \OCP\SystemTag\TagNotFoundException
|
* @expectedException \OCP\SystemTag\TagNotFoundException
|
||||||
*/
|
*/
|
||||||
public function testAssignNonExistingTags() {
|
public function testAssignNonExistingTags() {
|
||||||
$this->tagMapper->assignTags(1, 'testtype', [100]);
|
$this->tagMapper->assignTags('1', 'testtype', [100]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testAssignNonExistingTagInArray() {
|
public function testAssignNonExistingTagInArray() {
|
||||||
$caught = false;
|
$caught = false;
|
||||||
try {
|
try {
|
||||||
$this->tagMapper->assignTags(1, 'testtype', [100, $this->tag3->getId()]);
|
$this->tagMapper->assignTags('1', 'testtype', [100, $this->tag3->getId()]);
|
||||||
} catch (TagNotFoundException $e) {
|
} catch (TagNotFoundException $e) {
|
||||||
$caught = true;
|
$caught = true;
|
||||||
}
|
}
|
||||||
|
@ -237,12 +237,12 @@ class SystemTagObjectMapperTest extends TestCase {
|
||||||
$this->assertTrue($caught, 'Exception thrown');
|
$this->assertTrue($caught, 'Exception thrown');
|
||||||
|
|
||||||
$tagIdMapping = $this->tagMapper->getTagIdsForObjects(
|
$tagIdMapping = $this->tagMapper->getTagIdsForObjects(
|
||||||
[1],
|
['1'],
|
||||||
'testtype'
|
'testtype'
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->assertEquals([
|
$this->assertEquals([
|
||||||
1 => [$this->tag1->getId(), $this->tag2->getId()],
|
'1' => [$this->tag1->getId(), $this->tag2->getId()],
|
||||||
], $tagIdMapping, 'None of the tags got assigned');
|
], $tagIdMapping, 'None of the tags got assigned');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -250,13 +250,13 @@ class SystemTagObjectMapperTest extends TestCase {
|
||||||
* @expectedException \OCP\SystemTag\TagNotFoundException
|
* @expectedException \OCP\SystemTag\TagNotFoundException
|
||||||
*/
|
*/
|
||||||
public function testUnassignNonExistingTags() {
|
public function testUnassignNonExistingTags() {
|
||||||
$this->tagMapper->unassignTags(1, 'testtype', [100]);
|
$this->tagMapper->unassignTags('1', 'testtype', [100]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testUnassignNonExistingTagsInArray() {
|
public function testUnassignNonExistingTagsInArray() {
|
||||||
$caught = false;
|
$caught = false;
|
||||||
try {
|
try {
|
||||||
$this->tagMapper->unassignTags(1, 'testtype', [100, $this->tag1->getId()]);
|
$this->tagMapper->unassignTags('1', 'testtype', [100, $this->tag1->getId()]);
|
||||||
} catch (TagNotFoundException $e) {
|
} catch (TagNotFoundException $e) {
|
||||||
$caught = true;
|
$caught = true;
|
||||||
}
|
}
|
||||||
|
@ -269,14 +269,14 @@ class SystemTagObjectMapperTest extends TestCase {
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->assertEquals([
|
$this->assertEquals([
|
||||||
1 => [$this->tag1->getId(), $this->tag2->getId()],
|
'1' => [$this->tag1->getId(), $this->tag2->getId()],
|
||||||
], $tagIdMapping, 'None of the tags got unassigned');
|
], $tagIdMapping, 'None of the tags got unassigned');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testHaveTagAllMatches() {
|
public function testHaveTagAllMatches() {
|
||||||
$this->assertTrue(
|
$this->assertTrue(
|
||||||
$this->tagMapper->haveTag(
|
$this->tagMapper->haveTag(
|
||||||
[1],
|
['1'],
|
||||||
'testtype',
|
'testtype',
|
||||||
$this->tag1->getId(),
|
$this->tag1->getId(),
|
||||||
true
|
true
|
||||||
|
@ -286,7 +286,7 @@ class SystemTagObjectMapperTest extends TestCase {
|
||||||
|
|
||||||
$this->assertTrue(
|
$this->assertTrue(
|
||||||
$this->tagMapper->haveTag(
|
$this->tagMapper->haveTag(
|
||||||
[1, 2],
|
['1', '2'],
|
||||||
'testtype',
|
'testtype',
|
||||||
$this->tag1->getId(),
|
$this->tag1->getId(),
|
||||||
true
|
true
|
||||||
|
@ -296,7 +296,7 @@ class SystemTagObjectMapperTest extends TestCase {
|
||||||
|
|
||||||
$this->assertFalse(
|
$this->assertFalse(
|
||||||
$this->tagMapper->haveTag(
|
$this->tagMapper->haveTag(
|
||||||
[1, 2],
|
['1', '2'],
|
||||||
'testtype',
|
'testtype',
|
||||||
$this->tag2->getId(),
|
$this->tag2->getId(),
|
||||||
true
|
true
|
||||||
|
@ -306,7 +306,7 @@ class SystemTagObjectMapperTest extends TestCase {
|
||||||
|
|
||||||
$this->assertFalse(
|
$this->assertFalse(
|
||||||
$this->tagMapper->haveTag(
|
$this->tagMapper->haveTag(
|
||||||
[2],
|
['2'],
|
||||||
'testtype',
|
'testtype',
|
||||||
$this->tag2->getId(),
|
$this->tag2->getId(),
|
||||||
true
|
true
|
||||||
|
@ -316,7 +316,7 @@ class SystemTagObjectMapperTest extends TestCase {
|
||||||
|
|
||||||
$this->assertFalse(
|
$this->assertFalse(
|
||||||
$this->tagMapper->haveTag(
|
$this->tagMapper->haveTag(
|
||||||
[3],
|
['3'],
|
||||||
'testtype',
|
'testtype',
|
||||||
$this->tag2->getId(),
|
$this->tag2->getId(),
|
||||||
true
|
true
|
||||||
|
@ -328,7 +328,7 @@ class SystemTagObjectMapperTest extends TestCase {
|
||||||
public function testHaveTagAtLeastOneMatch() {
|
public function testHaveTagAtLeastOneMatch() {
|
||||||
$this->assertTrue(
|
$this->assertTrue(
|
||||||
$this->tagMapper->haveTag(
|
$this->tagMapper->haveTag(
|
||||||
[1],
|
['1'],
|
||||||
'testtype',
|
'testtype',
|
||||||
$this->tag1->getId(),
|
$this->tag1->getId(),
|
||||||
false
|
false
|
||||||
|
@ -338,7 +338,7 @@ class SystemTagObjectMapperTest extends TestCase {
|
||||||
|
|
||||||
$this->assertTrue(
|
$this->assertTrue(
|
||||||
$this->tagMapper->haveTag(
|
$this->tagMapper->haveTag(
|
||||||
[1, 2],
|
['1', '2'],
|
||||||
'testtype',
|
'testtype',
|
||||||
$this->tag1->getId(),
|
$this->tag1->getId(),
|
||||||
false
|
false
|
||||||
|
@ -348,7 +348,7 @@ class SystemTagObjectMapperTest extends TestCase {
|
||||||
|
|
||||||
$this->assertTrue(
|
$this->assertTrue(
|
||||||
$this->tagMapper->haveTag(
|
$this->tagMapper->haveTag(
|
||||||
[1, 2],
|
['1', '2'],
|
||||||
'testtype',
|
'testtype',
|
||||||
$this->tag2->getId(),
|
$this->tag2->getId(),
|
||||||
false
|
false
|
||||||
|
@ -358,7 +358,7 @@ class SystemTagObjectMapperTest extends TestCase {
|
||||||
|
|
||||||
$this->assertFalse(
|
$this->assertFalse(
|
||||||
$this->tagMapper->haveTag(
|
$this->tagMapper->haveTag(
|
||||||
[2],
|
['2'],
|
||||||
'testtype',
|
'testtype',
|
||||||
$this->tag2->getId(),
|
$this->tag2->getId(),
|
||||||
false
|
false
|
||||||
|
@ -368,7 +368,7 @@ class SystemTagObjectMapperTest extends TestCase {
|
||||||
|
|
||||||
$this->assertFalse(
|
$this->assertFalse(
|
||||||
$this->tagMapper->haveTag(
|
$this->tagMapper->haveTag(
|
||||||
[3],
|
['3'],
|
||||||
'testtype',
|
'testtype',
|
||||||
$this->tag2->getId(),
|
$this->tag2->getId(),
|
||||||
false
|
false
|
||||||
|
@ -382,7 +382,7 @@ class SystemTagObjectMapperTest extends TestCase {
|
||||||
*/
|
*/
|
||||||
public function testHaveTagNonExisting() {
|
public function testHaveTagNonExisting() {
|
||||||
$this->tagMapper->haveTag(
|
$this->tagMapper->haveTag(
|
||||||
[1],
|
['1'],
|
||||||
'testtype',
|
'testtype',
|
||||||
100
|
100
|
||||||
);
|
);
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
// We only can count up. The 4. digit is only for the internal patchlevel to trigger DB upgrades
|
// We only can count up. The 4. digit is only for the internal patchlevel to trigger DB upgrades
|
||||||
// between betas, final and RCs. This is _not_ the public version number. Reset minor/patchlevel
|
// between betas, final and RCs. This is _not_ the public version number. Reset minor/patchlevel
|
||||||
// when updating major/minor version number.
|
// when updating major/minor version number.
|
||||||
$OC_Version = array(9, 0, 0, 12);
|
$OC_Version = array(9, 0, 0, 13);
|
||||||
|
|
||||||
// The human readable string
|
// The human readable string
|
||||||
$OC_VersionString = '9.0.0 beta 2';
|
$OC_VersionString = '9.0.0 beta 2';
|
||||||
|
|
Loading…
Reference in New Issue