# BUG: trying to downcast DB::ResultSet+ \<- SQLite3::ResultSet (Exception) #9594

**URL:** <https://forum.crystal-lang.org/t/bug-trying-to-downcast-db-resultset-sqlite3-resultset-exception-9594/2315>\
**Category:** Help & Support\
**Created:** [July 10, 2020, 6:50am UTC](https://forum.crystal-lang.org/t/bug-trying-to-downcast-db-resultset-sqlite3-resultset-exception-9594/2315 "2020-07-10T06:50:17Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Geo-7](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/geo-7/32/816_2.png) [@Geo-7](https://forum.crystal-lang.org/u/Geo-7)\
**Post date:** [July 10, 2020, 6:50am UTC](https://forum.crystal-lang.org/t/bug-trying-to-downcast-db-resultset-sqlite3-resultset-exception-9594/2315/1 "2020-07-10T06:50:17Z")

</div>

crystal -v  
Crystal 0.35.1 [[5999ae2](https://github.com/crystal-lang/crystal/commit/5999ae29beacf4cfd54e232ca83c1a46b79f26a5)] (2020-06-19)

LLVM: 8.0.0  
Default target: x86\_64-unknown-linux-gnu

```
require "sqlite3"
require "db"

db =DB.open("sqlite3://luckdb")
db.query_all("SELECT * FROM movie") do |rs|
    rs.each do
        rs.column_names.each do
            ...
        end
    end
end

```

**OUTPUT:**

> BUG: trying to downcast DB::ResultSet+ ← SQLite3::ResultSet (Exception)  
> from …/…/…/…/…/crystal/src/compiler/crystal/codegen/cast.cr:541:5 in ‘downcast\_distinct’  
> from …/…/…/…/…/crystal/src/indexable.cr:73:26 in ‘downcast’  
> from …/…/…/…/…/crystal/src/compiler/crystal/codegen/codegen.cr:1156:17 in ‘visit’  
> from …/…/…/…/…/crystal/src/compiler/crystal/syntax/visitor.cr:27:12 in ‘accept’  
> from …/…/…/…/…/crystal/src/compiler/crystal/codegen/codegen.cr:2193:7 in ‘prepare\_call\_args\_non\_external’  
> from …/…/…/…/…/crystal/src/compiler/crystal/codegen/call.cr:57:7 in ‘visit’  
> from …/…/…/…/…/crystal/src/compiler/crystal/syntax/visitor.cr:27:12 in ‘accept’  
> from …/…/…/…/…/crystal/src/compiler/crystal/codegen/codegen.cr:2193:7 in ‘prepare\_call\_args\_non\_external’  
> from …/…/…/…/…/crystal/src/compiler/crystal/codegen/call.cr:57:7 in ‘visit’  
> from …/…/…/…/…/crystal/src/compiler/crystal/syntax/visitor.cr:27:12 in ‘accept’  
> from …/…/…/…/…/crystal/src/compiler/crystal/codegen/codegen.cr:74:5 in ‘accept’  
> from …/…/…/…/…/crystal/src/compiler/crystal/codegen/codegen.cr:2188:9 in ‘accept’  
> from …/…/…/…/…/crystal/src/compiler/crystal/codegen/codegen.cr:2193:7 in ‘visit’  
> from …/…/…/…/…/crystal/src/compiler/crystal/syntax/visitor.cr:27:12 in ‘accept’  
> from …/…/…/…/…/crystal/src/compiler/crystal/codegen/codegen.cr:74:5 in ‘accept’  
> from …/…/…/…/…/crystal/src/compiler/crystal/semantic/bindings.cr:17:7 in ‘prepare\_call\_args\_non\_external’  
> from …/…/…/…/…/crystal/src/compiler/crystal/codegen/call.cr:57:7 in ‘visit’  
> from …/…/…/…/…/crystal/src/compiler/crystal/syntax/visitor.cr:27:12 in ‘accept’  
> from …/…/…/…/…/crystal/src/compiler/crystal/codegen/codegen.cr:74:5 in ‘accept’  
> from …/…/…/…/…/crystal/src/compiler/crystal/codegen/codegen.cr:74:5 in ‘accept’  
> from …/…/…/…/…/crystal/src/compiler/crystal/codegen/codegen.cr:2188:9 in ‘accept’  
> from …/…/…/…/…/crystal/src/compiler/crystal/codegen/codegen.cr:2193:7 in ‘visit’  
> from …/…/…/…/…/crystal/src/compiler/crystal/syntax/visitor.cr:27:12 in ‘accept’  
> from …/…/…/…/…/crystal/src/compiler/crystal/codegen/codegen.cr:74:5 in ‘accept’  
> from …/…/…/…/…/crystal/src/compiler/crystal/codegen/exception.cr:92:7 in ‘accept’  
> from …/…/…/…/…/crystal/src/compiler/crystal/codegen/codegen.cr:628:9 in ‘accept’  
> from …/…/…/…/…/crystal/src/compiler/crystal/codegen/codegen.cr:2193:7 in ‘visit’  
> from …/…/…/…/…/crystal/src/compiler/crystal/syntax/visitor.cr:27:12 in ‘accept’  
> from …/…/…/…/…/crystal/src/compiler/crystal/codegen/codegen.cr:628:9 in ‘accept’  
> from …/…/…/…/…/crystal/src/compiler/crystal/codegen/codegen.cr:2193:7 in ‘visit’  
> from …/…/…/…/…/crystal/src/compiler/crystal/syntax/visitor.cr:27:12 in ‘accept’  
> from …/…/…/…/…/crystal/src/compiler/crystal/codegen/codegen.cr:628:9 in ‘accept’  
> from …/…/…/…/…/crystal/src/compiler/crystal/codegen/codegen.cr:2193:7 in ‘visit’  
> from …/…/…/…/…/crystal/src/compiler/crystal/syntax/visitor.cr:27:12 in ‘accept’  
> from …/…/…/…/…/crystal/src/compiler/crystal/codegen/codegen.cr:628:9 in ‘accept’  
> from …/…/…/…/…/crystal/src/compiler/crystal/codegen/codegen.cr:2158:7 in ‘codegen’  
> from …/…/…/…/…/crystal/src/compiler/crystal/compiler.cr:172:16 in ‘compile’  
> from …/…/…/…/…/crystal/src/compiler/crystal/command.cr:295:3 in ‘run’  
> from …/…/…/…/…/crystal/src/compiler/crystal.cr:11:1 in ‘\_\_crystal\_main’  
> from …/…/…/…/…/crystal/src/crystal/main.cr:105:5 in ‘main’  
> from src/env/\_\_libc\_start\_main.c:94:2 in ‘libc\_start\_main\_stage2’  
> Error: you’ve found a bug in the Crystal compiler. Please open an issue, including source code that will allow us to reproduce the bug: [Issues · crystal-lang/crystal · GitHub](https://github.com/crystal-lang/crystal/issues)  
> The terminal process terminated with exit code: 1
> 
> Terminal will be reused by tasks, press any key to close it.

I know that my code is not useful but it will produce a bug 🙂
