fisharebest / webtrees

Online genealogy
https://webtrees.net
GNU General Public License v3.0
454 stars 298 forks source link

2.2 Dev sqlsrv: date/time "2022-12-24 17:06:37.327" does not match pattern "Y-m-d H:i:s" #4682

Open FrankWarius opened 1 year ago

FrankWarius commented 1 year ago

date/time "2022-12-24 17:06:37.327" does not match pattern "Y-m-d H:i:s" …\app\Factories\TimestampFactory.php:68

0 …\app\Statistics\Repository\GedcomRepository.php(169): Fisharebest\Webtrees\Factories\TimestampFactory->fromString('2022-12-24 17:0...')

1 …\app\Statistics.php(273): Fisharebest\Webtrees\Statistics\Repository\GedcomRepository->gedcomUpdated()

2 …\app\Statistics.php(2845): Fisharebest\Webtrees\Statistics->gedcomUpdated()

3 …\app\Statistics.php(214): Fisharebest\Webtrees\Statistics->getTags('\r\n <p class=...')

4 …\app\Module\FamilyTreeStatisticsModule.php(189): Fisharebest\Webtrees\Statistics->embedTags('\r\n <p class=...')

5 …\app\Http\RequestHandlers\TreePageBlock.php(66): Fisharebest\Webtrees\Module\FamilyTreeStatisticsModule->getBlock(Object(Fisharebest\Webtrees\Tree), 23, 'tree')

doesn't work either with "Y-M-d H:m:s"

FrankWarius commented 1 year ago

public function fromString(?string $string, string $format = 'Y-m-d H:i:s.v', UserInterface $user = null): TimestampInterface works for sqlsrv

fisharebest commented 8 months ago

The database migrations create timestamp columns with a default precision of 0.

So, I would expect the column wt_change.change_time to contain integer seconds.

But your table contains milliseconds.

Question - did you do anything to change this column, or was it created by the migration?

FrankWarius commented 8 months ago

it is a blank out of the (2.2 dev) box installation. After that I exported my 2.1 Gedcom and imported it to 2.2 and did one source change (successful).

FrankWarius commented 8 months ago

it is already logged by the SetupWizzard if the database is MS SQL.

log_id log_time log_type log_message ip_address user_id gedcom_id 1 2024-01-01 12:08:05.553 config Site preference "WT_SCHEMA_VERSION" set to "1" ::1 NULL NULL 2 2024-01-01 12:08:05.563 config Site preference "WT_SCHEMA_VERSION" set to "2" ::1 NULL NULL 3 2024-01-01 12:08:05.573 config Site preference "WT_SCHEMA_VERSION" set to "3" ::1 NULL NULL ... 78 2024-01-01 18:34:39.127 edit Update: INDI I1811 ::1 1 1

changing $format to 'Y-m-d H:i:s.v' in booth TimeStampFactory and TimeStampFactoryInterface fixes the error

FrankWarius commented 8 months ago

The database migrations create timestamp columns with a default precision of 0. Question - did you do anything to change this column, or was it created by the migration?

No,

type is datetime decimals are set to 3 by migration.

TSQL datetime always have 3 decimals see https://learn.microsoft.com/en-us/sql/t-sql/data-types/datetime-transact-sql?view=sql-server-ver16

image