will / crystal-pg

a postgres driver for crystal
BSD 3-Clause "New" or "Revised" License
463 stars 78 forks source link

Undefined method 'empty' when exec is called without params #73

Closed ray-delossantos closed 7 years ago

ray-delossantos commented 7 years ago

Hello:

I'm receiving this error:

undefined method 'empty' for Slice(Bool | Float32 | Float64 | Int32 | Int64 | Slice(UInt8) | String | Time | Nil):Class
      perform_exec_and_release(Slice(Any).empty)

Code:

DB.open("postgres:///") do |db| 
  db.exec("DROP SCHEMA IF EXISTS test CASCADE;")
end

Workaround:

module DB
  abstract class Statement
    # See `QueryMethods#exec`
    def exec
      perform_exec_and_release([] of DB::Any)
    end
  end
end

I really don't know if is related to crystal-pg or also affect all crystal-db drivers.

CC: @bcardiff.

will commented 7 years ago

Are you on Crystal >= 2.20.1? Slice#empty was added then https://github.com/crystal-lang/crystal/blob/master/CHANGELOG.md#0201-05-12-2016

bcardiff commented 7 years ago

Slice.empty was added in crystal 0.20.1 it's probably an outdated crystal version this issue.

ray-delossantos commented 7 years ago

That's correct. There's an outdated brew formula (current: 0.20.0) http://brewformulas.org/CrystalLang. I'll compile crystal from the master repo.

ray-delossantos commented 7 years ago

Thanks :).