Skip to content

Commit 1c094f1

Browse files
committed
Jet Core
------------ * ORM DataModel: Bug fix (fatal error): DateTime->onOnlyDate was ignored. This made it impossible to create queries with only date and not time.
1 parent 9a7c275 commit 1c094f1

File tree

4 files changed

+16
-7
lines changed

4 files changed

+16
-7
lines changed

library/Jet/DataModel/Backend/MSSQL.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,10 @@ protected function _getValue( mixed $value ): float|int|string
390390
}
391391

392392
if( $value instanceof Data_DateTime ) {
393-
$value = $value->format( 'Y-m-d H:i:s' );
393+
$value = $value->isOnlyDate() ?
394+
$value->format( 'Y-m-d' )
395+
:
396+
$value->format( 'Y-m-d H:i:s' );
394397
}
395398

396399
if(

library/Jet/DataModel/Backend/MySQL.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,10 @@ protected function _getValue( mixed $value ): float|int|string
389389
}
390390

391391
if( $value instanceof Data_DateTime ) {
392-
$value = $value->format( 'Y-m-d H:i:s' );
392+
$value = $value->isOnlyDate() ?
393+
$value->format( 'Y-m-d' )
394+
:
395+
$value->format( 'Y-m-d H:i:s' );
393396
}
394397

395398
if(

library/Jet/DataModel/Backend/PgSQL.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,10 @@ protected function _getValue( mixed $value ): float|int|string
388388
}
389389

390390
if( $value instanceof Data_DateTime ) {
391-
$value = $value->format( 'Y-m-d H:i:s' );
391+
$value = $value->isOnlyDate() ?
392+
$value->format( 'Y-m-d' )
393+
:
394+
$value->format( 'Y-m-d H:i:s' );
392395
}
393396

394397
if(
@@ -548,7 +551,6 @@ protected function _getRecord( DataModel_RecordData $record, bool $quote = true,
548551
*/
549552
public function transactionStart(): void
550553
{
551-
//TODO:
552554
/*
553555
$this->getDbWrite()->beginTransaction();
554556
*/
@@ -560,7 +562,6 @@ public function transactionStart(): void
560562
*/
561563
public function transactionRollback(): void
562564
{
563-
//TODO:
564565
/*
565566
if( $this->getDbWrite()->inTransaction() ) {
566567
$this->getDbWrite()->rollBack();
@@ -573,7 +574,6 @@ public function transactionRollback(): void
573574
*/
574575
public function transactionCommit(): void
575576
{
576-
//TODO:
577577
/*
578578
if( $this->getDbWrite()->inTransaction() ) {
579579
$this->getDbWrite()->commit();

library/Jet/DataModel/Backend/SQLite.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,10 @@ protected function _getValue( mixed $value ): float|int|string
490490
}
491491

492492
if( $value instanceof Data_DateTime ) {
493-
$value = $value->format( 'Y-m-d H:i:s' );
493+
$value = $value->isOnlyDate() ?
494+
$value->format( 'Y-m-d' )
495+
:
496+
$value->format( 'Y-m-d H:i:s' );
494497
}
495498

496499
if( is_array( $value ) ) {

0 commit comments

Comments
 (0)