Fix Oracle insert error

This commit is contained in:
Thomas Müller 2015-12-14 11:48:31 +01:00 committed by Björn Schießle
parent cd55a19034
commit e5469a1121
2 changed files with 8 additions and 4 deletions

View file

@ -29,6 +29,7 @@ use Sabre\CardDAV\Backend\BackendInterface;
use Sabre\CardDAV\Backend\SyncSupport;
use Sabre\CardDAV\Plugin;
use Sabre\DAV\Exception\BadRequest;
use Sabre\VObject\Component\VCard;
use Sabre\VObject\Reader;
class CardDavBackend implements BackendInterface, SyncSupport {
@ -431,7 +432,7 @@ class CardDavBackend implements BackendInterface, SyncSupport {
$query = $this->db->getQueryBuilder();
$query->insert('cards')
->values([
'carddata' => $query->createNamedParameter($cardData),
'carddata' => $query->createNamedParameter($cardData, \PDO::PARAM_LOB),
'uri' => $query->createNamedParameter($cardUri),
'lastmodified' => $query->createNamedParameter(time()),
'addressbookid' => $query->createNamedParameter($addressBookId),
@ -688,7 +689,7 @@ class CardDavBackend implements BackendInterface, SyncSupport {
*/
public function search($addressBookId, $pattern, $searchProperties) {
$query = $this->db->getQueryBuilder();
$query->selectDistinct('carddata', 'c')
$query->selectDistinct(['carddata', 'c'])
->from($this->dbCardsTable, 'c')
->leftJoin('c', $this->dbCardsPropertiesTable, 'cp', $query->expr()->eq('cp.cardid', 'c.id'));
foreach ($searchProperties as $property) {

View file

@ -20,6 +20,7 @@
*/
namespace OCA\DAV\Tests\Unit\CardDAV;
use InvalidArgumentException;
use OCA\DAV\CardDAV\CardDavBackend;
use OCA\DAV\Connector\Sabre\Principal;
use OCP\IDBConnection;
@ -126,6 +127,7 @@ class CardDavBackendTest extends TestCase {
public function testCardOperations() {
/** @var CardDavBackend | \PHPUnit_Framework_MockObject_MockObject $backend */
$backend = $this->getMockBuilder('OCA\DAV\CardDAV\CardDavBackend')
->setConstructorArgs([$this->db, $this->principal, $this->logger])
->setMethods(['updateProperties', 'purgeProperties'])->getMock();
@ -392,6 +394,7 @@ class CardDavBackendTest extends TestCase {
* @param array $expected
*/
public function testSearch($pattern, $expected) {
/** @var VCard $vCards */
$vCards = [];
$vCards[0] = new VCard();
$vCards[0]->add(new Text($vCards[0], 'UID', 'uid'));
@ -407,9 +410,9 @@ class CardDavBackendTest extends TestCase {
->values(
[
'addressbookid' => $query->createNamedParameter(0),
'carddata' => $query->createNamedParameter($vCards[$i]->serialize()),
'carddata' => $query->createNamedParameter($vCards[$i]->serialize(), \PDO::PARAM_LOB),
'uri' => $query->createNamedParameter('uri' . $i),
'lastmodified' => $query->createNamedParameter(5489543),
'lastmodified' => $query->createNamedParameter(time()),
'etag' => $query->createNamedParameter('etag' . $i),
'size' => $query->createNamedParameter(120),
]