Bug fixes

This commit is contained in:
Dennis Eichhorn 2019-10-21 15:38:15 +02:00
parent f6fb7f4747
commit baf2218980
5 changed files with 22 additions and 3 deletions

View File

@ -495,7 +495,10 @@ class DataMapperAbstract implements DataMapperInterface
var_dump($query->toSql());
}
return self::$db->con->lastInsertId();
$objId = self::$db->con->lastInsertId();
\settype($objId, static::$columns[static::$primaryField]['type']);
return $objId;
}
/**

View File

@ -418,7 +418,7 @@ class Grammar extends GrammarAbstract
$expression .= '(' . \rtrim($join['table']->toSql(), ';') . ')' . (\is_string($key) ? ' as ' . $query->getPrefix() . $key : '');
}
$expression .= $this->compileOn($query, $query->ons[$key]);
$expression .= $this->compileOn($query, $query->ons[$key]) . ' ';
}
$expression = \rtrim($expression, ', ');

View File

@ -27,7 +27,7 @@ class Heap
/**
* Comparison function
*
* @var \Closure
* @var \Closure
* @since 1.0.0
*/
private \Closure $compare;

View File

@ -142,6 +142,20 @@ class SmartDateTime extends \DateTime
return new self($this->format('Y') . '-' . $this->format('m') . '-01');
}
/**
* Get start of the week
*
* @return SmartDateTime
*
* @since 1.0.0
*/
public function getStartOfWeek() : self
{
$w = \strtotime('-' . \date('w', $this->getTimestamp()) .' days', $this->getTimestamp());
return new self(\date('Y-m-d', $w));
}
/**
* Get days of current month
*

View File

@ -59,6 +59,8 @@ class SmartDateTimeTest extends \PHPUnit\Framework\TestCase
self::assertTrue(SmartDateTime::leapYear(2104));
self::assertEquals(\date('w', $expected->getTimestamp()), SmartDateTime::getDayOfWeek((int) $expected->format('Y'), (int) $expected->format('m'), (int) $expected->format('d')));
// todo: i think this assertion is wrong! or the function getFirstDay... doesn't do what is supposed to do
self::assertEquals(\date('w', $expected->getTimestamp()), $obj->getFirstDayOfWeek());
self::assertCount(42, $obj->getMonthCalendar());