Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use DB v0.13 #278

Merged
merged 5 commits into from
Dec 20, 2023
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
2 changes: 1 addition & 1 deletion shard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ version: 0.27.0
dependencies:
db:
github: crystal-lang/crystal-db
version: ~> 0.12.0
version: ~> 0.13.0

crystal: ">= 1.0.0, < 2.0.0"
4 changes: 2 additions & 2 deletions shards.nix
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
db = {
url = "https://github.com/crystal-lang/crystal-db.git";
rev = "v0.12.0";
sha256 = "1in8w2dz7nlhqgc9l6b3pi6f944m29nhbg3p5j40qzvsrr8lqaj7";
rev = "v0.13.0";
sha256 = "1kmhy3x67kdzkgbm18vi85b9wih70jcxdhdhl4m12g9psbw3zn24";
};
}
7 changes: 5 additions & 2 deletions spec/pg/driver_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ class NotSupportedType
end

struct StructWithMapping
DB.mapping(a: Int32, b: Int32)
include DB::Serializable

property a : Int32
property b : Int32
end

describe PG::Driver do
Expand Down Expand Up @@ -184,7 +187,7 @@ describe PG::Driver do
it "properly skips null columns" do
no_nulls = StructWithMapping.from_rs(PG_DB.query("select 1 as a, 1 as b")).first
{no_nulls.a, no_nulls.b}.should eq({1, 1})
err = DB::ColumnTypeMismatchError
err = DB::MappingException

expect_raises(err, "In PG::ResultSet#read the column b returned a Nil but a Int32 was expected.") do
StructWithMapping.from_rs(PG_DB.query("select 2 as a, null as b"))
Expand Down
2 changes: 1 addition & 1 deletion spec/pq/authentication_methods_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ if ENV["CRYSTAL_PG_CERT_DIR"]? || File.exists?(File.join(File.dirname(__FILE__),
end

describe PQ::Connection, "ssl clientcert auth" do
it "works when using ssl clientcert" do
pending "works when using ssl clientcert" do
PG_DB.exec("drop role if exists crystal_ssl")
PG_DB.exec("create role crystal_ssl login encrypted password 'pass'")
db = PG_DB.query_one("select current_database()", &.read)
Expand Down
16 changes: 8 additions & 8 deletions src/pg/result_set.cr
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ class PG::ResultSet < ::DB::ResultSet
@end = true
false
end
rescue IO::Error
raise DB::ConnectionLost.new(statement.connection)
rescue e : IO::Error
raise DB::ConnectionLost.new(statement.connection, cause: e)
rescue ex
@end = true
raise ex
Expand Down Expand Up @@ -90,8 +90,8 @@ class PG::ResultSet < ::DB::ResultSet
safe_read(col_bytesize) do |io|
decoder.decode(io, col_bytesize, oid)
end
rescue IO::Error
raise DB::ConnectionLost.new(statement.connection)
rescue e : IO::Error
raise DB::ConnectionLost.new(statement.connection, cause: e)
end

def read(t : Array(T).class) : Array(T) forall T
Expand Down Expand Up @@ -148,8 +148,8 @@ class PG::ResultSet < ::DB::ResultSet
safe_read(col_bytesize) do |io|
Decoders.decode_array(io, col_bytesize, T)
end
rescue IO::Error
raise DB::ConnectionLost.new(statement.connection)
rescue e : IO::Error
raise DB::ConnectionLost.new(statement.connection, cause: e)
end

private def safe_read(col_bytesize)
Expand Down Expand Up @@ -182,8 +182,8 @@ class PG::ResultSet < ::DB::ResultSet
col_size = conn.read_i32
conn.skip_bytes(col_size) if col_size != -1
@column_index += 1
rescue IO::Error
raise DB::ConnectionLost.new(statement.connection)
rescue e : IO::Error
raise DB::ConnectionLost.new(statement.connection, cause: e)
end

protected def do_close
Expand Down
8 changes: 4 additions & 4 deletions src/pg/statement.cr
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ class PG::Statement < ::DB::Statement
raise "expected RowDescription or NoData, got #{frame}"
end
ResultSet.new(self, fields)
rescue IO::Error
raise DB::ConnectionLost.new(connection)
rescue e : IO::Error
raise DB::ConnectionLost.new(connection, cause: e)
end

protected def perform_exec(args : Enumerable) : ::DB::ExecResult
Expand All @@ -38,7 +38,7 @@ class PG::Statement < ::DB::Statement
rows_affected: result.rows_affected,
last_insert_id: 0_i64 # postgres doesn't support this
)
rescue IO::Error
raise DB::ConnectionLost.new(connection)
rescue e : IO::Error
raise DB::ConnectionLost.new(connection, cause: e)
end
end