Skip to content

Commit 1f1b56a

Browse files
author
Montana Mendy
authored
Add files via upload
1 parent e914faa commit 1f1b56a

File tree

101 files changed

+6011
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

101 files changed

+6011
-0
lines changed

data_objects/ChangeLog.markdown

+76
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
## 0.10.10 2012-10-11
2+
3+
* JRuby performance improvements
4+
* Reconnect added on JRuby
5+
* do\_sqlite3 C driver supports busy\_timeout
6+
7+
## 0.10.9 2012-08-13
8+
9+
* Don't try to escape queries when no binding parameters are given
10+
11+
## 0.10.8 2012-02-10
12+
13+
* Ruby 1.9.3 compatibility on Windows
14+
* Don't display password in URI
15+
16+
## 0.10.7 2011-10-13
17+
18+
* Ruby 1.9.3 compatibility
19+
20+
## 0.10.6 2011-05-22
21+
22+
Bugfixes
23+
* Fix an issue on some platforms when multiple DO drivers are loaded
24+
25+
## 0.10.5 2011-05-03
26+
27+
Bugfixes
28+
* Fix an issue with DateTime (do\_sqlite3)
29+
30+
## 0.10.4 2011-04-28
31+
32+
New features
33+
* Add save point to transactions (all)
34+
* JRuby 1.9 mode support (encodings etc.)
35+
36+
Bugfixes
37+
* Fix segfault when no tuples are returned from a non select statement (do\_postgres)
38+
* Fix bug when using nested transactions in concurrent scenarios (all)
39+
* Use column aliases instead of names (jruby)
40+
* DST calculation fixes (all)
41+
* Attempt to add better support for ancient MySQL versions (do\_mysql)
42+
* Fix handling sub second precision for Time objects (do\_postgres)
43+
44+
Other
45+
* Refactor to DRY up the adapters (all)
46+
* Many style fixes
47+
* Switch back to RSpec
48+
49+
## 0.10.3 2011-01-30
50+
* Reworked transactions
51+
* Fix a DST bug that could cause datetimes in the wrong timezone
52+
53+
## 0.10.2 2010-05-19
54+
* Support for Encoding.default_internal
55+
* Rework logging to adding a callback is possible
56+
57+
## 0.10.1 2010-01-08
58+
59+
* Removal of Extlib dependency: Pooling and Utilities code moved to DataObjects.
60+
* Switch to Jeweler for Gem building tasks (this change may be temporary).
61+
* Switch to using Bacon for running specs: This should make specs friendlier to
62+
new Ruby implementations that are not yet 100% MRI-compatible, and in turn,
63+
pave the road for our own IronRuby and MacRuby support.
64+
* Make DataObjects::Reader Enumerable.
65+
66+
## 0.10.0 2009-09-15
67+
68+
* No Changes since 0.9.11
69+
70+
## 0.9.11 2009-01-19
71+
* Fixes
72+
* Use Extlib `Object.full_const_get` instead of custom code
73+
* Remove Field as it was unused
74+
75+
## 0.9.9 2008-11-27
76+
* No Changes since 0.9.8

data_objects/Gemfile

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
source :rubygems
2+
3+
gemspec
4+
5+
group :development do # Development dependencies (as in the gemspec)
6+
gem 'rake'
7+
end

data_objects/LICENSE

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
Copyright (c) 2007 - 2011 Yehuda Katz, Dirkjan Bussink
2+
3+
Permission is hereby granted, free of charge, to any person obtaining
4+
a copy of this software and associated documentation files (the
5+
"Software"), to deal in the Software without restriction, including
6+
without limitation the rights to use, copy, modify, merge, publish,
7+
distribute, sublicense, and/or sell copies of the Software, and to
8+
permit persons to whom the Software is furnished to do so, subject to
9+
the following conditions:
10+
11+
The above copyright notice and this permission notice shall be
12+
included in all copies or substantial portions of the Software.
13+
14+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

data_objects/README.markdown

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# data_objects
2+
3+
* <http://dataobjects.info>
4+
5+
## Description
6+
7+
A unified Ruby API for popular databases.
8+
9+
## License
10+
11+
Licensed under the MIT license. Please see the {file:LICENSE} for more information.
12+
13+
## Contact
14+
15+
**IRC**: **Join us on IRC in #datamapper on irc.freenode.net!**<br/>
16+
**Git**: <http://github.com/datamapper/do><br/>
17+
**Author**: Dirkjan Bussink<br/>
18+
**License**: MIT License

