Skip to content
Merged
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
9 changes: 3 additions & 6 deletions src/tables.jl
Original file line number Diff line number Diff line change
Expand Up @@ -350,18 +350,15 @@ function checkdupnames(names::Union{AbstractVector,Tuple})
return true
end

# check if schema names match column names in DB
# check if schema names match column names in DB; SQLite compares column names ignoring case
function checknames(
::Tables.Schema{names},
db_names::AbstractVector{String},
) where {names}
table_names = Set(string.(names))
db_names = Set(db_names)

if table_names != db_names
if Set(lowercase.(string.(names))) != Set(lowercase.(db_names))
throw(
SQLiteException(
"Error loading, column names from table $(collect(table_names)) do not match database names $(collect(db_names))",
"Error loading, column names from table $(collect(string.(names))) do not match database names $(db_names)",
),
)
end
Expand Down
10 changes: 10 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -992,6 +992,16 @@ end
close(db)
end

@testset "load! matches existing column names ignoring case" begin
db = SQLite.DB()
DBInterface.execute(db, "CREATE TABLE people (id INTEGER, name TEXT)")
SQLite.load!((NAME = ["ann"], Id = [1]), db, "people")
@test columntable(DBInterface.execute(db, "SELECT id, name FROM people")) ==
(id = [1], name = ["ann"])
@test_throws SQLiteException SQLite.load!((nam = ["bob"], id = [2]), db, "people")
close(db)
end

@testset "ANALYZE quotes table and index names" begin
db = SQLite.DB()
@test SQLite.load!((a = [1, 1, 2],), db, "my table"; analyze = true) == "my table"
Expand Down
Loading