Skip to content

Commit eaa4027

Browse files
committed
Statement spec with comparison and like operators
1 parent f961df8 commit eaa4027

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

spec/mysql2/statement_spec.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,20 @@
8383
result = statement.execute
8484
expect(result.to_a.length).to eq(1)
8585
end
86+
87+
it "should handle comparisons and likes" do
88+
@client.query 'USE test'
89+
@client.query 'CREATE TABLE IF NOT EXISTS mysql2_stmt_q(a int, b varchar(10))'
90+
@client.query 'INSERT INTO mysql2_stmt_q (a, b) VALUES (1, "Hello"), (2, "World")'
91+
statement = @client.prepare 'SELECT * FROM mysql2_stmt_q WHERE a < ?'
92+
results = statement.execute(2)
93+
results.first.should == {"a" => 1, "b" => "Hello"}
94+
95+
statement = @client.prepare 'SELECT * FROM mysql2_stmt_q WHERE b LIKE ?'
96+
results = statement.execute('%orld')
97+
results.first.should == {"a" => 2, "b" => "World"}
98+
99+
@client.query 'DROP TABLE IF EXISTS mysql2_stmt_q'
86100
end
87101

88102
it "should select dates" do

0 commit comments

Comments
 (0)