From 6c94f0c220a3a5b6cf50631f3fd53987afe60f55 Mon Sep 17 00:00:00 2001 From: "Brian J. Cardiff" Date: Wed, 7 Dec 2016 14:47:33 -0300 Subject: [PATCH] fix exec with non DB::Any args mixed with DB::Any --- spec/driver_spec.cr | 9 +++++++++ src/mysql/types.cr | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/spec/driver_spec.cr b/spec/driver_spec.cr index 24164b7..3da9998 100644 --- a/spec/driver_spec.cr +++ b/spec/driver_spec.cr @@ -216,6 +216,15 @@ describe Driver do db.scalar("select col1 from table1").should eq({{value}}) end end + + it "insert/get value {{value.id}} from table with binding" do + with_test_db do |db| + db.exec "create table table1 (col0 varchar(25), col1 #{mysql_type_for({{value}})})" + # the next statement will force a union in the *args + db.exec %(insert into table1 (col0, col1) values (?, ?)), "", {{value}} + db.scalar("select col1 from table1").should eq({{value}}) + end + end {% end %} # zero dates http://dev.mysql.com/doc/refman/5.7/en/datetime.html - work on some mysql not others, diff --git a/src/mysql/types.cr b/src/mysql/types.cr index 3f316b6..2bb22d6 100644 --- a/src/mysql/types.cr +++ b/src/mysql/types.cr @@ -66,7 +66,7 @@ abstract struct MySql::Type # Writes in packet the value in ProtocolBinary format. # Used when sending query params. - def self.write(packet, v : DB::Any) + def self.write(packet, v) raise "not supported write" end