The Crystal Programming Language Forum

Postgresql DB.open does not work in crystal V-0.35

Hi
After upgrading crystal to version v.35:
db = DB.open "postgres://username:password@192.168.1.1/mydb"
in my main application I got this error:

In /usr/share/crystal/src/io.cr:845:34

 845 | def write_byte(byte : UInt8) : Int64
                                      ^
Error: method must return Int64 but it is returning (Int64 | Nil)

after create a simple new file with only db.open

In lib/pg/src/pq/connection.cr:362:13

 362 | ctx.update(inner.to_unsafe, inner.bytesize.to_u32)
           ^-----
Error: wrong number of arguments for 'OpenSSL::Digest#update' (given 2, expected 1)

I am using will/crystal-pg

Update to https://github.com/will/crystal-pg/releases/tag/v0.21.1 that release.

Thanks but why shards install install the older version?

name: pg
version: 0.21.0

dependencies:
  db:
    github: crystal-lang/crystal-db
    version: ~> 0.9.0

Because it’s probably respecting your shard.lock file. You need to run shards update, after changing the version in your shard.yml.

1 Like

Thanks, your guess was right.