data_objects/Rakefile

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
require 'pathname'
2+
require 'rubygems'
3+
require 'bundler'
4+
require 'rubygems/package_task'
5+
Bundler::GemHelper.install_tasks
6+
7+
require 'rake'
8+
require 'rake/clean'
9+
10+
ROOT = Pathname(__FILE__).dirname.expand_path
11+
12+
require ROOT + 'lib/data_objects/version'
13+
14+
JRUBY = RUBY_PLATFORM =~ /java/
15+
IRONRUBY = defined?(RUBY_ENGINE) && RUBY_ENGINE == 'ironruby'
16+
WINDOWS = Gem.win_platform? || (JRUBY && ENV_JAVA['os.name'] =~ /windows/i)
17+
SUDO = WINDOWS ? '' : ('sudo' unless ENV['SUDOLESS'])
18+
19+
CLEAN.include(%w[ pkg/ **/*.rbc ])
20+
21+
FileList['tasks/**/*.rake'].each { |task| import task }

data_objects/data_objects.gemspec

+115
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
# -*- encoding: utf-8 -*-
2+
3+
Gem::Specification.new do |s|
4+
s.name = %q{data_objects}
5+
s.version = "0.10.10"
6+
7+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8+
s.authors = ["Dirkjan Bussink"]
9+
s.description = %q{Provide a standard and simplified API for communicating with RDBMS from Ruby}
10+
s.email = %q{[email protected]}
11+
s.extra_rdoc_files = [
12+
"README.markdown"
13+
]
14+
s.files = [
15+
"ChangeLog.markdown",
16+
"LICENSE",
17+
"README.markdown",
18+
"Rakefile",
19+
"lib/data_objects.rb",
20+
"lib/data_objects/byte_array.rb",
21+
"lib/data_objects/command.rb",
22+
"lib/data_objects/connection.rb",
23+
"lib/data_objects/error.rb",
24+
"lib/data_objects/error/connection_error.rb",
25+
"lib/data_objects/error/data_error.rb",
26+
"lib/data_objects/error/integrity_error.rb",
27+
"lib/data_objects/error/sql_error.rb",
28+
"lib/data_objects/error/syntax_error.rb",
29+
"lib/data_objects/error/transaction_error.rb",
30+
"lib/data_objects/extension.rb",
31+
"lib/data_objects/logger.rb",
32+
"lib/data_objects/pooling.rb",
33+
"lib/data_objects/quoting.rb",
34+
"lib/data_objects/reader.rb",
35+
"lib/data_objects/result.rb",
36+
"lib/data_objects/spec/lib/pending_helpers.rb",
37+
"lib/data_objects/spec/lib/ssl.rb",
38+
"lib/data_objects/spec/setup.rb",
39+
"lib/data_objects/spec/shared/command_spec.rb",
40+
"lib/data_objects/spec/shared/connection_spec.rb",
41+
"lib/data_objects/spec/shared/encoding_spec.rb",
42+
"lib/data_objects/spec/shared/error/sql_error_spec.rb",
43+
"lib/data_objects/spec/shared/quoting_spec.rb",
44+
"lib/data_objects/spec/shared/reader_spec.rb",
45+
"lib/data_objects/spec/shared/result_spec.rb",
46+
"lib/data_objects/spec/shared/typecast/array_spec.rb",
47+
"lib/data_objects/spec/shared/typecast/bigdecimal_spec.rb",
48+
"lib/data_objects/spec/shared/typecast/boolean_spec.rb",
49+
"lib/data_objects/spec/shared/typecast/byte_array_spec.rb",
50+
"lib/data_objects/spec/shared/typecast/class_spec.rb",
51+
"lib/data_objects/spec/shared/typecast/date_spec.rb",
52+
"lib/data_objects/spec/shared/typecast/datetime_spec.rb",
53+
"lib/data_objects/spec/shared/typecast/float_spec.rb",
54+
"lib/data_objects/spec/shared/typecast/integer_spec.rb",
55+
"lib/data_objects/spec/shared/typecast/ipaddr_spec.rb",
56+
"lib/data_objects/spec/shared/typecast/nil_spec.rb",
57+
"lib/data_objects/spec/shared/typecast/other_spec.rb",
58+
"lib/data_objects/spec/shared/typecast/range_spec.rb",
59+
"lib/data_objects/spec/shared/typecast/string_spec.rb",
60+
"lib/data_objects/spec/shared/typecast/time_spec.rb",
61+
"lib/data_objects/transaction.rb",
62+
"lib/data_objects/uri.rb",
63+
"lib/data_objects/utilities.rb",
64+
"lib/data_objects/version.rb",
65+
"spec/command_spec.rb",
66+
"spec/connection_spec.rb",
67+
"spec/do_mock.rb",
68+
"spec/do_mock2.rb",
69+
"spec/pooling_spec.rb",
70+
"spec/reader_spec.rb",
71+
"spec/result_spec.rb",
72+
"spec/spec_helper.rb",
73+
"spec/transaction_spec.rb",
74+
"spec/uri_spec.rb",
75+
"tasks/release.rake",
76+
"tasks/spec.rake",
77+
"tasks/yard.rake",
78+
"tasks/yardstick.rake"
79+
]
80+
s.homepage = %q{http://github.com/datamapper/do}
81+
s.require_paths = ["lib"]
82+
s.rubyforge_project = %q{dorb}
83+
s.rubygems_version = %q{1.6.2}
84+
s.summary = %q{DataObjects basic API and shared driver specifications}
85+
s.test_files = [
86+
"spec/command_spec.rb",
87+
"spec/connection_spec.rb",
88+
"spec/do_mock.rb",
89+
"spec/do_mock2.rb",
90+
"spec/pooling_spec.rb",
91+
"spec/reader_spec.rb",
92+
"spec/result_spec.rb",
93+
"spec/spec_helper.rb",
94+
"spec/transaction_spec.rb",
95+
"spec/uri_spec.rb"
96+
]
97+
98+
if s.respond_to? :specification_version then
99+
s.specification_version = 3
100+
101+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
102+
s.add_runtime_dependency(%q<addressable>, ["~> 2.1"])
103+
s.add_development_dependency(%q<rspec>, ["~> 2.5"])
104+
s.add_development_dependency(%q<yard>, ["~> 0.5"])
105+
else
106+
s.add_dependency(%q<addressable>, ["~> 2.1"])
107+
s.add_dependency(%q<rspec>, ["~> 2.5"])
108+
s.add_dependency(%q<yard>, ["~> 0.5"])
109+
end
110+
else
111+
s.add_dependency(%q<addressable>, ["~> 2.1"])
112+
s.add_dependency(%q<rspec>, ["~> 2.5"])
113+
s.add_dependency(%q<yard>, ["~> 0.5"])
114+
end
115+
end

data_objects/lib/data_objects.rb

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
require 'data_objects/version'
2+
require 'data_objects/utilities'
3+
require 'data_objects/logger'
4+
require 'data_objects/byte_array'
5+
require 'data_objects/pooling'
6+
require 'data_objects/connection'
7+
require 'data_objects/uri'
8+
require 'data_objects/transaction'
9+
require 'data_objects/command'
10+
require 'data_objects/result'
11+
require 'data_objects/reader'
12+
require 'data_objects/quoting'
13+
require 'data_objects/extension'
14+
require 'data_objects/error'
15+
require 'data_objects/error/sql_error'
16+
require 'data_objects/error/connection_error'
17+
require 'data_objects/error/data_error'
18+
require 'data_objects/error/integrity_error'
19+
require 'data_objects/error/syntax_error'
20+
require 'data_objects/error/transaction_error'
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# This class has exists to represent binary data. This is mainly
2+
# used by DataObjects. Binary data sometimes needs to be quoted differently
3+
# than regular string data (even if the string is just plain ASCII).
4+
module Extlib
5+
class ByteArray < ::String; end
6+
end
+82
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
module DataObjects
2+
# Abstract base class for adapter-specific Command subclasses
3+
class Command
4+
5+
# The Connection on which the command will be run
6+
attr_reader :connection
7+
8+
# Create a new Command object on the specified connection
9+
def initialize(connection, text)
10+
raise ArgumentError.new("+connection+ must be a DataObjects::Connection") unless DataObjects::Connection === connection
11+
@connection, @text = connection, text
12+
end
13+
14+
# Execute this command and return no dataset
15+
def execute_non_query(*args)
16+
raise NotImplementedError.new
17+
end
18+
19+
# Execute this command and return a DataObjects::Reader for a dataset
20+
def execute_reader(*args)
21+
raise NotImplementedError.new
22+
end
23+
24+
# Assign an array of types for the columns to be returned by this command
25+
def set_types(column_types)
26+
raise NotImplementedError.new
27+
end
28+
29+
# Display the command text
30+
def to_s
31+
@text
32+
end
33+
34+
private
35+
36+
# Escape a string of SQL with a set of arguments.
37+
# The first argument is assumed to be the SQL to escape,
38+
# the remaining arguments (if any) are assumed to be
39+
# values to escape and interpolate.
40+
#
41+
# ==== Examples
42+
# escape_sql("SELECT * FROM zoos")
43+
# # => "SELECT * FROM zoos"
44+
#
45+
# escape_sql("SELECT * FROM zoos WHERE name = ?", "Dallas")
46+
# # => "SELECT * FROM zoos WHERE name = `Dallas`"
47+
#
48+
# escape_sql("SELECT * FROM zoos WHERE name = ? AND acreage > ?", "Dallas", 40)
49+
# # => "SELECT * FROM zoos WHERE name = `Dallas` AND acreage > 40"
50+
#
51+
# ==== Warning
52+
# This method is meant mostly for adapters that don't support
53+
# bind-parameters.
54+
def escape_sql(args)
55+
return @text if args.empty?
56+
sql = @text.dup
57+
vars = args.dup
58+
59+
replacements = 0
60+
mismatch = false
61+
62+
sql.gsub!(/'[^']*'|"[^"]*"|`[^`]*`|\?/) do |x|
63+
next x unless x == '?'
64+
replacements += 1
65+
if vars.empty?
66+
mismatch = true
67+
else
68+
var = vars.shift
69+
connection.quote_value(var)
70+
end
71+
end
72+
73+
if !vars.empty? || mismatch
74+
raise ArgumentError, "Binding mismatch: #{args.size} for #{replacements}"
75+
else
76+
sql
77+
end
78+
end
79+
80+
end
81+
82+
end

0 commit comments

Comments
 (0)