test fixes

This commit is contained in:
Dennis Eichhorn 2023-10-22 14:15:33 +00:00
parent a4f7d2e527
commit 2cbbe69bac
4 changed files with 21 additions and 3 deletions

View File

@ -60,6 +60,10 @@ class MysqlGrammar extends Grammar
$expression = '*';
}
return 'SELECT ' . $expression . ' ' . $this->compileFrom($query, $query->from) . ' ' . $this->compileWheres($query, $query->wheres) . ' ORDER BY RAND() ' . $this->compileLimit($query, $query->limit ?? 1);
return 'SELECT ' . $expression
. ' ' . $this->compileFrom($query, $query->from)
. ' ' . $this->compileWheres($query, $query->wheres)
. ' ORDER BY RAND() '
. $this->compileLimit($query, $query->limit ?? 1);
}
}

View File

@ -759,6 +759,20 @@ class Matrix implements \ArrayAccess, \Iterator
$result[$i] = $temp;
}
return self::fromArray($result);
} elseif (!$isMatrix1 && $isMatrix2) {
$result = [];
for ($i = 0; $i < $m1; ++$i) { // Row of 1
$temp = 0;
for ($c = 0; $c < $m2; ++$c) { // Row of 2
/** @var array $value1 */
$temp += $value2[$i][$c] * $value1[$c];
}
$result[$i] = $temp;
}
return self::fromArray($result);
}

View File

@ -121,7 +121,7 @@ final class BuilderTest extends \PHPUnit\Framework\TestCase
$iE = $con->getGrammar()->systemIdentifierEnd;
$query = new Builder($con);
$sql = 'SELECT [a].[test] FROM [a] as b WHERE [a].[test] = 1 ORDER BY \rand() LIMIT 1;';
$sql = 'SELECT [a].[test] FROM [a] as b WHERE [a].[test] = 1 ORDER BY RAND() LIMIT 1;';
$sql = \strtr($sql, '[]', $iS . $iE);
self::assertEquals($sql, $query->random('a.test')->fromAs('a', 'b')->where('a.test', '=', 1)->toSql());
}

View File

@ -495,7 +495,7 @@ final class MatrixTest extends \PHPUnit\Framework\TestCase
public function testDotVectors() : void
{
$v1 = Vector::fromArray([1, 3, -5]);
$v1 = Vector::fromArray([1, 3, -5])->transpose();
self::assertEquals(
3,