sequel 0.4.4.1 → 0.4.4.2
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/CHANGELOG +10 -0
- data/Rakefile +161 -159
- data/lib/sequel.rb +14 -10
- data/lib/sequel/adapters/adapter_skeleton.rb +2 -1
- data/lib/sequel/adapters/ado.rb +2 -1
- data/lib/sequel/adapters/db2.rb +5 -3
- data/lib/sequel/adapters/dbi.rb +2 -1
- data/lib/sequel/adapters/informix.rb +2 -1
- data/lib/sequel/adapters/jdbc.rb +3 -2
- data/lib/sequel/adapters/mysql.rb +268 -264
- data/lib/sequel/adapters/odbc.rb +7 -2
- data/lib/sequel/adapters/odbc_mssql.rb +1 -1
- data/lib/sequel/adapters/openbase.rb +2 -1
- data/lib/sequel/adapters/oracle.rb +2 -1
- data/lib/sequel/adapters/postgres.rb +32 -16
- data/lib/sequel/adapters/sqlite.rb +7 -6
- data/lib/sequel/array_keys.rb +295 -295
- data/lib/sequel/connection_pool.rb +1 -1
- data/lib/sequel/core_sql.rb +14 -5
- data/lib/sequel/database.rb +4 -4
- data/lib/sequel/dataset.rb +12 -10
- data/lib/sequel/dataset/convenience.rb +10 -8
- data/lib/sequel/dataset/sequelizer.rb +19 -16
- data/lib/sequel/dataset/sql.rb +43 -30
- data/lib/sequel/exceptions.rb +45 -0
- data/lib/sequel/migration.rb +7 -5
- data/lib/sequel/model.rb +1 -1
- data/lib/sequel/model/base.rb +3 -3
- data/lib/sequel/model/hooks.rb +0 -4
- data/lib/sequel/model/record.rb +9 -9
- data/lib/sequel/model/relations.rb +2 -2
- data/lib/sequel/pretty_table.rb +6 -3
- data/lib/sequel/schema/schema_sql.rb +11 -6
- data/lib/sequel/worker.rb +8 -7
- data/spec/adapters/sqlite_spec.rb +3 -3
- data/spec/array_keys_spec.rb +543 -543
- data/spec/connection_pool_spec.rb +6 -3
- data/spec/database_spec.rb +4 -4
- data/spec/dataset_spec.rb +25 -25
- data/spec/migration_spec.rb +1 -1
- data/spec/model_spec.rb +16 -16
- data/spec/sequelizer_spec.rb +7 -7
- data/spec/spec.opts +8 -0
- metadata +5 -5
- data/lib/sequel/error.rb +0 -22
data/CHANGELOG
CHANGED
@@ -1,3 +1,13 @@
|
|
1
|
+
=== 0.4.4.2 (2007-12-20)
|
2
|
+
|
3
|
+
* Fixed parsing errors in Ruby 1.9.
|
4
|
+
|
5
|
+
* Fixed sync problem in connection_pool_spec.
|
6
|
+
|
7
|
+
* Changed String#to_time to raise Error::InvalidValue if Time.parse fails.
|
8
|
+
|
9
|
+
* Refactored sequel error classes.
|
10
|
+
|
1
11
|
=== 0.4.4.1 (2007-12-19)
|
2
12
|
|
3
13
|
* Fixed schema generation code to use fied quoting and support adapter-specific literalization of default values (#108).
|
data/Rakefile
CHANGED
@@ -1,159 +1,161 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
6
|
-
include FileUtils
|
7
|
-
|
8
|
-
NAME = "sequel"
|
9
|
-
VERS = "0.4.4.
|
10
|
-
CLEAN.include [
|
11
|
-
RDOC_OPTS = [
|
12
|
-
"--opname", "index.html",
|
13
|
-
"--line-numbers",
|
14
|
-
"--main", "README",
|
15
|
-
"--inline-source"]
|
16
|
-
|
17
|
-
desc "Packages up Sequel."
|
18
|
-
task :default => [:package]
|
19
|
-
task :package => [:clean]
|
20
|
-
|
21
|
-
task :doc => [:rdoc]
|
22
|
-
|
23
|
-
Rake::RDocTask.new do |rdoc|
|
24
|
-
rdoc.rdoc_dir =
|
25
|
-
rdoc.options += RDOC_OPTS
|
26
|
-
rdoc.main = "README"
|
27
|
-
rdoc.title = "Sequel: Lightweight ORM library for Ruby"
|
28
|
-
rdoc.rdoc_files.add [
|
29
|
-
end
|
30
|
-
|
31
|
-
spec = Gem::Specification.new do |s|
|
32
|
-
s.name = NAME
|
33
|
-
s.version = VERS
|
34
|
-
s.platform = Gem::Platform::RUBY
|
35
|
-
s.has_rdoc = true
|
36
|
-
s.extra_rdoc_files = ["README", "CHANGELOG", "COPYING"]
|
37
|
-
s.rdoc_options += RDOC_OPTS +
|
38
|
-
[
|
39
|
-
s.summary = "Lightweight ORM library for Ruby"
|
40
|
-
s.description = s.summary
|
41
|
-
s.author = "Sharon Rosner"
|
42
|
-
s.email =
|
43
|
-
s.homepage =
|
44
|
-
s.executables = [
|
45
|
-
|
46
|
-
s.add_dependency(
|
47
|
-
s.add_dependency(
|
48
|
-
s.add_dependency(
|
49
|
-
|
50
|
-
s.required_ruby_version =
|
51
|
-
|
52
|
-
s.files = %w(COPYING README Rakefile) + Dir.glob("{bin,doc,spec,lib}/**/*")
|
53
|
-
|
54
|
-
s.require_path = "lib"
|
55
|
-
s.bindir = "bin"
|
56
|
-
end
|
57
|
-
|
58
|
-
win_spec = Gem::Specification.new do |s|
|
59
|
-
s.name = NAME
|
60
|
-
s.version = VERS
|
61
|
-
s.platform = Gem::Platform::WIN32
|
62
|
-
s.has_rdoc = true
|
63
|
-
s.extra_rdoc_files = ["README", "CHANGELOG", "COPYING"]
|
64
|
-
s.rdoc_options += RDOC_OPTS +
|
65
|
-
[
|
66
|
-
s.summary = "Lightweight ORM library for Ruby"
|
67
|
-
s.description = s.summary
|
68
|
-
s.author = "Sharon Rosner"
|
69
|
-
s.email =
|
70
|
-
s.homepage =
|
71
|
-
s.executables = [
|
72
|
-
|
73
|
-
s.add_dependency(
|
74
|
-
|
75
|
-
s.required_ruby_version =
|
76
|
-
|
77
|
-
s.files = %w(COPYING README Rakefile) + Dir.glob("{bin,doc,spec,lib}/**/*")
|
78
|
-
|
79
|
-
s.require_path = "lib"
|
80
|
-
s.bindir = "bin"
|
81
|
-
end
|
82
|
-
|
83
|
-
Rake::GemPackageTask.new(spec) do |p|
|
84
|
-
p.need_tar = true
|
85
|
-
p.gem_spec = spec
|
86
|
-
end
|
87
|
-
|
88
|
-
Rake::GemPackageTask.new(win_spec) do |p|
|
89
|
-
p.need_tar = true
|
90
|
-
p.gem_spec = win_spec
|
91
|
-
end
|
92
|
-
|
93
|
-
task :install do
|
94
|
-
sh %{rake package}
|
95
|
-
sh %{sudo gem install pkg/#{NAME}-#{VERS}}
|
96
|
-
end
|
97
|
-
|
98
|
-
task :install_no_docs do
|
99
|
-
sh %{rake package}
|
100
|
-
sh %{sudo gem install pkg/#{NAME}-#{VERS} --no-rdoc --no-ri}
|
101
|
-
end
|
102
|
-
|
103
|
-
task :uninstall => [:clean] do
|
104
|
-
sh %{sudo gem uninstall #{NAME}}
|
105
|
-
end
|
106
|
-
|
107
|
-
task :release => [:package] do
|
108
|
-
sh %{rubyforge login}
|
109
|
-
sh %{rubyforge add_release sequel sequel #{VERS} pkg/sequel-#{VERS}.tgz}
|
110
|
-
sh %{rubyforge add_file sequel sequel #{VERS} pkg/sequel-#{VERS}.gem}
|
111
|
-
sh %{rubyforge add_file sequel sequel #{VERS} pkg/sequel-#{VERS}-x86-mswin32-60.gem}
|
112
|
-
end
|
113
|
-
|
114
|
-
desc
|
115
|
-
task :doc_rforge do
|
116
|
-
sh %{rake doc}
|
117
|
-
sh %{scp -r doc/rdoc/* ciconia@rubyforge.org:/var/www/gforge-projects/sequel}
|
118
|
-
end
|
119
|
-
|
120
|
-
require
|
121
|
-
|
122
|
-
desc "Run specs with coverage"
|
123
|
-
Spec::Rake::SpecTask.new(
|
124
|
-
t.spec_files = FileList[
|
125
|
-
t.
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
t.
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
##############################################################################
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
1
|
+
require "rake"
|
2
|
+
require "rake/clean"
|
3
|
+
require "rake/gempackagetask"
|
4
|
+
require "rake/rdoctask"
|
5
|
+
require "fileutils"
|
6
|
+
include FileUtils
|
7
|
+
|
8
|
+
NAME = "sequel"
|
9
|
+
VERS = "0.4.4.2"
|
10
|
+
CLEAN.include ["**/.*.sw?", "pkg/*", ".config", "doc/*", "coverage/*"]
|
11
|
+
RDOC_OPTS = ["--quiet", "--title", "Sequel: Concise ORM for Ruby",
|
12
|
+
"--opname", "index.html",
|
13
|
+
"--line-numbers",
|
14
|
+
"--main", "README",
|
15
|
+
"--inline-source"]
|
16
|
+
|
17
|
+
desc "Packages up Sequel."
|
18
|
+
task :default => [:package]
|
19
|
+
task :package => [:clean]
|
20
|
+
|
21
|
+
task :doc => [:rdoc]
|
22
|
+
|
23
|
+
Rake::RDocTask.new do |rdoc|
|
24
|
+
rdoc.rdoc_dir = "doc/rdoc"
|
25
|
+
rdoc.options += RDOC_OPTS
|
26
|
+
rdoc.main = "README"
|
27
|
+
rdoc.title = "Sequel: Lightweight ORM library for Ruby"
|
28
|
+
rdoc.rdoc_files.add ["README", "COPYING", "lib/sequel.rb", "lib/**/*.rb"]
|
29
|
+
end
|
30
|
+
|
31
|
+
spec = Gem::Specification.new do |s|
|
32
|
+
s.name = NAME
|
33
|
+
s.version = VERS
|
34
|
+
s.platform = Gem::Platform::RUBY
|
35
|
+
s.has_rdoc = true
|
36
|
+
s.extra_rdoc_files = ["README", "CHANGELOG", "COPYING"]
|
37
|
+
s.rdoc_options += RDOC_OPTS +
|
38
|
+
["--exclude", "^(examples|extras)\/", "--exclude", "lib/sequel.rb"]
|
39
|
+
s.summary = "Lightweight ORM library for Ruby"
|
40
|
+
s.description = s.summary
|
41
|
+
s.author = "Sharon Rosner"
|
42
|
+
s.email = "ciconia@gmail.com"
|
43
|
+
s.homepage = "http://sequel.rubyforge.org"
|
44
|
+
s.executables = ["sequel"]
|
45
|
+
|
46
|
+
s.add_dependency("metaid")
|
47
|
+
s.add_dependency("ParseTree", ">= 2.0.0")
|
48
|
+
s.add_dependency("ruby2ruby")
|
49
|
+
|
50
|
+
s.required_ruby_version = ">= 1.8.4"
|
51
|
+
|
52
|
+
s.files = %w(COPYING README Rakefile) + Dir.glob("{bin,doc,spec,lib}/**/*")
|
53
|
+
|
54
|
+
s.require_path = "lib"
|
55
|
+
s.bindir = "bin"
|
56
|
+
end
|
57
|
+
|
58
|
+
win_spec = Gem::Specification.new do |s|
|
59
|
+
s.name = NAME
|
60
|
+
s.version = VERS
|
61
|
+
s.platform = Gem::Platform::WIN32
|
62
|
+
s.has_rdoc = true
|
63
|
+
s.extra_rdoc_files = ["README", "CHANGELOG", "COPYING"]
|
64
|
+
s.rdoc_options += RDOC_OPTS +
|
65
|
+
["--exclude", "^(examples|extras)\/", "--exclude", "lib/sequel.rb"]
|
66
|
+
s.summary = "Lightweight ORM library for Ruby"
|
67
|
+
s.description = s.summary
|
68
|
+
s.author = "Sharon Rosner"
|
69
|
+
s.email = "ciconia@gmail.com"
|
70
|
+
s.homepage = "http://sequel.rubyforge.org"
|
71
|
+
s.executables = ["sequel"]
|
72
|
+
|
73
|
+
s.add_dependency("metaid")
|
74
|
+
|
75
|
+
s.required_ruby_version = ">= 1.8.4"
|
76
|
+
|
77
|
+
s.files = %w(COPYING README Rakefile) + Dir.glob("{bin,doc,spec,lib}/**/*")
|
78
|
+
|
79
|
+
s.require_path = "lib"
|
80
|
+
s.bindir = "bin"
|
81
|
+
end
|
82
|
+
|
83
|
+
Rake::GemPackageTask.new(spec) do |p|
|
84
|
+
p.need_tar = true
|
85
|
+
p.gem_spec = spec
|
86
|
+
end
|
87
|
+
|
88
|
+
Rake::GemPackageTask.new(win_spec) do |p|
|
89
|
+
p.need_tar = true
|
90
|
+
p.gem_spec = win_spec
|
91
|
+
end
|
92
|
+
|
93
|
+
task :install do
|
94
|
+
sh %{rake package}
|
95
|
+
sh %{sudo gem install pkg/#{NAME}-#{VERS}}
|
96
|
+
end
|
97
|
+
|
98
|
+
task :install_no_docs do
|
99
|
+
sh %{rake package}
|
100
|
+
sh %{sudo gem install pkg/#{NAME}-#{VERS} --no-rdoc --no-ri}
|
101
|
+
end
|
102
|
+
|
103
|
+
task :uninstall => [:clean] do
|
104
|
+
sh %{sudo gem uninstall #{NAME}}
|
105
|
+
end
|
106
|
+
|
107
|
+
task :release => [:package] do
|
108
|
+
sh %{rubyforge login}
|
109
|
+
sh %{rubyforge add_release sequel sequel #{VERS} pkg/sequel-#{VERS}.tgz}
|
110
|
+
sh %{rubyforge add_file sequel sequel #{VERS} pkg/sequel-#{VERS}.gem}
|
111
|
+
sh %{rubyforge add_file sequel sequel #{VERS} pkg/sequel-#{VERS}-x86-mswin32-60.gem}
|
112
|
+
end
|
113
|
+
|
114
|
+
desc "Update docs and upload to rubyforge.org"
|
115
|
+
task :doc_rforge do
|
116
|
+
sh %{rake doc}
|
117
|
+
sh %{scp -r doc/rdoc/* ciconia@rubyforge.org:/var/www/gforge-projects/sequel}
|
118
|
+
end
|
119
|
+
|
120
|
+
require "spec/rake/spectask"
|
121
|
+
|
122
|
+
desc "Run specs with coverage"
|
123
|
+
Spec::Rake::SpecTask.new("spec") do |t|
|
124
|
+
t.spec_files = FileList["spec/*_spec.rb"]
|
125
|
+
t.rcov_opts = ["--exclude", "gems", "--exclude", "spec"]
|
126
|
+
t.rcov = true
|
127
|
+
end
|
128
|
+
|
129
|
+
desc "Run specs without coverage"
|
130
|
+
Spec::Rake::SpecTask.new("spec_no_cov") do |t|
|
131
|
+
t.spec_files = FileList["spec/*_spec.rb"]
|
132
|
+
end
|
133
|
+
|
134
|
+
desc "Run adapter specs without coverage"
|
135
|
+
Spec::Rake::SpecTask.new("spec_adapters") do |t|
|
136
|
+
t.spec_files = FileList["spec/adapters/*_spec.rb"]
|
137
|
+
end
|
138
|
+
|
139
|
+
desc "Run all specs with coverage"
|
140
|
+
Spec::Rake::SpecTask.new("spec_all") do |t|
|
141
|
+
t.spec_files = FileList["spec/*_spec.rb", "spec/adapters/*_spec.rb"]
|
142
|
+
t.rcov_opts = ["--exclude", "gems", "--exclude", "spec"]
|
143
|
+
t.rcov = true
|
144
|
+
end
|
145
|
+
|
146
|
+
##############################################################################
|
147
|
+
# Statistics
|
148
|
+
##############################################################################
|
149
|
+
|
150
|
+
STATS_DIRECTORIES = [
|
151
|
+
%w(Code lib/),
|
152
|
+
%w(Spec spec/)
|
153
|
+
].collect { |name, dir| [ name, "./#{dir}" ] }.select { |name, dir| File.directory?(dir) }
|
154
|
+
|
155
|
+
desc "Report code statistics (KLOCs, etc) from the application"
|
156
|
+
task :stats do
|
157
|
+
require "extra/stats"
|
158
|
+
verbose = true
|
159
|
+
CodeStatistics.new(*STATS_DIRECTORIES).to_s
|
160
|
+
end
|
161
|
+
|
data/lib/sequel.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
1
|
+
require "metaid"
|
2
|
+
require "bigdecimal"
|
3
|
+
require "bigdecimal/util"
|
4
4
|
|
5
5
|
files = %w[
|
6
|
-
core_ext core_sql array_keys
|
6
|
+
core_ext core_sql array_keys exceptions connection_pool pretty_table
|
7
7
|
dataset migration model schema database worker
|
8
8
|
]
|
9
|
-
dir = File.join(File.dirname(__FILE__),
|
9
|
+
dir = File.join(File.dirname(__FILE__), "sequel")
|
10
10
|
files.each {|f| require(File.join(dir, f))}
|
11
11
|
|
12
12
|
module Sequel #:nodoc:
|
@@ -32,16 +32,20 @@ module Sequel #:nodoc:
|
|
32
32
|
def method_missing(m, *args)
|
33
33
|
c = Database.adapter_class(m)
|
34
34
|
begin
|
35
|
+
# three ways to invoke this:
|
36
|
+
# 0 arguments: Sequel.dbi
|
37
|
+
# 1 argument: Sequel.dbi(db_name)
|
38
|
+
# more args: Sequel.dbi(db_name, opts)
|
35
39
|
case args.size
|
36
|
-
when
|
37
|
-
opts = args[0].is_a?(Hash) ? args[0] : {:database => args[0]}
|
38
|
-
when 0 # Sequel.dbi
|
40
|
+
when 0
|
39
41
|
opts = {}
|
40
|
-
|
42
|
+
when 1
|
43
|
+
opts = args[0].is_a?(Hash) ? args[0] : {:database => args[0]}
|
44
|
+
else
|
41
45
|
opts = args[1].merge(:database => args[0])
|
42
46
|
end
|
43
47
|
rescue
|
44
|
-
raise
|
48
|
+
raise Error, "Unknown adapter (#{m})"
|
45
49
|
end
|
46
50
|
c.new(opts)
|
47
51
|
end
|
data/lib/sequel/adapters/ado.rb
CHANGED
data/lib/sequel/adapters/db2.rb
CHANGED
@@ -14,9 +14,10 @@ module Sequel
|
|
14
14
|
|
15
15
|
def check_error(rc, msg)
|
16
16
|
case rc
|
17
|
-
when SQL_SUCCESS, SQL_SUCCESS_WITH_INFO
|
17
|
+
when SQL_SUCCESS, SQL_SUCCESS_WITH_INFO
|
18
|
+
nil
|
18
19
|
else
|
19
|
-
raise
|
20
|
+
raise Error, msg
|
20
21
|
end
|
21
22
|
end
|
22
23
|
|
@@ -79,7 +80,8 @@ module Sequel
|
|
79
80
|
class Dataset < Sequel::Dataset
|
80
81
|
def literal(v)
|
81
82
|
case v
|
82
|
-
when Time
|
83
|
+
when Time
|
84
|
+
literal(v.iso8601)
|
83
85
|
else
|
84
86
|
super
|
85
87
|
end
|
data/lib/sequel/adapters/dbi.rb
CHANGED
data/lib/sequel/adapters/jdbc.rb
CHANGED
@@ -15,7 +15,7 @@ module Sequel
|
|
15
15
|
|
16
16
|
def connect
|
17
17
|
unless conn_string = @opts[:uri] || @opts[:url] || @opts[:database]
|
18
|
-
raise
|
18
|
+
raise Error, "No connection string specified"
|
19
19
|
end
|
20
20
|
unless conn_string =~ /^jdbc:/
|
21
21
|
conn_string = "jdbc:#{conn_string}"
|
@@ -65,7 +65,8 @@ module Sequel
|
|
65
65
|
class Dataset < Sequel::Dataset
|
66
66
|
def literal(v)
|
67
67
|
case v
|
68
|
-
when Time
|
68
|
+
when Time
|
69
|
+
literal(v.iso8601)
|
69
70
|
else
|
70
71
|
super
|
71
72
|
end
|