sequel 5.22.0 → 5.26.0
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.
- checksums.yaml +4 -4
- data/CHANGELOG +66 -0
- data/README.rdoc +1 -1
- data/doc/dataset_filtering.rdoc +15 -0
- data/doc/opening_databases.rdoc +3 -0
- data/doc/postgresql.rdoc +2 -2
- data/doc/release_notes/5.23.0.txt +56 -0
- data/doc/release_notes/5.24.0.txt +56 -0
- data/doc/release_notes/5.25.0.txt +32 -0
- data/doc/release_notes/5.26.0.txt +35 -0
- data/doc/testing.rdoc +1 -0
- data/lib/sequel/adapters/jdbc.rb +7 -1
- data/lib/sequel/adapters/jdbc/postgresql.rb +1 -13
- data/lib/sequel/adapters/jdbc/sqlite.rb +29 -0
- data/lib/sequel/adapters/mysql2.rb +0 -1
- data/lib/sequel/adapters/shared/mssql.rb +9 -8
- data/lib/sequel/adapters/shared/postgres.rb +25 -7
- data/lib/sequel/adapters/shared/sqlite.rb +16 -2
- data/lib/sequel/adapters/tinytds.rb +12 -0
- data/lib/sequel/adapters/utils/mysql_mysql2.rb +1 -1
- data/lib/sequel/database/logging.rb +7 -1
- data/lib/sequel/database/schema_generator.rb +11 -2
- data/lib/sequel/database/schema_methods.rb +2 -0
- data/lib/sequel/dataset/actions.rb +3 -2
- data/lib/sequel/extensions/named_timezones.rb +51 -9
- data/lib/sequel/extensions/pg_array.rb +4 -0
- data/lib/sequel/extensions/pg_json.rb +88 -17
- data/lib/sequel/extensions/pg_json_ops.rb +124 -0
- data/lib/sequel/extensions/pg_range.rb +9 -0
- data/lib/sequel/extensions/pg_row.rb +3 -1
- data/lib/sequel/extensions/sql_comments.rb +2 -2
- data/lib/sequel/model/base.rb +12 -5
- data/lib/sequel/plugins/association_multi_add_remove.rb +83 -0
- data/lib/sequel/plugins/association_proxies.rb +3 -2
- data/lib/sequel/plugins/caching.rb +3 -0
- data/lib/sequel/plugins/class_table_inheritance.rb +10 -0
- data/lib/sequel/plugins/csv_serializer.rb +26 -9
- data/lib/sequel/plugins/dirty.rb +3 -9
- data/lib/sequel/plugins/insert_conflict.rb +72 -0
- data/lib/sequel/plugins/nested_attributes.rb +7 -0
- data/lib/sequel/plugins/pg_auto_constraint_validations.rb +89 -30
- data/lib/sequel/plugins/sharding.rb +11 -5
- data/lib/sequel/plugins/static_cache.rb +8 -3
- data/lib/sequel/plugins/static_cache_cache.rb +53 -0
- data/lib/sequel/plugins/typecast_on_load.rb +3 -2
- data/lib/sequel/sql.rb +3 -1
- data/lib/sequel/timezones.rb +50 -11
- data/lib/sequel/version.rb +1 -1
- data/spec/adapters/postgres_spec.rb +130 -0
- data/spec/bin_spec.rb +2 -2
- data/spec/core/database_spec.rb +50 -0
- data/spec/core/dataset_spec.rb +23 -1
- data/spec/core/expression_filters_spec.rb +7 -2
- data/spec/core/schema_spec.rb +18 -0
- data/spec/core/spec_helper.rb +1 -1
- data/spec/core_extensions_spec.rb +1 -1
- data/spec/extensions/association_multi_add_remove_spec.rb +1041 -0
- data/spec/extensions/dirty_spec.rb +33 -0
- data/spec/extensions/insert_conflict_spec.rb +103 -0
- data/spec/extensions/named_timezones_spec.rb +109 -2
- data/spec/extensions/nested_attributes_spec.rb +48 -0
- data/spec/extensions/pg_auto_constraint_validations_spec.rb +37 -0
- data/spec/extensions/pg_json_ops_spec.rb +67 -0
- data/spec/extensions/pg_json_spec.rb +12 -0
- data/spec/extensions/pg_range_spec.rb +19 -2
- data/spec/extensions/sharding_spec.rb +8 -0
- data/spec/extensions/spec_helper.rb +9 -2
- data/spec/extensions/static_cache_cache_spec.rb +35 -0
- data/spec/guards_helper.rb +1 -1
- data/spec/integration/plugin_test.rb +27 -0
- data/spec/integration/schema_test.rb +16 -2
- data/spec/model/spec_helper.rb +1 -1
- metadata +30 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8c7e9baac1a3a326ffdc2506dde798441b376fecbe71594cd91efb54bc56a9a7
|
4
|
+
data.tar.gz: d051640fc5fb89053beaa43915eca9920222d7978be91bc704cde94f1b425532
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0e424392185dec97acca2092fb5b3127a6619033dd62eef683f29501ece0ecacd17ada2a2b1edf27682155c6d59633fa88a475dd1ebf4bdbf8f1641f73a566a8
|
7
|
+
data.tar.gz: 8c1ac728b94de7b5f0cf9a3df230f35732906accea64a0b61b6eba90203e49396eacc95786ad7a78bc56b3b812cda8bd94d4e8f1d0be188b9d9ae4f49792a9de
|
data/CHANGELOG
CHANGED
@@ -1,3 +1,69 @@
|
|
1
|
+
=== 5.26.0 (2019-11-01)
|
2
|
+
|
3
|
+
* Recognize two additional foreign key constraint violation codes on MySQL 8.0.13+ (rianmcguire) (#1657)
|
4
|
+
|
5
|
+
* Support table aliases for single-table INSERT statements on PostgreSQL 9.5+ (jeremyevans) (#1656)
|
6
|
+
|
7
|
+
* Implement Sequel::Postgres::PGRange#hash so instances work correctly in hashes (jeremyevans) (#1648)
|
8
|
+
|
9
|
+
* Make dirty plugin work correctly with typecast_on_load plugin (jeremyevans) (#1647)
|
10
|
+
|
11
|
+
* Add support for :require_modification option when setting up nested_attributes (jeremyevans)
|
12
|
+
|
13
|
+
* Add support for SQL/JSON path expressions to the pg_json_ops extension, supported by PostgreSQL 12+ (jeremyevans)
|
14
|
+
|
15
|
+
=== 5.25.0 (2019-10-01)
|
16
|
+
|
17
|
+
* Fix Sequel::SQL::NumericMethods#coerce to not raise NoMethodError if super method is not defined (jeremyevans) (#1645)
|
18
|
+
|
19
|
+
* Allow setting a default for a column that already has a default on Microsoft SQL Server (jeremyevans)
|
20
|
+
|
21
|
+
* Fix keyword argument separation warnings on Ruby master branch in csv_serializer plugin (jeremyevans)
|
22
|
+
|
23
|
+
* Add association_multi_add_remove plugin for adding/removing multiple associated objects in a single method call (AlexWayfer, jeremyevans) (#1641, #1643)
|
24
|
+
|
25
|
+
* Make sharding plugin integrate with server_block extension (jeremyevans)
|
26
|
+
|
27
|
+
=== 5.24.0 (2019-09-01)
|
28
|
+
|
29
|
+
* Add Database#skip_logging? private method designed for extensions to force query timing even if no logger is present (adam12) (#1640)
|
30
|
+
|
31
|
+
* Allow a hostname specified in a defaults_file in the mysql2 adapter, by not explicitly setting :host (sapio-bdeamer) (#1638)
|
32
|
+
|
33
|
+
* Convert all database array types to Ruby arrays in the jdbc adapter (jeremyevans)
|
34
|
+
|
35
|
+
* Add static_cache_cache plugin for caching rows for static_cache models to a file to avoid database queries during model initialization (jeremyevans)
|
36
|
+
|
37
|
+
* Add :cache_file plugin option to pg_auto_constraint_validations plugin, for caching metadata to a file for faster initialization (jeremyevans)
|
38
|
+
|
39
|
+
* Support :unique_deferrable and :primary_key_deferrable column options (jeremyevans)
|
40
|
+
|
41
|
+
* Support :generated_always_as column option on PostgreSQL 12+ (jeremyevans)
|
42
|
+
|
43
|
+
=== 5.23.0 (2019-08-01)
|
44
|
+
|
45
|
+
* Work around a bug on jdbc-sqlite3 3.27.2.1 when parsing schema for tables with columns with default values (jeremyevans)
|
46
|
+
|
47
|
+
* Work around a bug in jdbc-sqlite3 3.27.2.1 when in Database#foreign_key_list in the jdbc/sqlite3 adapter (jeremyevans)
|
48
|
+
|
49
|
+
* Make Dataset#execute* private methods respect explicit servers option, fixing Dataset#paged_each in the postgres adapter when sharding (jeremyevans) (#1632)
|
50
|
+
|
51
|
+
* Handle instances of subclasses of core classes when wrapping objects in the pg_json extension (jeremyevans) (#1631)
|
52
|
+
|
53
|
+
* Support :ansi Database option in the tinytds adapter (kenaniah) (#1629)
|
54
|
+
|
55
|
+
* Support cross-database and linked servers when parsing schema on Microsoft SQL Server (kenaniah) (#1629)
|
56
|
+
|
57
|
+
* Add insert_conflict plugin for automatically handling unique constraint conflicts when saving new model instances on PostgreSQL 9.5+ and SQLite 3.24.0+ (jeremyevans)
|
58
|
+
|
59
|
+
* Avoid errors when parsing schema in the mock sqlite adapter (jeremyevans)
|
60
|
+
|
61
|
+
* Avoid possible thread-safety issue in the timezones support (jeremyevans)
|
62
|
+
|
63
|
+
* Handle offsets when typecasting an array or hash to datetime when Sequel.datetime_class = Time (jeremyevans)
|
64
|
+
|
65
|
+
* Support Sequel.datetime_class = Time when using the named_timezones extension (jeremyevans)
|
66
|
+
|
1
67
|
=== 5.22.0 (2019-07-01)
|
2
68
|
|
3
69
|
* Fix Dataset#multi_insert and #import with return: :primary_key on MSSQL when the dataset has a row_proc (jeremyevans) (#1627)
|
data/README.rdoc
CHANGED
@@ -578,7 +578,7 @@ A single model instance can also be fetched by specifying a condition:
|
|
578
578
|
post = Post.first(title: 'hello world')
|
579
579
|
post = Post.first{num_comments < 10}
|
580
580
|
|
581
|
-
The dataset for a model class returns rows
|
581
|
+
The dataset for a model class returns rows of model instances instead of plain hashes:
|
582
582
|
|
583
583
|
DB[:posts].first.class # => Hash
|
584
584
|
Post.first.class # => Post
|
data/doc/dataset_filtering.rdoc
CHANGED
@@ -106,6 +106,21 @@ You can also use placeholders with :placeholder and a hash of placeholder values
|
|
106
106
|
items.where(Sequel.lit('category = :category', category: "ruby")).sql
|
107
107
|
# "SELECT * FROM items WHERE category = 'ruby'"
|
108
108
|
|
109
|
+
In order to combine AND and OR together, you have a few options:
|
110
|
+
|
111
|
+
items.where(category: nil).or(category: "ruby")
|
112
|
+
# SELECT * FROM items WHERE (category IS NULL) OR (category = 'ruby')
|
113
|
+
|
114
|
+
This won't work if you add other conditions:
|
115
|
+
|
116
|
+
items.where(name: "Programming in Ruby").where(category: nil).or(category: 'ruby')
|
117
|
+
# SELECT * FROM items WHERE ((name = 'Programming in Ruby') AND (category IS NULL)) OR (category = 'ruby')
|
118
|
+
|
119
|
+
The OR applies globally and not locally. To fix this, use & and |:
|
120
|
+
|
121
|
+
items.where(Sequel[name: "Programming in Ruby"] & (Sequel[category: nil] | Sequel[category: "ruby"]))
|
122
|
+
# SELECT * FROM items WHERE ((name = 'Programming in Ruby') AND ((category IS NULL) OR (category = 'ruby')))
|
123
|
+
|
109
124
|
=== Specifying SQL functions
|
110
125
|
|
111
126
|
Sequel also allows you to specify functions by using the Sequel.function method:
|
data/doc/opening_databases.rdoc
CHANGED
@@ -401,6 +401,9 @@ options that you may want to set are :login_timeout, :timeout, :tds_version, :az
|
|
401
401
|
|
402
402
|
Other Sequel specific options:
|
403
403
|
|
404
|
+
:ansi :: Set to true to enable the ANSI compatibility settings when connecting
|
405
|
+
(ANSI_NULLS, ANSI_PADDING, ANSI_WARNINGS, ANSI_NULL_DFLT_ON, QUOTED_IDENTIFIER,
|
406
|
+
CONCAT_NULL_YIELDS_NULL).
|
404
407
|
:server_version :: Override the server version to use (9000000 = SQL Server 2005).
|
405
408
|
This also works on any other adapter that connects to Microsoft
|
406
409
|
SQL Server.
|
data/doc/postgresql.rdoc
CHANGED
@@ -341,12 +341,12 @@ Dataset#overriding_system_value and Dataset#overriding_user_value to use this ne
|
|
341
341
|
syntax:
|
342
342
|
|
343
343
|
DB.create_table(:table){primary_key :id}
|
344
|
-
# Ignore the given value for id, using the identity's sequence value
|
344
|
+
# Ignore the given value for id, using the identity's sequence value.
|
345
345
|
DB[:table].overriding_user_value.insert(:id=>1)
|
346
346
|
|
347
347
|
DB.create_table(:table){primary_key :id, :identity=>:always}
|
348
348
|
# Force the use of the given value for id, because otherwise the insert will
|
349
|
-
# raise an error, since GENERATED ALWAYS was
|
349
|
+
# raise an error, since GENERATED ALWAYS was used when creating the column.
|
350
350
|
DB[:table].overriding_system_value.insert(:id=>1)
|
351
351
|
|
352
352
|
=== Distinct On Specific Columns
|
@@ -0,0 +1,56 @@
|
|
1
|
+
= New Features
|
2
|
+
|
3
|
+
* An insert_conflict plugin has been added for automatically handling
|
4
|
+
constraint conflicts when saving new model instances. It is
|
5
|
+
supported on PostgreSQL 9.5+ and SQLite 3.24.0+.
|
6
|
+
|
7
|
+
Album.new(name: 'Foo', copies_sold: 1000).
|
8
|
+
insert_conflict(
|
9
|
+
target: :name,
|
10
|
+
update: {copies_sold: Sequel[:excluded][:b]}
|
11
|
+
).
|
12
|
+
save
|
13
|
+
|
14
|
+
* On Microsoft SQL Server, the Database :ansi option has been added,
|
15
|
+
which sets the following ANSI related options:
|
16
|
+
|
17
|
+
* ANSI_NULLS
|
18
|
+
* ANSI_PADDING
|
19
|
+
* ANSI_WARNINGS
|
20
|
+
* ANSI_NULL_DFLT_ON
|
21
|
+
* QUOTED_IDENTIFIER
|
22
|
+
* CONCAT_NULL_YIELDS_NULL
|
23
|
+
|
24
|
+
= Other Improvements
|
25
|
+
|
26
|
+
* Sequel.datetime_class = Time is now supported when using the
|
27
|
+
named_timezones extension. For backwards compatibility, the
|
28
|
+
named_timezones extension still sets
|
29
|
+
Sequel.datetime_class = DateTime. When using Ruby 2.6+, the
|
30
|
+
Time instances have the timezone set on them using Ruby 2.6+'s
|
31
|
+
timezone support, but basic support works correctly in earlier
|
32
|
+
versions of Ruby.
|
33
|
+
|
34
|
+
* On Microsoft SQL Server, Sequel now handles parsing schema for
|
35
|
+
tables in another database on the same server or in a database
|
36
|
+
on a linked server.
|
37
|
+
|
38
|
+
* The pg_json extension now correctly handles subclasses of core
|
39
|
+
classes when wrapping objects. This stopped working in Sequel
|
40
|
+
5.21.0, when support for wrapping JSON primitives was added.
|
41
|
+
|
42
|
+
* Sequel now works around a couple bugs in jdbc-sqlite 3.27.2.1,
|
43
|
+
allowing schema parsing and foreign key parsing to work.
|
44
|
+
|
45
|
+
* Dataset#execute* private methods now respect an explicitly given
|
46
|
+
:server option, fixing Dataset#paged_each in the postgres adapter
|
47
|
+
when using sharding.
|
48
|
+
|
49
|
+
* Timezone offsets are now handled correctly when typecasting an array
|
50
|
+
or hash to datetime when Sequel.datetime_class = Time.
|
51
|
+
|
52
|
+
* Sequel now avoids errors when parsing schema when using the mock
|
53
|
+
SQLite adapter.
|
54
|
+
|
55
|
+
* A minor thread-safety issue has been fixed in the named_timezones
|
56
|
+
extension.
|
@@ -0,0 +1,56 @@
|
|
1
|
+
= New Features
|
2
|
+
|
3
|
+
* A :cache_file plugin option has been added to the
|
4
|
+
pg_auto_constraint_validations plugin. This option specifies
|
5
|
+
a file to use to cache the metadata the plugin uses, so the
|
6
|
+
plugin does not need to run 5 queries per model at startup to
|
7
|
+
load the metadata. This can dramatically improve startup time
|
8
|
+
when using the plugin with a large number of models.
|
9
|
+
|
10
|
+
To create the metadata file, load the plugin into Sequel::Model
|
11
|
+
(or whatever class you are using as the base class for your
|
12
|
+
model classes) with the :cache_file option, and after loading
|
13
|
+
all of the subclasses of that class, run:
|
14
|
+
|
15
|
+
Sequel::Model.dump_pg_auto_constraint_validations_cache
|
16
|
+
|
17
|
+
As when using the schema_caching and index_caching extensions,
|
18
|
+
it is up to the user to ensure that the cached metadata matches
|
19
|
+
the current database schema. Sequel does no checking of this,
|
20
|
+
as checking would take more time, and the point of this plugin
|
21
|
+
is to improve startup performance.
|
22
|
+
|
23
|
+
* A static_cache_cache plugin has been added. This plugin allows
|
24
|
+
for caching rows for models using the static_cache plugin. This
|
25
|
+
prevents the need to issue a query at model creation time to
|
26
|
+
get the rows. This plugin should be loaded into Sequel::Model
|
27
|
+
(or whatever class you are using as the base class for your
|
28
|
+
model classes) before loading the models using the static_cache
|
29
|
+
plugin. To create the metadata file, after all subclasses of
|
30
|
+
that class have been loaded, run:
|
31
|
+
|
32
|
+
Sequel::Model.dump_static_cache_cache
|
33
|
+
|
34
|
+
* :unique_deferrable and :primary_key_deferrable column
|
35
|
+
options are now supported on PostgreSQL 9+ and Oracle. This
|
36
|
+
allows you to created deferrable unique and primary key
|
37
|
+
column constraints. You could already create deferrable
|
38
|
+
table constraints using the :deferrable option to the primary_key
|
39
|
+
and unique methods.
|
40
|
+
|
41
|
+
* A :generated_always_as column option is now supported on
|
42
|
+
PostgreSQL 12+, for creating generated columns.
|
43
|
+
|
44
|
+
* A Database#skip_logging? private method has been added. This
|
45
|
+
is designed for use in extensions, to force log timing even
|
46
|
+
when no loggers are configured.
|
47
|
+
|
48
|
+
= Other Improvements
|
49
|
+
|
50
|
+
* Sequel no longer sets the :host option to localhost by default
|
51
|
+
in the mysql2 adapter. This prevents Sequel from overriding
|
52
|
+
a host specified in the defaults_file.
|
53
|
+
|
54
|
+
* All database array types are converted to Ruby arrays in the
|
55
|
+
jdbc adapter. Previously, this was only done in the
|
56
|
+
jdbc/postgresql subadapter.
|
@@ -0,0 +1,32 @@
|
|
1
|
+
= New Features
|
2
|
+
|
3
|
+
* An association_multi_add_remove plugin has been added. This plugin
|
4
|
+
adds a shortcut for adding or removing multiple associated objects
|
5
|
+
in a single method call:
|
6
|
+
|
7
|
+
Artist.plugin :association_multi_add_remove
|
8
|
+
Artist.many_to_one :albums
|
9
|
+
Artist[1].add_albums([Album[2], Album[3]])
|
10
|
+
Artist[1].remove_albums([Album[4], Album[5]])
|
11
|
+
|
12
|
+
It also offers a setter method, which will add and remove associated
|
13
|
+
objects as necessary:
|
14
|
+
|
15
|
+
Artist[1].albums = [Album[3], Album[4]]
|
16
|
+
|
17
|
+
= Other Improvements
|
18
|
+
|
19
|
+
* The sharding plugin now integrates with the server_block extension.
|
20
|
+
This makes it so if you retrieve a model instance inside a
|
21
|
+
with_server block, saving the model instance will save it back to
|
22
|
+
the shard from which it was retrieved.
|
23
|
+
|
24
|
+
* Setting a default for a column on Microsoft SQL Server now works
|
25
|
+
correctly if the column already has a default.
|
26
|
+
|
27
|
+
* Sequel::SQL::NumericMethods#coerce no longer raises NoMethodError
|
28
|
+
if the super method is not defined. This fixes some cases when
|
29
|
+
comparing Date/DateTime instances to Sequel objects.
|
30
|
+
|
31
|
+
* The csv_serializer plugin now avoids keyword argument separation
|
32
|
+
issues on Ruby 2.7+.
|
@@ -0,0 +1,35 @@
|
|
1
|
+
= New Features
|
2
|
+
|
3
|
+
* Support for SQL/JSON path expressions has been added to the
|
4
|
+
pg_json_ops extension. These are supported in PostgreSQL 12+.
|
5
|
+
Examples:
|
6
|
+
|
7
|
+
j = Sequel.pg_json_op(:json_column)
|
8
|
+
j.path_exists('$.foo') # (jsonb_column @? '$.foo')
|
9
|
+
j.path_match('$.foo') # (jsonb_column @@ '$.foo')
|
10
|
+
j.path_exists!('$.foo') # jsonb_path_exists(jsonb_column, '$.foo')
|
11
|
+
j.path_match!('$.foo') # jsonb_path_match(jsonb_column, '$.foo')
|
12
|
+
j.path_query('$.foo') # jsonb_path_query(jsonb_column, '$.foo')
|
13
|
+
j.path_query_array('$.foo') # jsonb_path_query_array(jsonb_column, '$.foo')
|
14
|
+
j.path_query_first('$.foo') # jsonb_path_query_first(jsonb_column, '$.foo')
|
15
|
+
|
16
|
+
* The nested_attributes method in the nested_attributes plugin now
|
17
|
+
supports a :require_modification option, which can override the
|
18
|
+
default require_modification setting for the nested objects. This
|
19
|
+
can be useful to avoid errors if multiple requests are submitted
|
20
|
+
simultaneously to delete the same nested row.
|
21
|
+
|
22
|
+
= Other Improvements
|
23
|
+
|
24
|
+
* The dirty plugin now works correctly with the typecast_on_load
|
25
|
+
plugin.
|
26
|
+
|
27
|
+
* Sequel::Postgres::PGRange#hash has been added to the pg_range
|
28
|
+
extension, allowing PGRange instances to be usable as hash keys.
|
29
|
+
|
30
|
+
* Table aliases are now supported for single table INSERT
|
31
|
+
statements on PostgreSQL 9.5+, which can make some insert_conflict
|
32
|
+
usage easier.
|
33
|
+
|
34
|
+
* Two more foreign key constraint violation types are now recognized
|
35
|
+
on MySQL 8.0.13+.
|
data/doc/testing.rdoc
CHANGED
@@ -169,3 +169,4 @@ SEQUEL_NO_PENDING :: Don't skip any specs, try running all specs (note, can caus
|
|
169
169
|
SEQUEL_PG_TIMESTAMPTZ :: Use the pg_timestamptz extension when running the postgres specs
|
170
170
|
SEQUEL_SPLIT_SYMBOLS :: Turn on symbol splitting when running the adapter and integration specs
|
171
171
|
SEQUEL_SYNCHRONIZE_SQL :: Use the synchronize_sql extension when running the specs
|
172
|
+
SEQUEL_TZINFO_VERSION :: Force the given tzinfo version when running the specs (e.g. '>=2')
|
data/lib/sequel/adapters/jdbc.rb
CHANGED
@@ -102,12 +102,17 @@ module Sequel
|
|
102
102
|
v.getSubString(1, v.length)
|
103
103
|
end
|
104
104
|
end
|
105
|
+
x = convertors[:RubyArray] = Object.new
|
106
|
+
def x.call(r, i)
|
107
|
+
if v = r.getArray(i)
|
108
|
+
v.array.to_ary
|
109
|
+
end
|
110
|
+
end
|
105
111
|
|
106
112
|
MAP = Hash.new(convertors[:Object])
|
107
113
|
types = Java::JavaSQL::Types
|
108
114
|
|
109
115
|
{
|
110
|
-
:ARRAY => :Array,
|
111
116
|
:BOOLEAN => :Boolean,
|
112
117
|
:CHAR => :String,
|
113
118
|
:DOUBLE => :Double,
|
@@ -126,6 +131,7 @@ module Sequel
|
|
126
131
|
BASIC_MAP = MAP.dup
|
127
132
|
|
128
133
|
{
|
134
|
+
:ARRAY => :Array,
|
129
135
|
:BINARY => :Blob,
|
130
136
|
:BLOB => :Blob,
|
131
137
|
:CLOB => :Clob,
|
@@ -195,17 +195,7 @@ module Sequel
|
|
195
195
|
|
196
196
|
STRING_TYPE = Java::JavaSQL::Types::VARCHAR
|
197
197
|
ARRAY_TYPE = Java::JavaSQL::Types::ARRAY
|
198
|
-
PG_SPECIFIC_TYPES = [
|
199
|
-
|
200
|
-
# Return PostgreSQL array types as ruby Arrays instead of
|
201
|
-
# JDBC PostgreSQL driver-specific array type. Only used if the
|
202
|
-
# database does not have a conversion proc for the type.
|
203
|
-
ARRAY_METHOD = Object.new
|
204
|
-
def ARRAY_METHOD.call(r, i)
|
205
|
-
if v = r.getArray(i)
|
206
|
-
v.array.to_ary
|
207
|
-
end
|
208
|
-
end
|
198
|
+
PG_SPECIFIC_TYPES = [Java::JavaSQL::Types::ARRAY, Java::JavaSQL::Types::OTHER, Java::JavaSQL::Types::STRUCT, Java::JavaSQL::Types::TIME_WITH_TIMEZONE, Java::JavaSQL::Types::TIME].freeze
|
209
199
|
|
210
200
|
# Return PostgreSQL hstore types as ruby Hashes instead of
|
211
201
|
# Java HashMaps. Only used if the database does not have a
|
@@ -223,8 +213,6 @@ module Sequel
|
|
223
213
|
oid = meta.getField(i).getOID
|
224
214
|
if pr = db.oid_convertor_proc(oid)
|
225
215
|
pr
|
226
|
-
elsif type == ARRAY_TYPE
|
227
|
-
ARRAY_METHOD
|
228
216
|
elsif oid == 2950 # UUID
|
229
217
|
map[STRING_TYPE]
|
230
218
|
elsif meta.getPGType(i) == 'hstore'
|
@@ -15,6 +15,24 @@ module Sequel
|
|
15
15
|
end
|
16
16
|
|
17
17
|
module SQLite
|
18
|
+
module ForeignKeyListPragmaConvertorFix
|
19
|
+
# For the use of the convertor for String, working around a bug
|
20
|
+
# in jdbc-sqlite3 that reports fields are of type
|
21
|
+
# java.sql.types.NUMERIC even though they contain non-numeric data.
|
22
|
+
def type_convertor(_, _, _, i)
|
23
|
+
i > 2 ? TypeConvertor::CONVERTORS[:String] : super
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
module TableInfoPragmaConvertorFix
|
28
|
+
# For the use of the convertor for String, working around a bug
|
29
|
+
# in jdbc-sqlite3 that reports dflt_value field is of type
|
30
|
+
# java.sql.types.NUMERIC even though they contain string data.
|
31
|
+
def type_convertor(_, _, _, i)
|
32
|
+
i == 5 ? TypeConvertor::CONVERTORS[:String] : super
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
18
36
|
module DatabaseMethods
|
19
37
|
include Sequel::SQLite::DatabaseMethods
|
20
38
|
|
@@ -37,6 +55,17 @@ module Sequel
|
|
37
55
|
end
|
38
56
|
|
39
57
|
private
|
58
|
+
|
59
|
+
|
60
|
+
# Add workaround for bug when running foreign_key_list pragma
|
61
|
+
def _foreign_key_list_ds(_)
|
62
|
+
super.with_extend(ForeignKeyListPragmaConvertorFix)
|
63
|
+
end
|
64
|
+
|
65
|
+
# Add workaround for bug when running table_info pragma
|
66
|
+
def _parse_pragma_ds(_, _)
|
67
|
+
super.with_extend(TableInfoPragmaConvertorFix)
|
68
|
+
end
|
40
69
|
|
41
70
|
DATABASE_ERROR_REGEXPS = Sequel::SQLite::DatabaseMethods::DATABASE_ERROR_REGEXPS.merge(/Abort due to constraint violation/ => ConstraintViolation).freeze
|
42
71
|
def database_error_regexps
|
@@ -36,7 +36,6 @@ module Sequel
|
|
36
36
|
# options such as :local_infile.
|
37
37
|
def connect(server)
|
38
38
|
opts = server_opts(server)
|
39
|
-
opts[:host] ||= 'localhost'
|
40
39
|
opts[:username] ||= opts.delete(:user)
|
41
40
|
opts[:flags] ||= 0
|
42
41
|
opts[:flags] |= ::Mysql2::Client::FOUND_ROWS if ::Mysql2::Client.const_defined?(:FOUND_ROWS)
|
@@ -279,7 +279,7 @@ module Sequel
|
|
279
279
|
end
|
280
280
|
end
|
281
281
|
sqls << "ALTER TABLE #{quote_schema_table(table)} ALTER COLUMN #{column_definition_sql(op)}"
|
282
|
-
sqls << alter_table_sql(table, op.merge(:op=>:set_column_default, :default=>default)) if default
|
282
|
+
sqls << alter_table_sql(table, op.merge(:op=>:set_column_default, :default=>default, :skip_drop_default=>true)) if default
|
283
283
|
sqls
|
284
284
|
when :set_column_null
|
285
285
|
sch = schema(table).find{|k,v| k.to_s == op[:name].to_s}.last
|
@@ -290,7 +290,9 @@ module Sequel
|
|
290
290
|
end
|
291
291
|
"ALTER TABLE #{quote_schema_table(table)} ALTER COLUMN #{quote_identifier(op[:name])} #{type_literal(:type=>type)} #{'NOT ' unless op[:null]}NULL"
|
292
292
|
when :set_column_default
|
293
|
-
|
293
|
+
sqls = []
|
294
|
+
add_drop_default_constraint_sql(sqls, table, op[:name]) unless op[:skip_drop_default]
|
295
|
+
sqls << "ALTER TABLE #{quote_schema_table(table)} ADD CONSTRAINT #{quote_identifier("sequel_#{table}_#{op[:name]}_def")} DEFAULT #{literal(op[:default])} FOR #{quote_identifier(op[:name])}"
|
294
296
|
else
|
295
297
|
super(table, op)
|
296
298
|
end
|
@@ -427,20 +429,19 @@ module Sequel
|
|
427
429
|
m = output_identifier_meth(opts[:dataset])
|
428
430
|
m2 = input_identifier_meth(opts[:dataset])
|
429
431
|
tn = m2.call(table_name.to_s)
|
430
|
-
table_id = get(Sequel.function(:object_id, tn))
|
431
432
|
info_sch_sch = opts[:information_schema_schema]
|
432
433
|
inf_sch_qual = lambda{|s| info_sch_sch ? Sequel.qualify(info_sch_sch, s) : Sequel[s]}
|
433
|
-
|
434
|
+
table_id = metadata_dataset.from(inf_sch_qual.call(Sequel[:sys][:objects])).where(:name => tn).select_map(:object_id).first
|
434
435
|
|
435
|
-
identity_cols = metadata_dataset.from(
|
436
|
+
identity_cols = metadata_dataset.from(inf_sch_qual.call(Sequel[:sys][:columns])).
|
436
437
|
where(:object_id=>table_id, :is_identity=>true).
|
437
438
|
select_map(:name)
|
438
439
|
|
439
|
-
pk_index_id = metadata_dataset.from(
|
440
|
+
pk_index_id = metadata_dataset.from(inf_sch_qual.call(Sequel[:sys][:sysindexes])).
|
440
441
|
where(:id=>table_id, :indid=>1..254){{(status & 2048)=>2048}}.
|
441
442
|
get(:indid)
|
442
|
-
pk_cols = metadata_dataset.from(
|
443
|
-
join(
|
443
|
+
pk_cols = metadata_dataset.from(inf_sch_qual.call(Sequel[:sys][:sysindexkeys]).as(:sik)).
|
444
|
+
join(inf_sch_qual.call(Sequel[:sys][:syscolumns]).as(:sc), :id=>:id, :colid=>:colid).
|
444
445
|
where{{sik[:id]=>table_id, sik[:indid]=>pk_index_id}}.
|
445
446
|
select_order_map{sc[:name]}
|
446
447
|
|