sequel 4.12.0 → 4.13.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +64 -0
- data/Rakefile +3 -1
- data/bin/sequel +13 -5
- data/doc/release_notes/4.13.0.txt +169 -0
- data/doc/sql.rdoc +3 -3
- data/lib/sequel/adapters/do.rb +11 -23
- data/lib/sequel/adapters/do/mysql.rb +8 -0
- data/lib/sequel/adapters/do/postgres.rb +8 -0
- data/lib/sequel/adapters/do/{sqlite.rb → sqlite3.rb} +9 -0
- data/lib/sequel/adapters/jdbc.rb +16 -139
- data/lib/sequel/adapters/jdbc/as400.rb +9 -0
- data/lib/sequel/adapters/jdbc/cubrid.rb +9 -0
- data/lib/sequel/adapters/jdbc/db2.rb +9 -0
- data/lib/sequel/adapters/jdbc/derby.rb +9 -0
- data/lib/sequel/adapters/jdbc/{firebird.rb → firebirdsql.rb} +9 -0
- data/lib/sequel/adapters/jdbc/h2.rb +10 -0
- data/lib/sequel/adapters/jdbc/hsqldb.rb +9 -0
- data/lib/sequel/adapters/jdbc/{informix.rb → informix-sqli.rb} +9 -0
- data/lib/sequel/adapters/jdbc/{progress.rb → jdbcprogress.rb} +9 -0
- data/lib/sequel/adapters/jdbc/jtds.rb +10 -0
- data/lib/sequel/adapters/jdbc/mysql.rb +14 -0
- data/lib/sequel/adapters/jdbc/oracle.rb +9 -0
- data/lib/sequel/adapters/jdbc/postgresql.rb +9 -0
- data/lib/sequel/adapters/jdbc/sqlanywhere.rb +23 -0
- data/lib/sequel/adapters/jdbc/sqlite.rb +10 -0
- data/lib/sequel/adapters/jdbc/sqlserver.rb +10 -0
- data/lib/sequel/adapters/odbc.rb +6 -14
- data/lib/sequel/adapters/odbc/db2.rb +9 -0
- data/lib/sequel/adapters/odbc/mssql.rb +8 -0
- data/lib/sequel/adapters/odbc/progress.rb +8 -0
- data/lib/sequel/adapters/oracle.rb +1 -1
- data/lib/sequel/adapters/postgres.rb +1 -1
- data/lib/sequel/adapters/shared/firebird.rb +8 -1
- data/lib/sequel/adapters/shared/mssql.rb +68 -27
- data/lib/sequel/adapters/shared/mysql.rb +3 -5
- data/lib/sequel/adapters/shared/oracle.rb +17 -3
- data/lib/sequel/adapters/shared/postgres.rb +9 -4
- data/lib/sequel/adapters/shared/sqlanywhere.rb +6 -6
- data/lib/sequel/database/connecting.rb +38 -17
- data/lib/sequel/dataset/actions.rb +6 -2
- data/lib/sequel/dataset/graph.rb +18 -20
- data/lib/sequel/dataset/misc.rb +37 -0
- data/lib/sequel/dataset/prepared_statements.rb +1 -2
- data/lib/sequel/dataset/query.rb +1 -0
- data/lib/sequel/dataset/sql.rb +17 -10
- data/lib/sequel/extensions/dataset_source_alias.rb +90 -0
- data/lib/sequel/extensions/pg_array.rb +14 -10
- data/lib/sequel/extensions/pg_enum.rb +135 -0
- data/lib/sequel/extensions/pg_hstore.rb +4 -6
- data/lib/sequel/extensions/pg_inet.rb +4 -5
- data/lib/sequel/extensions/pg_interval.rb +3 -3
- data/lib/sequel/extensions/pg_json.rb +16 -12
- data/lib/sequel/extensions/pg_range.rb +5 -3
- data/lib/sequel/extensions/pg_row.rb +2 -2
- data/lib/sequel/extensions/round_timestamps.rb +52 -0
- data/lib/sequel/model.rb +5 -2
- data/lib/sequel/model/associations.rb +29 -3
- data/lib/sequel/model/base.rb +68 -29
- data/lib/sequel/plugins/class_table_inheritance.rb +25 -16
- data/lib/sequel/plugins/column_select.rb +57 -0
- data/lib/sequel/plugins/composition.rb +14 -16
- data/lib/sequel/plugins/dirty.rb +9 -11
- data/lib/sequel/plugins/insert_returning_select.rb +70 -0
- data/lib/sequel/plugins/instance_filters.rb +7 -9
- data/lib/sequel/plugins/lazy_attributes.rb +16 -4
- data/lib/sequel/plugins/list.rb +9 -0
- data/lib/sequel/plugins/modification_detection.rb +90 -0
- data/lib/sequel/plugins/serialization.rb +13 -15
- data/lib/sequel/plugins/serialization_modification_detection.rb +9 -9
- data/lib/sequel/plugins/single_table_inheritance.rb +3 -1
- data/lib/sequel/plugins/timestamps.rb +6 -6
- data/lib/sequel/version.rb +1 -1
- data/spec/adapters/mysql_spec.rb +7 -0
- data/spec/adapters/postgres_spec.rb +41 -0
- data/spec/bin_spec.rb +4 -1
- data/spec/core/database_spec.rb +6 -0
- data/spec/core/dataset_spec.rb +100 -90
- data/spec/core/object_graph_spec.rb +5 -0
- data/spec/extensions/class_table_inheritance_spec.rb +18 -13
- data/spec/extensions/column_select_spec.rb +108 -0
- data/spec/extensions/composition_spec.rb +20 -0
- data/spec/extensions/dataset_source_alias_spec.rb +51 -0
- data/spec/extensions/insert_returning_select_spec.rb +46 -0
- data/spec/extensions/lazy_attributes_spec.rb +24 -20
- data/spec/extensions/list_spec.rb +5 -0
- data/spec/extensions/modification_detection_spec.rb +80 -0
- data/spec/extensions/pg_enum_spec.rb +64 -0
- data/spec/extensions/pg_json_spec.rb +7 -13
- data/spec/extensions/prepared_statements_spec.rb +6 -4
- data/spec/extensions/round_timestamps_spec.rb +43 -0
- data/spec/extensions/serialization_modification_detection_spec.rb +10 -1
- data/spec/extensions/serialization_spec.rb +18 -0
- data/spec/extensions/single_table_inheritance_spec.rb +5 -0
- data/spec/extensions/timestamps_spec.rb +6 -0
- data/spec/integration/plugin_test.rb +14 -8
- data/spec/integration/prepared_statement_test.rb +12 -0
- data/spec/model/associations_spec.rb +24 -0
- data/spec/model/model_spec.rb +13 -3
- data/spec/model/record_spec.rb +24 -1
- metadata +22 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 22556ea07ee280b6aeb118f6079e84cd50079cd4
|
4
|
+
data.tar.gz: 011dbf4ff522233e9bed8a1b2bab18347237345b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9dc9163ebb7f4066cd44da3bdd85b1f5f26cea75b4af812f50ef2c950742b38b992b5c0fbdf61428395b3624788b31cf9f42a9da9b7bfac4ea4976cd29c73b69
|
7
|
+
data.tar.gz: 0ba493e43d63d2fe3d750a621199bb5f43b39e72858424e0089ff977045a3bc6b1c472751ad4c629bbf83680de7bad227cd29c4d7f705389ee212ee638e5c77f
|
data/CHANGELOG
CHANGED
@@ -1,3 +1,67 @@
|
|
1
|
+
=== 4.13.0 (2014-08-01)
|
2
|
+
|
3
|
+
* Use copy constructors instead of overriding Model#dup and #clone (ged, jeremyevans) (#852)
|
4
|
+
|
5
|
+
* Fix handling of MySQL create_table foreign_key calls using :key option (mimperatore, jeremyevans) (#850)
|
6
|
+
|
7
|
+
* Handle another disconnection error in the postgres adapter (lbosque) (#848)
|
8
|
+
|
9
|
+
* Make list plugin update remaining positions after destroying an instance (ehq, jeremyevans) (#847)
|
10
|
+
|
11
|
+
* Unalias aliased tables in Dataset#insert (jeremyevans)
|
12
|
+
|
13
|
+
* Add insert_returning_select plugin, for setting up RETURNING for inserts for models selecting explicit columns (jeremyevans)
|
14
|
+
|
15
|
+
* Make Model#save use insert_select if the dataset used for inserting already uses returning (jeremyevans)
|
16
|
+
|
17
|
+
* Add Dataset#unqualified_column_for helper method, returning unqualified version of possibly qualified column (jeremyevans)
|
18
|
+
|
19
|
+
* Calling Dataset#returning when the Database does not support or emulate RETURNING now raises an Error (jeremyevans)
|
20
|
+
|
21
|
+
* Emulate RETURNING on Microsoft SQL Server using OUTPUT, as long as only simple column references are used (jeremyevans)
|
22
|
+
|
23
|
+
* Switch class_table_inheritance plugin to use JOIN ON instead of JOIN USING (jeremyevans)
|
24
|
+
|
25
|
+
* Qualify primary keys for models with joined datasets when looking up model instances by primary key (jeremyevans)
|
26
|
+
|
27
|
+
* Fix qualification of columns when Dataset#graph automatically wraps the initially graphed dataset in a subselect (jeremyevans)
|
28
|
+
|
29
|
+
* Make Dataset#joined_dataset? a public method (jeremyevans)
|
30
|
+
|
31
|
+
* Allow external jdbc, odbc, and do subadapters to be loaded automatically (jeremyevans)
|
32
|
+
|
33
|
+
* Recognize another disconnect error in the jdbc/mysql adapter (jeremyevans)
|
34
|
+
|
35
|
+
* Set primary keys correctly for models even if datasets select specific columns (jeremyevans)
|
36
|
+
|
37
|
+
* Add dataset_source_alias extension, for automatically aliasing datasets to their first source (jeremyevans)
|
38
|
+
|
39
|
+
* Use qualified columns in the lazy_attributes plugin (jeremyevans)
|
40
|
+
|
41
|
+
* Add column_select plugin, for using explicit column selections in model datasets (jeremyevans)
|
42
|
+
|
43
|
+
* Use associated model's existing selection for join associations if it consists solely of explicitly quailfied columns (jeremyevans)
|
44
|
+
|
45
|
+
* Add round_timestamps extension for automatically rounding timestamp values to database precision before literalizing (jeremyevans)
|
46
|
+
|
47
|
+
* Make rake default task run plugin specs as well as core/model specs (jeremyevans)
|
48
|
+
|
49
|
+
* Use all_tables and all_views for Database#tables and #views on Oracle (jeremyevans)
|
50
|
+
|
51
|
+
* Use all_tab_cols instead of user_tab cols for defaults parsing in the oracle adapter (jeremyevans)
|
52
|
+
|
53
|
+
* Fix recursive mutex locking issue on JRuby when using Sequel::Model(dataset) (jeremyevans) (#841)
|
54
|
+
|
55
|
+
* Make composition and serialization plugins support validations on underlying columns (jeremyevans)
|
56
|
+
|
57
|
+
* Fix regression in timestamps and table inheritance plugin where column values would not be saved if validation is skipped (jeremyevans) (#839)
|
58
|
+
|
59
|
+
* Add pg_enum extension, for dealing with PostgreSQL enums (jeremyevans)
|
60
|
+
|
61
|
+
* Add modification_detection plugin, for automatic detection of in-place column value modifications (jeremyevans)
|
62
|
+
|
63
|
+
* Speed up using plain strings, numbers, true, false, and nil in json columns if underlying json library supports them (jeremyevans) (#834)
|
64
|
+
|
1
65
|
=== 4.12.0 (2014-07-01)
|
2
66
|
|
3
67
|
* Support :readonly Database option in sqlite adapter (ippeiukai, jeremyevans) (#832)
|
data/Rakefile
CHANGED
@@ -132,7 +132,9 @@ begin
|
|
132
132
|
t
|
133
133
|
end
|
134
134
|
|
135
|
-
|
135
|
+
desc "Run the core, model, and extension/plugin specs"
|
136
|
+
task :default => [:spec, :spec_plugin]
|
137
|
+
|
136
138
|
spec_with_cov.call("spec", Dir["spec/{core,model}/*_spec.rb"], "Run core and model specs"){|t| t.rcov_opts.concat(%w'--exclude "lib/sequel/(adapters/([a-ln-z]|m[a-np-z])|extensions/core_extensions)"')}
|
137
139
|
spec.call("spec_bin", ["spec/bin_spec.rb"], "Run bin/sequel specs")
|
138
140
|
spec.call("spec_core", Dir["spec/core/*_spec.rb"], "Run core specs")
|
data/bin/sequel
CHANGED
@@ -2,8 +2,6 @@
|
|
2
2
|
|
3
3
|
require 'rubygems'
|
4
4
|
require 'optparse'
|
5
|
-
$: << File.join(File.dirname(__FILE__), '..', 'lib')
|
6
|
-
require 'sequel'
|
7
5
|
|
8
6
|
code = nil
|
9
7
|
copy_databases = nil
|
@@ -13,6 +11,7 @@ env = nil
|
|
13
11
|
migrate_dir = nil
|
14
12
|
migrate_ver = nil
|
15
13
|
backtrace = nil
|
14
|
+
show_version = false
|
16
15
|
test = true
|
17
16
|
load_dirs = []
|
18
17
|
exclusive_options = []
|
@@ -43,6 +42,7 @@ options = OptionParser.new do |opts|
|
|
43
42
|
|
44
43
|
opts.on("-C", "--copy-databases", "copy one database to another") do
|
45
44
|
copy_databases = true
|
45
|
+
exclusive_options << :C
|
46
46
|
end
|
47
47
|
|
48
48
|
opts.on("-d", "--dump-migration", "print database migration to STDOUT") do
|
@@ -104,8 +104,7 @@ options = OptionParser.new do |opts|
|
|
104
104
|
end
|
105
105
|
|
106
106
|
opts.on_tail("-v", "--version", "Show version") do
|
107
|
-
|
108
|
-
exit
|
107
|
+
show_version = true
|
109
108
|
end
|
110
109
|
end
|
111
110
|
opts = options
|
@@ -140,6 +139,15 @@ connect_proc = lambda do |database|
|
|
140
139
|
end
|
141
140
|
|
142
141
|
begin
|
142
|
+
$:.unshift(File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib')))
|
143
|
+
require 'sequel'
|
144
|
+
if show_version
|
145
|
+
puts "sequel #{Sequel.version}"
|
146
|
+
unless db || code
|
147
|
+
exit
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
143
151
|
DB = connect_proc[db]
|
144
152
|
load_dirs.each{|d| d.is_a?(Array) ? require(d.first) : Dir["#{d}/**/*.rb"].each{|f| load(f)}}
|
145
153
|
if migrate_dir
|
@@ -222,7 +230,7 @@ begin
|
|
222
230
|
end
|
223
231
|
rescue => e
|
224
232
|
raise e if backtrace
|
225
|
-
error_proc["Error: #{e.class}: #{e.message}#{e.backtrace.first}"]
|
233
|
+
error_proc["Error: #{e.class}: #{e.message}\n#{e.backtrace.first}"]
|
226
234
|
end
|
227
235
|
|
228
236
|
if !ARGV.empty?
|
@@ -0,0 +1,169 @@
|
|
1
|
+
= New Features
|
2
|
+
|
3
|
+
* A modification_detection plugin has been added, for automatic
|
4
|
+
detection of in-place column value modifications. This makes
|
5
|
+
it so you don't have to call Model#modified! manually when
|
6
|
+
changing a value in place.
|
7
|
+
|
8
|
+
* A column_select plugin has been added, for automatically
|
9
|
+
selecting explicitly qualified columns in model datasets.
|
10
|
+
Example:
|
11
|
+
|
12
|
+
Sequel::Model.plugin :column_select
|
13
|
+
class Album < Sequel::Model
|
14
|
+
end
|
15
|
+
Album.dataset.sql
|
16
|
+
# SELECT albums.id, albums.name, albums.artist_id
|
17
|
+
# FROM albums
|
18
|
+
|
19
|
+
* An insert_returning_select plugin has been added, for automatically
|
20
|
+
setting up RETURNING clauses for models that select explicit
|
21
|
+
columns. This is useful when using the column_select or
|
22
|
+
lazy_attributes plugins.
|
23
|
+
|
24
|
+
* A pg_enum extension has been added, for easier dealing with
|
25
|
+
PostgreSQL enum types. The possible values for the type
|
26
|
+
are then returned in the schema hashes under the :enum_values
|
27
|
+
key. It also adds create_enum, drop_enum, and add_enum_value
|
28
|
+
Database methods for migration support.
|
29
|
+
|
30
|
+
* A round_timestamps extension has been added, for automatically
|
31
|
+
rounding timestamps to database supported precision when
|
32
|
+
literalizing.
|
33
|
+
|
34
|
+
* A dataset_source_alias extension has been added, for automatically
|
35
|
+
aliasing datasets to their first source, instead of using t1, t2.
|
36
|
+
Example:
|
37
|
+
|
38
|
+
DB.from(:a, DB[:b]).sql
|
39
|
+
# SELECT * FROM a, (SELECT * FROM b) AS t1
|
40
|
+
|
41
|
+
DB.extension(:dataset_source_alias)
|
42
|
+
DB.from(:a, DB[:b]).sql
|
43
|
+
# SELECT * FROM a, (SELECT * FROM b) AS b
|
44
|
+
|
45
|
+
* On Microsoft SQL Server, Sequel now emulates RETURNING support
|
46
|
+
using the OUTPUT clause, as long as only simple column references
|
47
|
+
are used.
|
48
|
+
|
49
|
+
= Other Improvements
|
50
|
+
|
51
|
+
* A regression has been fixed in the timestamps and table
|
52
|
+
inheritance plugins, where column values would not be
|
53
|
+
saved when skipping validations. This was first broken in
|
54
|
+
4.11.0.
|
55
|
+
|
56
|
+
* A regression has been fixed on JRuby and Rubinius when using
|
57
|
+
Sequel::Model(dataset) if the dataset needs to literalize a
|
58
|
+
symbol (and most do). This was first broken in 4.10.0.
|
59
|
+
|
60
|
+
* Primary keys are now automatically setup for models even if
|
61
|
+
the models select specific columns.
|
62
|
+
|
63
|
+
* The lazy_attributes plugin now uses qualified columns in its
|
64
|
+
selection, instead of unqualified columns.
|
65
|
+
|
66
|
+
* When looking up model instances by primary key, Sequel now uses a
|
67
|
+
qualified primary key if the model uses a joined dataset.
|
68
|
+
|
69
|
+
* For associations that require joins, Sequel will now use the
|
70
|
+
associated model's selection directly (instead of
|
71
|
+
associated_table.*) if the associated model's selection consists
|
72
|
+
solely of qualified columns.
|
73
|
+
|
74
|
+
Among other things, this means that a many_to_many association to
|
75
|
+
a model that uses lazy attributes will not eagerly load the lazy
|
76
|
+
attributes by default.
|
77
|
+
|
78
|
+
* Model#save now uses insert_select if there is an existing
|
79
|
+
RETURNING clause used by the underlying dataset, even if the model
|
80
|
+
selects specific columns.
|
81
|
+
|
82
|
+
* In Dataset#insert, aliased tables are now automatically unaliased.
|
83
|
+
This allows you to use a dataset with an aliased table and have
|
84
|
+
full SELECT/INSERT/UPDATE/DELETE support, assuming the database
|
85
|
+
supports aliased tables in UPDATE and DELETE.
|
86
|
+
|
87
|
+
* Dataset#graph now qualifies columns correctly if the current
|
88
|
+
dataset is a joined dataset and it moves the current dataset to
|
89
|
+
a subselect.
|
90
|
+
|
91
|
+
* Dataset#joined_dataset? is now a public method, and can be used to
|
92
|
+
determine whether the dataset uses a join, either explicitly via
|
93
|
+
JOIN or implicitly via multiple FROM tables.
|
94
|
+
|
95
|
+
* The Dataset#unqualified_column_for helper method has been added,
|
96
|
+
returning the unqualified version of a possibly qualified column.
|
97
|
+
|
98
|
+
* The composition and serialization plugins now support validations
|
99
|
+
on the underlying columns. Previously, the didn't update the
|
100
|
+
underlying columns until after validations were performed. This
|
101
|
+
works better when using the auto_validations plugin.
|
102
|
+
|
103
|
+
* The class_table_inheritance plugin now uses JOIN ON instead of
|
104
|
+
JOIN USING, which makes it work on all databases that Sequel
|
105
|
+
supports. Additionally, the plugin now explicitly selects
|
106
|
+
qualified columns from all of the tables.
|
107
|
+
|
108
|
+
* The list plugin now adds an after_destroy hook that will renumber
|
109
|
+
rows after the current row, similar to how moving existing values
|
110
|
+
in the list works.
|
111
|
+
|
112
|
+
* The pg_json extension is now faster when json column value is a
|
113
|
+
plain string, number, true, false, or nil, if the underlying json
|
114
|
+
library handles such values natively.
|
115
|
+
|
116
|
+
* External jdbc, odbc, and do subadapters can now be loaded
|
117
|
+
automatically without requiring them first, assuming proper
|
118
|
+
support in the external subadapter.
|
119
|
+
|
120
|
+
* When using create_table on MySQL, correctly handle the :key
|
121
|
+
option to when calling foreign_key with a column reference.
|
122
|
+
|
123
|
+
* On Oracle, use all_tab_cols instead of user_tab_cols for getting
|
124
|
+
default values when parsing the schema. This makes it work if the
|
125
|
+
user does not own the table.
|
126
|
+
|
127
|
+
* On Oracle, use all_tables and all_views for Database#tables and
|
128
|
+
Database#views. This works better for users with limited rights.
|
129
|
+
|
130
|
+
* Additional disconnect errors are now recognized in the postgres and
|
131
|
+
jdbc/mysql adapters.
|
132
|
+
|
133
|
+
* Sequel::Model now uses copy constructors (e.g. initialize_copy)
|
134
|
+
instead of overriding #dup and #clone.
|
135
|
+
|
136
|
+
* The rake default task now runs plugin specs in addition to
|
137
|
+
core and model specs.
|
138
|
+
|
139
|
+
= bin/sequel Improvements
|
140
|
+
|
141
|
+
* Add the sequel lib directory to the front of the load path
|
142
|
+
instead of the end, fixing cases where you end up requiring an
|
143
|
+
old version of the sequel gem (e.g. by using sequel_pg).
|
144
|
+
|
145
|
+
* Add the sequel lib directory as an absolute path, fixing cases
|
146
|
+
where you later change the current directory.
|
147
|
+
|
148
|
+
* Require sequel later in the code, so that bin/sequel -h doesn't
|
149
|
+
need to require sequel, and full backtrace is not printed if
|
150
|
+
requiring sequel raises an error (unless -t is used).
|
151
|
+
|
152
|
+
* If an exception is raised, put a newline between the exception
|
153
|
+
message and backtrace.
|
154
|
+
|
155
|
+
* Don't allow usage of -C with any of -cdDmS.
|
156
|
+
|
157
|
+
* If sequel -v is given along with a database or code string to
|
158
|
+
execute, print the Sequel version but also continue, similar
|
159
|
+
to how ruby -v works.
|
160
|
+
|
161
|
+
= Backwards Compatibility
|
162
|
+
|
163
|
+
* The switch from JOIN ON to JOIN USING in the
|
164
|
+
class_table_inheritance can break certain usage, such as querying
|
165
|
+
using unqualified primary key. Users should switch to using a
|
166
|
+
qualified primary key instead.
|
167
|
+
|
168
|
+
* Calling Dataset#returning when the underlying database does not
|
169
|
+
support it now raises an Error.
|
data/doc/sql.rdoc
CHANGED
@@ -287,9 +287,9 @@ Sequel also supports the SQL EXISTS operator using <tt>Dataset#exists</tt>:
|
|
287
287
|
|
288
288
|
Hashes in Sequel use IS if the value is true, false, or nil:
|
289
289
|
|
290
|
-
{:column=>nil
|
291
|
-
{:column=>true
|
292
|
-
{:column=>false
|
290
|
+
{:column=>nil} # ("column" IS NULL)
|
291
|
+
{:column=>true} # ("column" IS TRUE)
|
292
|
+
{:column=>false} # ("column" IS FALSE)
|
293
293
|
|
294
294
|
Negation works the same way as it does for equality and inclusion:
|
295
295
|
|
data/lib/sequel/adapters/do.rb
CHANGED
@@ -11,29 +11,17 @@ module Sequel
|
|
11
11
|
# * Sequel.connect('do:postgres://user:password@host/database')
|
12
12
|
# * Sequel.connect('do:mysql://user:password@host/database')
|
13
13
|
module DataObjects
|
14
|
-
# Contains procs keyed on
|
14
|
+
# Contains procs keyed on subadapter type that extend the
|
15
15
|
# given database object so it supports the correct database type.
|
16
|
-
DATABASE_SETUP = {
|
17
|
-
require 'do_postgres'
|
18
|
-
Sequel.require 'adapters/do/postgres'
|
19
|
-
db.extend(Sequel::DataObjects::Postgres::DatabaseMethods)
|
20
|
-
db.extend_datasets Sequel::Postgres::DatasetMethods
|
21
|
-
end,
|
22
|
-
:mysql=>proc do |db|
|
23
|
-
require 'do_mysql'
|
24
|
-
Sequel.require 'adapters/do/mysql'
|
25
|
-
db.extend(Sequel::DataObjects::MySQL::DatabaseMethods)
|
26
|
-
db.dataset_class = Sequel::DataObjects::MySQL::Dataset
|
27
|
-
end,
|
28
|
-
:sqlite3=>proc do |db|
|
29
|
-
require 'do_sqlite3'
|
30
|
-
Sequel.require 'adapters/do/sqlite'
|
31
|
-
db.extend(Sequel::DataObjects::SQLite::DatabaseMethods)
|
32
|
-
db.extend_datasets Sequel::SQLite::DatasetMethods
|
33
|
-
db.set_integer_booleans
|
34
|
-
end
|
35
|
-
}
|
16
|
+
DATABASE_SETUP = {}
|
36
17
|
|
18
|
+
# Wrapper for require that raises AdapterNotFound if driver could not be loaded
|
19
|
+
def self.load_driver(path)
|
20
|
+
require path
|
21
|
+
rescue LoadError => e
|
22
|
+
raise AdapterNotFound, e.message
|
23
|
+
end
|
24
|
+
|
37
25
|
# DataObjects uses it's own internal connection pooling in addition to the
|
38
26
|
# pooling that Sequel uses. You should make sure that you don't set
|
39
27
|
# the connection pool size to more than 8 for a
|
@@ -108,12 +96,12 @@ module Sequel
|
|
108
96
|
private
|
109
97
|
|
110
98
|
# Call the DATABASE_SETUP proc directly after initialization,
|
111
|
-
# so the object always uses
|
99
|
+
# so the object always uses subadapter specific code. Also,
|
112
100
|
# raise an error immediately if the connection doesn't have a
|
113
101
|
# uri, since DataObjects requires one.
|
114
102
|
def adapter_initialize
|
115
103
|
raise(Error, "No connection string specified") unless uri
|
116
|
-
if prok =
|
104
|
+
if prok = Sequel::Database.load_adapter(subadapter.to_sym, :map=>DATABASE_SETUP, :subdir=>'do')
|
117
105
|
prok.call(self)
|
118
106
|
end
|
119
107
|
end
|
@@ -1,7 +1,15 @@
|
|
1
|
+
Sequel::DataObjects.load_driver 'do_mysql'
|
1
2
|
Sequel.require 'adapters/shared/mysql'
|
2
3
|
|
3
4
|
module Sequel
|
4
5
|
module DataObjects
|
6
|
+
Sequel.synchronize do
|
7
|
+
DATABASE_SETUP[:mysql] = proc do |db|
|
8
|
+
db.extend(Sequel::DataObjects::MySQL::DatabaseMethods)
|
9
|
+
db.dataset_class = Sequel::DataObjects::MySQL::Dataset
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
5
13
|
# Database and Dataset instance methods for MySQL specific
|
6
14
|
# support via DataObjects.
|
7
15
|
module MySQL
|
@@ -1,9 +1,17 @@
|
|
1
|
+
Sequel::DataObjects.load_driver 'do_postgres'
|
1
2
|
Sequel.require 'adapters/shared/postgres'
|
2
3
|
|
3
4
|
module Sequel
|
4
5
|
Postgres::CONVERTED_EXCEPTIONS << ::DataObjects::Error
|
5
6
|
|
6
7
|
module DataObjects
|
8
|
+
Sequel.synchronize do
|
9
|
+
DATABASE_SETUP[:postgres] = proc do |db|
|
10
|
+
db.extend(Sequel::DataObjects::Postgres::DatabaseMethods)
|
11
|
+
db.extend_datasets Sequel::Postgres::DatasetMethods
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
7
15
|
# Adapter, Database, and Dataset support for accessing a PostgreSQL
|
8
16
|
# database via DataObjects.
|
9
17
|
module Postgres
|
@@ -1,7 +1,16 @@
|
|
1
|
+
Sequel::DataObjects.load_driver 'do_sqlite3'
|
1
2
|
Sequel.require 'adapters/shared/sqlite'
|
2
3
|
|
3
4
|
module Sequel
|
4
5
|
module DataObjects
|
6
|
+
Sequel.synchronize do
|
7
|
+
DATABASE_SETUP[:sqlite3] = proc do |db|
|
8
|
+
db.extend(Sequel::DataObjects::SQLite::DatabaseMethods)
|
9
|
+
db.extend_datasets Sequel::SQLite::DatasetMethods
|
10
|
+
db.set_integer_booleans
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
5
14
|
# Database and Dataset support for SQLite databases accessed via DataObjects.
|
6
15
|
module SQLite
|
7
16
|
# Instance methods for SQLite Database objects accessed via DataObjects.
|
data/lib/sequel/adapters/jdbc.rb
CHANGED
@@ -27,146 +27,11 @@ module Sequel
|
|
27
27
|
# to :integer.
|
28
28
|
DECIMAL_TYPE_RE = /number|numeric|decimal/io
|
29
29
|
|
30
|
-
# Contains procs keyed on
|
30
|
+
# Contains procs keyed on subadapter type that extend the
|
31
31
|
# given database object so it supports the correct database type.
|
32
|
-
DATABASE_SETUP = {
|
33
|
-
JDBC.load_gem(:Postgres)
|
34
|
-
org.postgresql.Driver
|
35
|
-
Sequel.require 'adapters/jdbc/postgresql'
|
36
|
-
db.extend(Sequel::JDBC::Postgres::DatabaseMethods)
|
37
|
-
db.dataset_class = Sequel::JDBC::Postgres::Dataset
|
38
|
-
org.postgresql.Driver
|
39
|
-
end,
|
40
|
-
:mysql=>proc do |db|
|
41
|
-
JDBC.load_gem(:MySQL)
|
42
|
-
com.mysql.jdbc.Driver
|
43
|
-
Sequel.require 'adapters/jdbc/mysql'
|
44
|
-
db.extend(Sequel::JDBC::MySQL::DatabaseMethods)
|
45
|
-
db.extend_datasets Sequel::MySQL::DatasetMethods
|
46
|
-
com.mysql.jdbc.Driver
|
47
|
-
end,
|
48
|
-
:sqlite=>proc do |db|
|
49
|
-
JDBC.load_gem(:SQLite3)
|
50
|
-
org.sqlite.JDBC
|
51
|
-
Sequel.require 'adapters/jdbc/sqlite'
|
52
|
-
db.extend(Sequel::JDBC::SQLite::DatabaseMethods)
|
53
|
-
db.extend_datasets Sequel::SQLite::DatasetMethods
|
54
|
-
db.set_integer_booleans
|
55
|
-
org.sqlite.JDBC
|
56
|
-
end,
|
57
|
-
:oracle=>proc do |db|
|
58
|
-
Java::oracle.jdbc.driver.OracleDriver
|
59
|
-
Sequel.require 'adapters/jdbc/oracle'
|
60
|
-
db.extend(Sequel::JDBC::Oracle::DatabaseMethods)
|
61
|
-
db.dataset_class = Sequel::JDBC::Oracle::Dataset
|
62
|
-
Java::oracle.jdbc.driver.OracleDriver
|
63
|
-
end,
|
64
|
-
:sqlserver=>proc do |db|
|
65
|
-
com.microsoft.sqlserver.jdbc.SQLServerDriver
|
66
|
-
Sequel.require 'adapters/jdbc/sqlserver'
|
67
|
-
db.extend(Sequel::JDBC::SQLServer::DatabaseMethods)
|
68
|
-
db.extend_datasets Sequel::MSSQL::DatasetMethods
|
69
|
-
db.send(:set_mssql_unicode_strings)
|
70
|
-
com.microsoft.sqlserver.jdbc.SQLServerDriver
|
71
|
-
end,
|
72
|
-
:jtds=>proc do |db|
|
73
|
-
JDBC.load_gem(:JTDS)
|
74
|
-
Java::net.sourceforge.jtds.jdbc.Driver
|
75
|
-
Sequel.require 'adapters/jdbc/jtds'
|
76
|
-
db.extend(Sequel::JDBC::JTDS::DatabaseMethods)
|
77
|
-
db.dataset_class = Sequel::JDBC::JTDS::Dataset
|
78
|
-
db.send(:set_mssql_unicode_strings)
|
79
|
-
Java::net.sourceforge.jtds.jdbc.Driver
|
80
|
-
end,
|
81
|
-
:h2=>proc do |db|
|
82
|
-
JDBC.load_gem(:H2)
|
83
|
-
org.h2.Driver
|
84
|
-
Sequel.require 'adapters/jdbc/h2'
|
85
|
-
db.extend(Sequel::JDBC::H2::DatabaseMethods)
|
86
|
-
db.dataset_class = Sequel::JDBC::H2::Dataset
|
87
|
-
org.h2.Driver
|
88
|
-
end,
|
89
|
-
:hsqldb=>proc do |db|
|
90
|
-
JDBC.load_gem(:HSQLDB)
|
91
|
-
org.hsqldb.jdbcDriver
|
92
|
-
Sequel.require 'adapters/jdbc/hsqldb'
|
93
|
-
db.extend(Sequel::JDBC::HSQLDB::DatabaseMethods)
|
94
|
-
db.dataset_class = Sequel::JDBC::HSQLDB::Dataset
|
95
|
-
org.hsqldb.jdbcDriver
|
96
|
-
end,
|
97
|
-
:derby=>proc do |db|
|
98
|
-
JDBC.load_gem(:Derby)
|
99
|
-
org.apache.derby.jdbc.EmbeddedDriver
|
100
|
-
Sequel.require 'adapters/jdbc/derby'
|
101
|
-
db.extend(Sequel::JDBC::Derby::DatabaseMethods)
|
102
|
-
db.dataset_class = Sequel::JDBC::Derby::Dataset
|
103
|
-
org.apache.derby.jdbc.EmbeddedDriver
|
104
|
-
end,
|
105
|
-
:as400=>proc do |db|
|
106
|
-
com.ibm.as400.access.AS400JDBCDriver
|
107
|
-
Sequel.require 'adapters/jdbc/as400'
|
108
|
-
db.extend(Sequel::JDBC::AS400::DatabaseMethods)
|
109
|
-
db.dataset_class = Sequel::JDBC::AS400::Dataset
|
110
|
-
com.ibm.as400.access.AS400JDBCDriver
|
111
|
-
end,
|
112
|
-
:"informix-sqli"=>proc do |db|
|
113
|
-
com.informix.jdbc.IfxDriver
|
114
|
-
Sequel.require 'adapters/jdbc/informix'
|
115
|
-
db.extend(Sequel::JDBC::Informix::DatabaseMethods)
|
116
|
-
db.extend_datasets Sequel::Informix::DatasetMethods
|
117
|
-
com.informix.jdbc.IfxDriver
|
118
|
-
end,
|
119
|
-
:db2=>proc do |db|
|
120
|
-
com.ibm.db2.jcc.DB2Driver
|
121
|
-
Sequel.require 'adapters/jdbc/db2'
|
122
|
-
db.extend(Sequel::JDBC::DB2::DatabaseMethods)
|
123
|
-
db.dataset_class = Sequel::JDBC::DB2::Dataset
|
124
|
-
com.ibm.db2.jcc.DB2Driver
|
125
|
-
end,
|
126
|
-
:firebirdsql=>proc do |db|
|
127
|
-
org.firebirdsql.jdbc.FBDriver
|
128
|
-
Sequel.require 'adapters/jdbc/firebird'
|
129
|
-
db.extend(Sequel::JDBC::Firebird::DatabaseMethods)
|
130
|
-
db.extend_datasets Sequel::Firebird::DatasetMethods
|
131
|
-
org.firebirdsql.jdbc.FBDriver
|
132
|
-
end,
|
133
|
-
:jdbcprogress=>proc do |db|
|
134
|
-
com.progress.sql.jdbc.JdbcProgressDriver
|
135
|
-
Sequel.require 'adapters/jdbc/progress'
|
136
|
-
db.extend(Sequel::JDBC::Progress::DatabaseMethods)
|
137
|
-
db.extend_datasets Sequel::Progress::DatasetMethods
|
138
|
-
com.progress.sql.jdbc.JdbcProgressDriver
|
139
|
-
end,
|
140
|
-
:cubrid=>proc do |db|
|
141
|
-
Java::cubrid.jdbc.driver.CUBRIDDriver
|
142
|
-
Sequel.require 'adapters/jdbc/cubrid'
|
143
|
-
db.extend(Sequel::JDBC::Cubrid::DatabaseMethods)
|
144
|
-
db.extend_datasets Sequel::Cubrid::DatasetMethods
|
145
|
-
Java::cubrid.jdbc.driver.CUBRIDDriver
|
146
|
-
end,
|
147
|
-
:sqlanywhere=>proc do |db|
|
148
|
-
drv = [
|
149
|
-
lambda{Java::sybase.jdbc4.sqlanywhere.IDriver},
|
150
|
-
lambda{Java::ianywhere.ml.jdbcodbc.jdbc4.IDriver},
|
151
|
-
lambda{Java::sybase.jdbc.sqlanywhere.IDriver},
|
152
|
-
lambda{Java::ianywhere.ml.jdbcodbc.jdbc.IDriver},
|
153
|
-
lambda{Java::com.sybase.jdbc4.jdbc.Sybdriver},
|
154
|
-
lambda{Java::com.sybase.jdbc3.jdbc.Sybdriver}
|
155
|
-
].each do |class_proc|
|
156
|
-
begin
|
157
|
-
break class_proc.call
|
158
|
-
rescue NameError
|
159
|
-
end
|
160
|
-
end
|
161
|
-
Sequel.require 'adapters/jdbc/sqlanywhere'
|
162
|
-
db.extend(Sequel::JDBC::SqlAnywhere::DatabaseMethods)
|
163
|
-
db.dataset_class = Sequel::JDBC::SqlAnywhere::Dataset
|
164
|
-
drv
|
165
|
-
end
|
166
|
-
}
|
32
|
+
DATABASE_SETUP = {}
|
167
33
|
|
168
|
-
#
|
169
|
-
# works for PostgreSQL, MySQL, and SQLite.
|
34
|
+
# Allow loading the necessary JDBC support via a gem.
|
170
35
|
def self.load_gem(name)
|
171
36
|
begin
|
172
37
|
require "jdbc/#{name.to_s.downcase}"
|
@@ -180,6 +45,18 @@ module Sequel
|
|
180
45
|
end
|
181
46
|
end
|
182
47
|
|
48
|
+
# Attempt to load the JDBC driver class, which should be specified as a string
|
49
|
+
# containing the driver class name (which JRuby should autoload).
|
50
|
+
# Note that the string is evaled, so this method is not safe to call with
|
51
|
+
# untrusted input.
|
52
|
+
# Raise a Sequel::AdapterNotFound if evaluating the class name raises a NameError.
|
53
|
+
def self.load_driver(drv, gem=nil)
|
54
|
+
load_gem(gem) if gem
|
55
|
+
eval drv
|
56
|
+
rescue NameError
|
57
|
+
raise Sequel::AdapterNotFound, "#{drv} not loaded#{", try installing jdbc-#{gem.to_s.downcase} gem" if gem}"
|
58
|
+
end
|
59
|
+
|
183
60
|
class TypeConvertor
|
184
61
|
%w'Boolean Float Double Int Long Short'.each do |meth|
|
185
62
|
class_eval("def #{meth}(r, i) v = r.get#{meth}(i); v unless r.wasNull end", __FILE__, __LINE__)
|
@@ -473,7 +350,7 @@ module Sequel
|
|
473
350
|
|
474
351
|
resolved_uri = jndi? ? get_uri_from_jndi : uri
|
475
352
|
|
476
|
-
@driver = if (match = /\Ajdbc:([^:]+)/.match(resolved_uri)) && (prok =
|
353
|
+
@driver = if (match = /\Ajdbc:([^:]+)/.match(resolved_uri)) && (prok = Sequel::Database.load_adapter(match[1].to_sym, :map=>DATABASE_SETUP, :subdir=>'jdbc'))
|
477
354
|
prok.call(self)
|
478
355
|
else
|
479
356
|
@opts[:driver]
|