mirror of
https://github.com/shlinkio/shlink.git
synced 2026-03-10 01:03:13 +08:00
Ensure short_code column is case sensitive in Microsoft SQL server
This commit is contained in:
@@ -39,8 +39,8 @@ class ShortUrl extends AbstractEntity
|
||||
private string $longUrl;
|
||||
private string $shortCode;
|
||||
private Chronos $dateCreated;
|
||||
/** @var Collection<int, Visit> */
|
||||
private Collection $visits;
|
||||
/** @var Collection<int, Visit> & Selectable */
|
||||
private Collection & Selectable $visits;
|
||||
/** @var Collection<string, DeviceLongUrl> */
|
||||
private Collection $deviceLongUrls;
|
||||
/** @var Collection<int, Tag> */
|
||||
@@ -255,23 +255,19 @@ class ShortUrl extends AbstractEntity
|
||||
|
||||
public function mostRecentImportedVisitDate(): ?Chronos
|
||||
{
|
||||
/** @var Selectable $visits */
|
||||
$visits = $this->visits;
|
||||
$criteria = Criteria::create()->where(Criteria::expr()->eq('type', VisitType::IMPORTED))
|
||||
->orderBy(['id' => 'DESC'])
|
||||
->setMaxResults(1);
|
||||
$visit = $this->visits->matching($criteria)->last();
|
||||
|
||||
/** @var Visit|false $visit */
|
||||
$visit = $visits->matching($criteria)->last();
|
||||
|
||||
return $visit === false ? null : $visit->getDate();
|
||||
return $visit instanceof Visit ? $visit->getDate() : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Collection<int, Visit> $visits
|
||||
* @param Collection<int, Visit> & Selectable $visits
|
||||
* @internal
|
||||
*/
|
||||
public function setVisits(Collection $visits): self
|
||||
public function setVisits(Collection & Selectable $visits): self
|
||||
{
|
||||
$this->visits = $visits;
|
||||
return $this;
|
||||
|
||||
@@ -5,7 +5,6 @@ declare(strict_types=1);
|
||||
namespace ShlinkioDbTest\Shlink\Core\ShortUrl\Repository;
|
||||
|
||||
use Cake\Chronos\Chronos;
|
||||
use Doctrine\DBAL\Platforms\SQLServerPlatform;
|
||||
use Shlinkio\Shlink\Core\Domain\Entity\Domain;
|
||||
use Shlinkio\Shlink\Core\ShortUrl\Entity\ShortUrl;
|
||||
use Shlinkio\Shlink\Core\ShortUrl\Model\ShortUrlCreation;
|
||||
@@ -61,13 +60,10 @@ class ShortUrlRepositoryTest extends DatabaseTestCase
|
||||
ShortUrlIdentifier::fromShortCodeAndDomain('fOo'),
|
||||
ShortUrlMode::LOOSE,
|
||||
));
|
||||
// TODO MS is doing loose checks always, making this fail.
|
||||
if (! $this->getEntityManager()->getConnection()->getDatabasePlatform() instanceof SQLServerPlatform) {
|
||||
self::assertNull($this->repo->findOneWithDomainFallback(
|
||||
ShortUrlIdentifier::fromShortCodeAndDomain('foo'),
|
||||
ShortUrlMode::STRICT,
|
||||
));
|
||||
}
|
||||
self::assertNull($this->repo->findOneWithDomainFallback(
|
||||
ShortUrlIdentifier::fromShortCodeAndDomain('foo'),
|
||||
ShortUrlMode::STRICT,
|
||||
));
|
||||
self::assertSame($regularOne, $this->repo->findOneWithDomainFallback(
|
||||
ShortUrlIdentifier::fromShortCodeAndDomain($withDomainDuplicatingRegular->getShortCode()),
|
||||
ShortUrlMode::STRICT,
|
||||
|
||||
Reference in New Issue
Block a user