|
78 | 78 | DBInterface.close!(con)
|
79 | 79 | end
|
80 | 80 |
|
| 81 | + @testset "SQLite.tables(db)" begin |
| 82 | + setup_clean_test_db() do db |
| 83 | + |
| 84 | + results1 = SQLite.tables(db) |
| 85 | + |
| 86 | + @test isa(results1, SQLite.DBTables) |
| 87 | + @test length(results1) == 11 |
| 88 | + @test isa(results1[1], SQLite.DBTable) |
| 89 | + |
| 90 | + @test Tables.istable(results1) |
| 91 | + @test Tables.rowaccess(results1) |
| 92 | + @test Tables.rows(results1) == results1 |
| 93 | + |
| 94 | + @test results1[1].name == "Album" |
| 95 | + @test results1[1].schema == Tables.schema(DBInterface.execute(db,"SELECT * FROM Album LIMIT 0")) |
| 96 | + |
| 97 | + @test SQLite.DBTable("Album") == SQLite.DBTable("Album", nothing) |
| 98 | + |
| 99 | + @test [t.name for t in results1] == ["Album", "Artist", "Customer", "Employee", "Genre", "Invoice", "InvoiceLine", "MediaType", "Playlist", "PlaylistTrack", "Track"] |
| 100 | + end |
| 101 | + |
| 102 | + @testset "#209: SQLite.tables response when no tables in DB" begin |
| 103 | + db = SQLite.DB() |
| 104 | + tables_v = SQLite.tables(db) |
| 105 | + @test String[] == [t.name for t in tables_v] |
| 106 | + DBInterface.close!(db) |
| 107 | + end |
| 108 | + end |
| 109 | + |
81 | 110 | @testset "Issue #207: 32 bit integers" begin
|
82 | 111 | setup_clean_test_db() do db
|
83 | 112 | ds =
|
|
117 | 146 | @test length(ds.name) == 11
|
118 | 147 |
|
119 | 148 | results1 = SQLite.tables(db)
|
120 |
| - @test isequal(ds, results1) |
| 149 | + @test isequal(ds.name, [t.name for t in results1]) |
121 | 150 | end
|
122 | 151 | end
|
123 | 152 |
|
|
223 | 252 |
|
224 | 253 | r = DBInterface.execute(db, "select * from temp limit 10") |> columntable
|
225 | 254 | @test length(r) == 4 && length(r[1]) == 10
|
226 |
| - @test typeof(r[4][1]) == Date |
| 255 | + @test isa(r[4][1], Date) |
227 | 256 | @test all(Bool[x == Date(2014, 1, 1) for x in r[4]])
|
228 | 257 | DBInterface.execute(db, "drop table temp")
|
229 | 258 |
|
|
233 | 262 | r = DBInterface.execute(db, "select * from $tablename") |> columntable
|
234 | 263 | @test length(r) == 2 && length(r[1]) == 5
|
235 | 264 | @test all([i for i in r[1]] .== collect(rng))
|
236 |
| - @test all([typeof(i) for i in r[1]] .== Dates.Date) |
| 265 | + @test all([isa(i, Dates.Date) for i in r[1]]) |
237 | 266 | SQLite.drop!(db, "$tablename")
|
238 | 267 | end
|
239 | 268 | end
|
@@ -411,11 +440,11 @@ end
|
411 | 440 | SQLite.drop!(db2, "nonexistant", ifexists = true)
|
412 | 441 | # should drop "tab2"
|
413 | 442 | SQLite.drop!(db2, "tab2", ifexists = true)
|
414 |
| - @test !in("tab2", SQLite.tables(db2)[1]) |
| 443 | + @test filter(x -> x.name == "tab2", SQLite.tables(db2)) |> length == 0 |
415 | 444 |
|
416 | 445 | SQLite.drop!(db, "sqlite_stat1", ifexists = true)
|
417 | 446 | tables = SQLite.tables(db)
|
418 |
| - @test length(tables[1]) == 11 |
| 447 | + @test length(tables) == 11 |
419 | 448 | end
|
420 | 449 | end
|
421 | 450 |
|
|
0 commit comments