mysql-nio icon indicating copy to clipboard operation
mysql-nio copied to clipboard

Exception when reading MySQLTime formatted as text

Open samalone opened this issue 3 years ago • 0 comments

Describe the bug

The getter for MySQLData.time assumes the data is in .binary format. However, MariaDB 10.5 returns data from timestamp fields in .text format "2008-12-29 12:59:59", which leads to a fatal error unwrapping nil.

To Reproduce

  1. Run a Docker container with mariadb:10.5 and these command-line arguments:
    • --max-allowed-packet=512M
    • --sql-mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
    • --default-time-zone=America/New_York
  2. Query the MariaDB server with:
let rows = try db.simpleQuery("SELECT CURRENT_TIMESTAMP();").wait()
print(rows)

Expected behavior

The current timestamp should be returned. Instead, there is a fatal error at MySQLData.swift:458.

Environment

framework: 4.55.0 toolbox: 18.3.3 OS version: macOS 12.2.1

Additional context

I think the fix is straightforward, and I hope to have a pull request to fix the problem soon.

samalone avatar Feb 20 '22 10:02 samalone