From c4baca6b603891a3db4eb6b67afb1853a4b94fab Mon Sep 17 00:00:00 2001 From: Jacob Quinn Date: Thu, 19 Nov 2026 03:18:55 -0700 Subject: [PATCH 1/3] Test that MySQL.load keeps a Time column's fractional seconds Co-Authored-By: Claude Opus 5.5 --- test/protocol/native_tests.jl | 1 + test/user_workflow.jl | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/test/protocol/native_tests.jl b/test/protocol/native_tests.jl index 971220c4..544d895a 100644 --- a/test/protocol/native_tests.jl +++ b/test/protocol/native_tests.jl @@ -5,6 +5,7 @@ struct LocalInfileFunctor end @test N.sqltype(Missing) == "VARCHAR(255)" @test N.sqltype(Any) == "VARCHAR(255)" @test N.sqltype(Union{Missing, Int64}) == "BIGINT" + @test N.sqltype(Dates.Time) == "TIME(6)" # TIME(0) would round the fractional seconds @test isempty(Test.detect_unbound_args(MySQL)) end diff --git a/test/user_workflow.jl b/test/user_workflow.jl index 112af38d..68599fb1 100644 --- a/test/user_workflow.jl +++ b/test/user_workflow.jl @@ -65,6 +65,11 @@ function run_user_workflow(conn) DBInterface.execute(conn, "DROP TABLE IF EXISTS old_dates_load") MySQL.load((id=[1], born=[DateTime(1955, 3, 4)]), conn, "old_dates_load") @test isequal(Tables.columntable(DBInterface.execute(conn, "SELECT born FROM old_dates_load")).born, [Timestamp{Millisecond}(DateTime(1955, 3, 4))]) + # Fractional seconds of a Time column survive MySQL.load (a TIME(0) column rounds them). + DBInterface.execute(conn, "DROP TABLE IF EXISTS times_load") + times = [Time(12, 0, 0, 500), Time(23, 59, 59, 999, 999), Time(0, 0, 0, 0, 1)] + MySQL.load((id=[1, 2, 3], at=times), conn, "times_load") + @test Tables.columntable(DBInterface.execute(conn, "SELECT at FROM times_load ORDER BY id")).at == times @test DBInterface.transaction(conn) do DBInterface.execute(conn, "UPDATE items SET label='changed' WHERE id=1") :committed From 098be2646713e35960ee9c70bd7b0c92bc2c4334 Mon Sep 17 00:00:00 2001 From: Jacob Quinn Date: Thu, 19 Nov 2026 03:22:18 -0700 Subject: [PATCH 2/3] Create TIME(6) columns for Time in MySQL.load A TIME column has no fractional seconds, so the server rounded every loaded Time to the second (MariaDB truncates), and on MySQL a value from 23:59:59.5 up became 24:00:00, which no longer reads back as a Time. DateTime already maps to DATETIME(3) for the same reason. Co-Authored-By: Claude Opus 5.5 --- docs/src/migration.md | 3 ++- src/load.jl | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/src/migration.md b/docs/src/migration.md index 0cfaeea5..0b9afa5e 100644 --- a/docs/src/migration.md +++ b/docs/src/migration.md @@ -92,7 +92,8 @@ row types `MySQL.TextRow` and `MySQL.BinaryRow` (1.x: `MySQL.TextRow` and `MySQL generated statements only, `debug=:values` also logs row values (1.x `debug=true` logged values). A `DateTime` column is created as `DATETIME(3)` (1.x: `DATETIME`, which dropped the milliseconds); `Timestamp{Second}`/`{Millisecond}`/`{Microsecond}` - columns become `DATETIME`/`DATETIME(3)`/`DATETIME(6)`. + columns become `DATETIME`/`DATETIME(3)`/`DATETIME(6)`. A `Time` column is created as + `TIME(6)` (1.x: `TIME`, which rounded away the fractional seconds). ## Unchanged (Preserve) diff --git a/src/load.jl b/src/load.jl index 2f8e76d1..4d8f98c0 100644 --- a/src/load.jl +++ b/src/load.jl @@ -31,7 +31,7 @@ const SQLTYPES = Dict{Type, String}( String => "VARCHAR(255)", DataString => "VARCHAR(255)", Date => "DATE", - Time => "TIME", + Time => "TIME(6)", DateTime => "DATETIME(3)", Timestamp{Second} => "DATETIME", Timestamp{Millisecond} => "DATETIME(3)", From 7a459eceda806e872c7872e409285aa84d6e2503 Mon Sep 17 00:00:00 2001 From: Jacob Quinn Date: Thu, 19 Nov 2026 03:29:05 -0700 Subject: [PATCH 3/3] Qualify Dates in the serverless sqltype test The coverage job includes test/protocol/runtests.jl on its own, where Dates is not imported. Co-Authored-By: Claude Opus 5.5 --- test/protocol/native_tests.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/protocol/native_tests.jl b/test/protocol/native_tests.jl index 544d895a..90fdde73 100644 --- a/test/protocol/native_tests.jl +++ b/test/protocol/native_tests.jl @@ -5,7 +5,7 @@ struct LocalInfileFunctor end @test N.sqltype(Missing) == "VARCHAR(255)" @test N.sqltype(Any) == "VARCHAR(255)" @test N.sqltype(Union{Missing, Int64}) == "BIGINT" - @test N.sqltype(Dates.Time) == "TIME(6)" # TIME(0) would round the fractional seconds + @test N.sqltype(MySQL.Dates.Time) == "TIME(6)" # TIME(0) would round the fractional seconds @test isempty(Test.detect_unbound_args(MySQL)) end