do_mysql 0.9.11 → 0.9.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/LICENSE +1 -1
- data/Manifest.txt +15 -4
- data/Rakefile +7 -122
- data/ext/do_mysql_ext/do_mysql_ext.c +154 -99
- data/ext/do_mysql_ext/extconf.rb +1 -0
- data/lib/do_mysql.rb +5 -2
- data/lib/do_mysql/version.rb +1 -1
- data/spec/command_spec.rb +9 -0
- data/spec/connection_spec.rb +19 -0
- data/spec/encoding_spec.rb +8 -0
- data/spec/lib/rspec_immediate_feedback_formatter.rb +3 -0
- data/spec/reader_spec.rb +8 -0
- data/spec/result_spec.rb +9 -0
- data/spec/spec_helper.rb +38 -47
- data/spec/typecast/array_spec.rb +8 -0
- data/spec/typecast/bigdecimal_spec.rb +9 -0
- data/spec/typecast/boolean_spec.rb +9 -0
- data/spec/typecast/byte_array_spec.rb +8 -0
- data/spec/typecast/class_spec.rb +8 -0
- data/spec/typecast/date_spec.rb +9 -0
- data/spec/typecast/datetime_spec.rb +9 -0
- data/spec/typecast/float_spec.rb +9 -0
- data/spec/typecast/integer_spec.rb +8 -0
- data/spec/typecast/nil_spec.rb +10 -0
- data/spec/typecast/range_spec.rb +8 -0
- data/spec/typecast/string_spec.rb +8 -0
- data/spec/typecast/time_spec.rb +8 -0
- data/tasks/gem.rake +60 -0
- data/tasks/install.rake +15 -0
- data/tasks/native.rake +31 -0
- data/tasks/release.rake +75 -0
- data/tasks/retrieve.rake +67 -0
- data/tasks/spec.rake +18 -0
- metadata +72 -40
- data/.gitignore +0 -0
- data/buildfile +0 -27
- data/ext-java/src/main/java/DoMysqlExtService.java +0 -23
- data/ext-java/src/main/java/do_mysql/MySqlDriverDefinition.java +0 -22
- data/ext/.gitignore +0 -2
- data/spec/integration/do_mysql_spec.rb +0 -341
- data/spec/integration/logging_spec.rb +0 -52
- data/spec/integration/quoting_spec.rb +0 -45
- data/spec/spec.opts +0 -2
- data/spec/unit/transaction_spec.rb +0 -35
@@ -1,52 +0,0 @@
|
|
1
|
-
require 'pathname'
|
2
|
-
require Pathname(__FILE__).dirname.expand_path.parent + 'spec_helper'
|
3
|
-
|
4
|
-
describe DataObjects::Mysql::Command do
|
5
|
-
|
6
|
-
before(:each) do
|
7
|
-
@connection = DataObjects::Connection.new(DO_MYSQL_SPEC_URI)
|
8
|
-
end
|
9
|
-
|
10
|
-
after(:each) do
|
11
|
-
@connection.close
|
12
|
-
end
|
13
|
-
|
14
|
-
describe "Executing a Reader" do
|
15
|
-
|
16
|
-
it "should log reader queries when the level is Debug (0)" do
|
17
|
-
command = @connection.create_command("SELECT * FROM widgets WHERE name = ?")
|
18
|
-
@mock_logger = mock('MockLogger', :level => 0)
|
19
|
-
DataObjects::Mysql.should_receive(:logger).and_return(@mock_logger)
|
20
|
-
@mock_logger.should_receive(:debug).with(/\([\d.]+\) SELECT \* FROM widgets WHERE name = 'Scott'/)
|
21
|
-
|
22
|
-
command.execute_reader('Scott').close # Readers must be closed!
|
23
|
-
end
|
24
|
-
|
25
|
-
it "shouldn't log reader queries when the level isn't Debug (0)" do
|
26
|
-
command = @connection.create_command("SELECT * FROM widgets WHERE name = ?")
|
27
|
-
@mock_logger = mock('MockLogger', :level => 1)
|
28
|
-
DataObjects::Mysql.should_receive(:logger).and_return(@mock_logger)
|
29
|
-
@mock_logger.should_not_receive(:debug)
|
30
|
-
command.execute_reader('Scott').close # Readers must be closed!
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
describe "Executing a Non-Query" do
|
35
|
-
it "should log non-query statements when the level is Debug (0)" do
|
36
|
-
command = @connection.create_command("INSERT INTO invoices (invoice_number) VALUES (?)")
|
37
|
-
@mock_logger = mock('MockLogger', :level => 0)
|
38
|
-
DataObjects::Mysql.should_receive(:logger).and_return(@mock_logger)
|
39
|
-
@mock_logger.should_receive(:debug).with(/\([\d.]+\) INSERT INTO invoices \(invoice_number\) VALUES \(1234\)/)
|
40
|
-
command.execute_non_query(1234)
|
41
|
-
end
|
42
|
-
|
43
|
-
it "shouldn't log non-query statements when the level isn't Debug (0)" do
|
44
|
-
command = @connection.create_command("INSERT INTO invoices (invoice_number) VALUES (?)")
|
45
|
-
@mock_logger = mock('MockLogger', :level => 1)
|
46
|
-
DataObjects::Mysql.should_receive(:logger).and_return(@mock_logger)
|
47
|
-
@mock_logger.should_not_receive(:debug)
|
48
|
-
command.execute_non_query(1234)
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
end
|
@@ -1,45 +0,0 @@
|
|
1
|
-
require 'pathname'
|
2
|
-
require Pathname(__FILE__).dirname.expand_path.parent + 'spec_helper'
|
3
|
-
|
4
|
-
unless JRUBY
|
5
|
-
require 'date'
|
6
|
-
|
7
|
-
describe DataObjects::Mysql::Command, "Quoting" do
|
8
|
-
include MysqlSpecHelpers
|
9
|
-
|
10
|
-
before :each do
|
11
|
-
setup_test_environment
|
12
|
-
end
|
13
|
-
|
14
|
-
after :each do
|
15
|
-
teardown_test_environment
|
16
|
-
end
|
17
|
-
|
18
|
-
it "should escape strings properly" do
|
19
|
-
command = @connection.create_command("SELECT * FROM widgets WHERE name = ?")
|
20
|
-
command.quote_string("Willy O'Hare & Johnny O'Toole").should == "'Willy O\\'Hare & Johnny O\\'Toole'".dup
|
21
|
-
command.quote_string("The\\Backslasher\\Rises\\Again").should == "'The\\\\Backslasher\\\\Rises\\\\Again'"
|
22
|
-
command.quote_string("Scott \"The Rage\" Bauer").should == "'Scott \\\"The Rage\\\" Bauer'"
|
23
|
-
end
|
24
|
-
|
25
|
-
it "should quote DateTime instances properly" do
|
26
|
-
command = @connection.create_command("SELECT * FROM widgets WHERE release_datetime >= ?")
|
27
|
-
dt = DateTime.now
|
28
|
-
command.quote_datetime(dt).should == "'#{dt.strftime('%Y-%m-%d %H:%M:%S')}'"
|
29
|
-
end
|
30
|
-
|
31
|
-
it "should quote Time instances properly" do
|
32
|
-
command = @connection.create_command("SELECT * FROM widgets WHERE release_timestamp >= ?")
|
33
|
-
dt = Time.now
|
34
|
-
command.quote_time(dt).should == "'#{dt.strftime('%Y-%m-%d %H:%M:%S')}'"
|
35
|
-
end
|
36
|
-
|
37
|
-
it "should quote Date instances properly" do
|
38
|
-
command = @connection.create_command("SELECT * FROM widgets WHERE release_date >= ?")
|
39
|
-
dt = Date.today
|
40
|
-
command.quote_date(dt).should == "'#{dt.strftime('%Y-%m-%d')}'"
|
41
|
-
end
|
42
|
-
|
43
|
-
end
|
44
|
-
|
45
|
-
end
|
data/spec/spec.opts
DELETED
@@ -1,35 +0,0 @@
|
|
1
|
-
require 'pathname'
|
2
|
-
require Pathname(__FILE__).dirname.expand_path.parent + 'spec_helper'
|
3
|
-
|
4
|
-
describe DataObjects::Mysql::Transaction do
|
5
|
-
|
6
|
-
before :each do
|
7
|
-
@connection = mock("connection")
|
8
|
-
DataObjects::Connection.should_receive(:new).with("mock://mock/mock").once.and_return(@connection)
|
9
|
-
@transaction = DataObjects::Mysql::Transaction.new("mock://mock/mock")
|
10
|
-
@transaction.id.replace("id")
|
11
|
-
@command = mock("command")
|
12
|
-
end
|
13
|
-
|
14
|
-
{
|
15
|
-
:begin => "XA START 'id'",
|
16
|
-
:commit => "XA COMMIT 'id'",
|
17
|
-
:rollback => ["XA END 'id'", "XA ROLLBACK 'id'"],
|
18
|
-
:rollback_prepared => "XA ROLLBACK 'id'",
|
19
|
-
:prepare => ["XA END 'id'", "XA PREPARE 'id'"]
|
20
|
-
}.each do |method, commands|
|
21
|
-
it "should execute #{commands.inspect} on ##{method}" do
|
22
|
-
if commands.is_a?(String)
|
23
|
-
@command.should_receive(:execute_non_query).once
|
24
|
-
@connection.should_receive(:create_command).once.with(commands).and_return(@command)
|
25
|
-
@transaction.send(method)
|
26
|
-
elsif commands.is_a?(Array) && commands.size == 2
|
27
|
-
@command.should_receive(:execute_non_query).twice
|
28
|
-
@connection.should_receive(:create_command).once.with(commands.first).and_return(@command)
|
29
|
-
@connection.should_receive(:create_command).once.with(commands.last).and_return(@command)
|
30
|
-
@transaction.send(method)
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
end
|