Skip to content

DateTime wrong binding/extraction for MySQL database #1897

@Erbengi

Description

@Erbengi

DateTime is not bind/extract correctly from MySQL database. Milisecond and microseconds are corrupted.

Binding

Miliseconds are bind by this code:

mt.second_part = val.millisecond();

But MYSQL_TIME::second_part contains both milisecond and microsecond as one number. So the previous code makes microseconds from miliseconds. For example 0.333555 seconds (333 miliseconds and 555 microseconds) is bind as mt.second_part = 333 (it means 333 microseconds), but it should be bind as mt.second_part = 333555.

Extraction

Extraction is done by code:

val.assign(mt.year, mt.month, mt.day, mt.hour, mt.minute, mt.second, mt.second_part, 0);

Assigment mt.second_part to DateTime causes assertion violation, because miliseconds in DateTime must be smaller or equal 999. But mt.second_part may contains much bigger values.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions