Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion docs/src/migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion src/load.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)",
Expand Down
1 change: 1 addition & 0 deletions test/protocol/native_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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(MySQL.Dates.Time) == "TIME(6)" # TIME(0) would round the fractional seconds
@test isempty(Test.detect_unbound_args(MySQL))
end

Expand Down
5 changes: 5 additions & 0 deletions test/user_workflow.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading