|
59 | 59 | expect(rows).to eq([{ "1" => 1 }]) |
60 | 60 | end |
61 | 61 |
|
| 62 | + it "should keep query options per prepared statement" do |
| 63 | + stmt1 = @client.prepare 'SELECT 1 AS a', :as => :hash |
| 64 | + stmt2 = @client.prepare 'SELECT 1 AS a', :as => :array |
| 65 | + |
| 66 | + expect(stmt1.execute.first).to eq("a" => 1) |
| 67 | + expect(stmt2.execute.first).to eq([1]) |
| 68 | + |
| 69 | + expect(stmt1.query_options).to include(:as => :hash) |
| 70 | + expect(stmt2.query_options).to include(:as => :array) |
| 71 | + end |
| 72 | + |
| 73 | + it "should capture query options when preparing the statement" do |
| 74 | + @client.query_options.merge!(:as => :hash) |
| 75 | + stmt1 = @client.prepare 'SELECT 1 AS a' |
| 76 | + |
| 77 | + @client.query_options.merge!(:as => :array) |
| 78 | + stmt2 = @client.prepare 'SELECT 1 AS a' |
| 79 | + |
| 80 | + expect(stmt1.execute.first).to eq("a" => 1) |
| 81 | + expect(stmt2.execute.first).to eq([1]) |
| 82 | + |
| 83 | + expect(stmt1.query_options).to include(:as => :hash) |
| 84 | + expect(stmt2.query_options).to include(:as => :array) |
| 85 | + end |
| 86 | + |
62 | 87 | it "should keep its result after other query" do |
63 | 88 | @client.query 'USE test' |
64 | 89 | @client.query 'CREATE TABLE IF NOT EXISTS mysql2_stmt_q(a int)' |
|
180 | 205 | # note: The current impl. of prepared statement requires results to be cached on #execute except for streaming queries |
181 | 206 | # The drawback of this is that args of Result#each is ignored... |
182 | 207 |
|
183 | | - it "should yield rows as hash's" do |
| 208 | + it "should yield rows as hashes" do |
184 | 209 | result = @client.prepare("SELECT 1").execute |
185 | 210 | result.each do |row| |
186 | 211 | expect(row).to be_an_instance_of(Hash) |
187 | 212 | end |
188 | 213 | end |
189 | 214 |
|
190 | | - it "should yield rows as hash's with symbol keys if :symbolize_keys was set to true" do |
| 215 | + it "should yield rows as hashes with symbol keys if :symbolize_keys was set to true" do |
191 | 216 | result = @client.prepare("SELECT 1", :symbolize_keys => true).execute |
192 | 217 | result.each do |row| |
193 | 218 | expect(row.keys.first).to be_an_instance_of(Symbol) |
|
0 commit comments