Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception when reading MySQLTime formatted as text #71

Closed
samalone opened this issue Feb 20, 2022 · 0 comments · Fixed by #72
Closed

Exception when reading MySQLTime formatted as text #71

samalone opened this issue Feb 20, 2022 · 0 comments · Fixed by #72
Labels
bug Something isn't working

Comments

@samalone
Copy link
Contributor

samalone commented Feb 20, 2022

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 samalone added the bug Something isn't working label Feb 20, 2022
samalone added a commit to samalone/mysql-nio that referenced this issue Feb 20, 2022
@gwynne gwynne closed this as completed in #72 May 9, 2023
gwynne pushed a commit that referenced this issue May 9, 2023
* Parse timestamp columns in text format. Fixes #71
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant