sequel 4.30.0 → 4.31.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +18 -0
- data/MIT-LICENSE +1 -1
- data/bin/sequel +1 -0
- data/doc/opening_databases.rdoc +6 -0
- data/doc/release_notes/4.31.0.txt +57 -0
- data/lib/sequel.rb +2 -0
- data/lib/sequel/adapters/ado.rb +2 -0
- data/lib/sequel/adapters/ado/access.rb +2 -0
- data/lib/sequel/adapters/ado/mssql.rb +2 -0
- data/lib/sequel/adapters/amalgalite.rb +2 -0
- data/lib/sequel/adapters/cubrid.rb +2 -0
- data/lib/sequel/adapters/do.rb +2 -0
- data/lib/sequel/adapters/do/mysql.rb +2 -0
- data/lib/sequel/adapters/do/postgres.rb +2 -0
- data/lib/sequel/adapters/do/sqlite3.rb +2 -0
- data/lib/sequel/adapters/ibmdb.rb +3 -1
- data/lib/sequel/adapters/jdbc.rb +2 -0
- data/lib/sequel/adapters/jdbc/as400.rb +2 -0
- data/lib/sequel/adapters/jdbc/cubrid.rb +2 -0
- data/lib/sequel/adapters/jdbc/db2.rb +2 -0
- data/lib/sequel/adapters/jdbc/derby.rb +2 -0
- data/lib/sequel/adapters/jdbc/firebirdsql.rb +2 -0
- data/lib/sequel/adapters/jdbc/h2.rb +2 -0
- data/lib/sequel/adapters/jdbc/hsqldb.rb +2 -0
- data/lib/sequel/adapters/jdbc/informix-sqli.rb +2 -0
- data/lib/sequel/adapters/jdbc/jdbcprogress.rb +2 -0
- data/lib/sequel/adapters/jdbc/jtds.rb +2 -0
- data/lib/sequel/adapters/jdbc/mssql.rb +2 -0
- data/lib/sequel/adapters/jdbc/mysql.rb +2 -0
- data/lib/sequel/adapters/jdbc/oracle.rb +2 -0
- data/lib/sequel/adapters/jdbc/postgresql.rb +24 -1
- data/lib/sequel/adapters/jdbc/sqlanywhere.rb +2 -0
- data/lib/sequel/adapters/jdbc/sqlite.rb +2 -0
- data/lib/sequel/adapters/jdbc/sqlserver.rb +2 -0
- data/lib/sequel/adapters/jdbc/transactions.rb +2 -0
- data/lib/sequel/adapters/mock.rb +2 -0
- data/lib/sequel/adapters/mysql.rb +2 -0
- data/lib/sequel/adapters/mysql2.rb +2 -0
- data/lib/sequel/adapters/odbc.rb +2 -0
- data/lib/sequel/adapters/odbc/db2.rb +2 -0
- data/lib/sequel/adapters/odbc/mssql.rb +2 -0
- data/lib/sequel/adapters/odbc/progress.rb +2 -0
- data/lib/sequel/adapters/oracle.rb +4 -2
- data/lib/sequel/adapters/postgres.rb +5 -3
- data/lib/sequel/adapters/postgresql.rb +2 -0
- data/lib/sequel/adapters/shared/access.rb +2 -0
- data/lib/sequel/adapters/shared/cubrid.rb +2 -0
- data/lib/sequel/adapters/shared/db2.rb +2 -0
- data/lib/sequel/adapters/shared/firebird.rb +2 -0
- data/lib/sequel/adapters/shared/informix.rb +2 -0
- data/lib/sequel/adapters/shared/mssql.rb +2 -0
- data/lib/sequel/adapters/shared/mysql.rb +5 -1
- data/lib/sequel/adapters/shared/mysql_prepared_statements.rb +2 -0
- data/lib/sequel/adapters/shared/oracle.rb +5 -3
- data/lib/sequel/adapters/shared/postgres.rb +19 -12
- data/lib/sequel/adapters/shared/progress.rb +2 -0
- data/lib/sequel/adapters/shared/sqlanywhere.rb +3 -1
- data/lib/sequel/adapters/shared/sqlite.rb +2 -0
- data/lib/sequel/adapters/sqlanywhere.rb +2 -0
- data/lib/sequel/adapters/sqlite.rb +4 -1
- data/lib/sequel/adapters/swift.rb +2 -0
- data/lib/sequel/adapters/swift/mysql.rb +2 -0
- data/lib/sequel/adapters/swift/postgres.rb +2 -0
- data/lib/sequel/adapters/swift/sqlite.rb +2 -0
- data/lib/sequel/adapters/tinytds.rb +2 -0
- data/lib/sequel/adapters/utils/emulate_offset_with_reverse_and_count.rb +5 -3
- data/lib/sequel/adapters/utils/emulate_offset_with_row_number.rb +5 -3
- data/lib/sequel/adapters/utils/pg_types.rb +2 -0
- data/lib/sequel/adapters/utils/replace.rb +2 -0
- data/lib/sequel/adapters/utils/split_alter_table.rb +2 -0
- data/lib/sequel/adapters/utils/stored_procedures.rb +2 -0
- data/lib/sequel/ast_transformer.rb +2 -0
- data/lib/sequel/connection_pool.rb +2 -0
- data/lib/sequel/connection_pool/sharded_single.rb +2 -0
- data/lib/sequel/connection_pool/sharded_threaded.rb +2 -0
- data/lib/sequel/connection_pool/single.rb +2 -0
- data/lib/sequel/connection_pool/threaded.rb +2 -0
- data/lib/sequel/core.rb +2 -0
- data/lib/sequel/database.rb +2 -0
- data/lib/sequel/database/connecting.rb +2 -0
- data/lib/sequel/database/dataset.rb +2 -0
- data/lib/sequel/database/dataset_defaults.rb +2 -0
- data/lib/sequel/database/features.rb +2 -0
- data/lib/sequel/database/logging.rb +2 -0
- data/lib/sequel/database/misc.rb +2 -0
- data/lib/sequel/database/query.rb +2 -0
- data/lib/sequel/database/schema_generator.rb +2 -0
- data/lib/sequel/database/schema_methods.rb +11 -4
- data/lib/sequel/database/transactions.rb +2 -0
- data/lib/sequel/dataset.rb +2 -0
- data/lib/sequel/dataset/actions.rb +2 -0
- data/lib/sequel/dataset/features.rb +2 -0
- data/lib/sequel/dataset/graph.rb +2 -0
- data/lib/sequel/dataset/misc.rb +2 -0
- data/lib/sequel/dataset/mutation.rb +2 -0
- data/lib/sequel/dataset/placeholder_literalizer.rb +3 -1
- data/lib/sequel/dataset/prepared_statements.rb +2 -0
- data/lib/sequel/dataset/query.rb +2 -0
- data/lib/sequel/dataset/sql.rb +7 -5
- data/lib/sequel/deprecated.rb +2 -0
- data/lib/sequel/exceptions.rb +2 -0
- data/lib/sequel/extensions/_pretty_table.rb +5 -3
- data/lib/sequel/extensions/arbitrary_servers.rb +2 -0
- data/lib/sequel/extensions/blank.rb +2 -0
- data/lib/sequel/extensions/columns_introspection.rb +2 -0
- data/lib/sequel/extensions/connection_validator.rb +2 -0
- data/lib/sequel/extensions/constraint_validations.rb +2 -0
- data/lib/sequel/extensions/core_extensions.rb +2 -0
- data/lib/sequel/extensions/core_refinements.rb +2 -0
- data/lib/sequel/extensions/current_datetime_timestamp.rb +2 -0
- data/lib/sequel/extensions/dataset_source_alias.rb +2 -0
- data/lib/sequel/extensions/date_arithmetic.rb +3 -1
- data/lib/sequel/extensions/empty_array_consider_nulls.rb +2 -0
- data/lib/sequel/extensions/empty_array_ignore_nulls.rb +2 -0
- data/lib/sequel/extensions/error_sql.rb +2 -0
- data/lib/sequel/extensions/eval_inspect.rb +2 -0
- data/lib/sequel/extensions/filter_having.rb +2 -0
- data/lib/sequel/extensions/from_block.rb +2 -0
- data/lib/sequel/extensions/graph_each.rb +2 -0
- data/lib/sequel/extensions/hash_aliases.rb +2 -0
- data/lib/sequel/extensions/inflector.rb +2 -0
- data/lib/sequel/extensions/looser_typecasting.rb +2 -0
- data/lib/sequel/extensions/meta_def.rb +2 -0
- data/lib/sequel/extensions/migration.rb +14 -4
- data/lib/sequel/extensions/mssql_emulate_lateral_with_apply.rb +2 -0
- data/lib/sequel/extensions/named_timezones.rb +2 -0
- data/lib/sequel/extensions/null_dataset.rb +2 -0
- data/lib/sequel/extensions/pagination.rb +2 -0
- data/lib/sequel/extensions/pg_array.rb +16 -36
- data/lib/sequel/extensions/pg_array_ops.rb +2 -0
- data/lib/sequel/extensions/pg_enum.rb +4 -1
- data/lib/sequel/extensions/pg_hstore.rb +3 -1
- data/lib/sequel/extensions/pg_hstore_ops.rb +2 -0
- data/lib/sequel/extensions/pg_inet.rb +2 -0
- data/lib/sequel/extensions/pg_inet_ops.rb +2 -0
- data/lib/sequel/extensions/pg_interval.rb +3 -1
- data/lib/sequel/extensions/pg_json.rb +2 -0
- data/lib/sequel/extensions/pg_json_ops.rb +2 -0
- data/lib/sequel/extensions/pg_loose_count.rb +2 -0
- data/lib/sequel/extensions/pg_range.rb +2 -0
- data/lib/sequel/extensions/pg_range_ops.rb +2 -0
- data/lib/sequel/extensions/pg_row.rb +2 -0
- data/lib/sequel/extensions/pg_row_ops.rb +2 -0
- data/lib/sequel/extensions/pg_static_cache_updater.rb +2 -0
- data/lib/sequel/extensions/pretty_table.rb +2 -0
- data/lib/sequel/extensions/query.rb +2 -0
- data/lib/sequel/extensions/query_literals.rb +2 -0
- data/lib/sequel/extensions/round_timestamps.rb +2 -0
- data/lib/sequel/extensions/ruby18_symbol_extensions.rb +2 -0
- data/lib/sequel/extensions/schema_caching.rb +2 -0
- data/lib/sequel/extensions/schema_dumper.rb +4 -1
- data/lib/sequel/extensions/select_remove.rb +2 -0
- data/lib/sequel/extensions/sequel_3_dataset_methods.rb +3 -1
- data/lib/sequel/extensions/server_block.rb +2 -0
- data/lib/sequel/extensions/set_overrides.rb +2 -0
- data/lib/sequel/extensions/split_array_nil.rb +2 -0
- data/lib/sequel/extensions/sql_expr.rb +2 -0
- data/lib/sequel/extensions/string_date_time.rb +2 -0
- data/lib/sequel/extensions/thread_local_timezones.rb +2 -0
- data/lib/sequel/extensions/to_dot.rb +3 -1
- data/lib/sequel/model.rb +2 -0
- data/lib/sequel/model/associations.rb +3 -1
- data/lib/sequel/model/base.rb +5 -1
- data/lib/sequel/model/dataset_module.rb +2 -0
- data/lib/sequel/model/default_inflections.rb +2 -0
- data/lib/sequel/model/errors.rb +2 -0
- data/lib/sequel/model/exceptions.rb +2 -0
- data/lib/sequel/model/inflections.rb +2 -0
- data/lib/sequel/model/plugins.rb +2 -0
- data/lib/sequel/no_core_ext.rb +2 -0
- data/lib/sequel/plugins/accessed_columns.rb +2 -0
- data/lib/sequel/plugins/active_model.rb +2 -0
- data/lib/sequel/plugins/after_initialize.rb +2 -0
- data/lib/sequel/plugins/association_autoreloading.rb +2 -0
- data/lib/sequel/plugins/association_dependencies.rb +2 -0
- data/lib/sequel/plugins/association_pks.rb +20 -24
- data/lib/sequel/plugins/association_proxies.rb +2 -0
- data/lib/sequel/plugins/auto_validations.rb +2 -0
- data/lib/sequel/plugins/before_after_save.rb +2 -0
- data/lib/sequel/plugins/blacklist_security.rb +2 -0
- data/lib/sequel/plugins/boolean_readers.rb +2 -0
- data/lib/sequel/plugins/boolean_subsets.rb +2 -0
- data/lib/sequel/plugins/caching.rb +2 -0
- data/lib/sequel/plugins/class_table_inheritance.rb +2 -0
- data/lib/sequel/plugins/column_conflicts.rb +2 -0
- data/lib/sequel/plugins/column_select.rb +2 -0
- data/lib/sequel/plugins/composition.rb +2 -0
- data/lib/sequel/plugins/constraint_validations.rb +2 -0
- data/lib/sequel/plugins/csv_serializer.rb +2 -0
- data/lib/sequel/plugins/dataset_associations.rb +2 -0
- data/lib/sequel/plugins/defaults_setter.rb +2 -0
- data/lib/sequel/plugins/delay_add_association.rb +2 -0
- data/lib/sequel/plugins/dirty.rb +2 -0
- data/lib/sequel/plugins/eager_each.rb +2 -0
- data/lib/sequel/plugins/error_splitter.rb +2 -0
- data/lib/sequel/plugins/force_encoding.rb +2 -0
- data/lib/sequel/plugins/hook_class_methods.rb +2 -0
- data/lib/sequel/plugins/identifier_columns.rb +2 -0
- data/lib/sequel/plugins/input_transformer.rb +2 -0
- data/lib/sequel/plugins/insert_returning_select.rb +2 -0
- data/lib/sequel/plugins/instance_filters.rb +2 -0
- data/lib/sequel/plugins/instance_hooks.rb +2 -0
- data/lib/sequel/plugins/inverted_subsets.rb +2 -0
- data/lib/sequel/plugins/json_serializer.rb +2 -0
- data/lib/sequel/plugins/lazy_attributes.rb +2 -0
- data/lib/sequel/plugins/list.rb +2 -0
- data/lib/sequel/plugins/many_through_many.rb +2 -0
- data/lib/sequel/plugins/many_to_one_pk_lookup.rb +2 -0
- data/lib/sequel/plugins/modification_detection.rb +2 -0
- data/lib/sequel/plugins/mssql_optimistic_locking.rb +2 -0
- data/lib/sequel/plugins/nested_attributes.rb +2 -0
- data/lib/sequel/plugins/optimistic_locking.rb +2 -0
- data/lib/sequel/plugins/pg_array_associations.rb +2 -0
- data/lib/sequel/plugins/pg_row.rb +2 -0
- data/lib/sequel/plugins/pg_typecast_on_load.rb +2 -0
- data/lib/sequel/plugins/prepared_statements.rb +2 -0
- data/lib/sequel/plugins/prepared_statements_associations.rb +2 -0
- data/lib/sequel/plugins/prepared_statements_safe.rb +2 -0
- data/lib/sequel/plugins/prepared_statements_with_pk.rb +2 -0
- data/lib/sequel/plugins/rcte_tree.rb +2 -0
- data/lib/sequel/plugins/schema.rb +2 -0
- data/lib/sequel/plugins/scissors.rb +2 -0
- data/lib/sequel/plugins/serialization.rb +2 -0
- data/lib/sequel/plugins/serialization_modification_detection.rb +2 -0
- data/lib/sequel/plugins/sharding.rb +2 -0
- data/lib/sequel/plugins/single_table_inheritance.rb +2 -0
- data/lib/sequel/plugins/singular_table_names.rb +2 -0
- data/lib/sequel/plugins/skip_create_refresh.rb +2 -0
- data/lib/sequel/plugins/split_values.rb +2 -0
- data/lib/sequel/plugins/static_cache.rb +2 -0
- data/lib/sequel/plugins/string_stripper.rb +2 -0
- data/lib/sequel/plugins/subclasses.rb +2 -0
- data/lib/sequel/plugins/subset_conditions.rb +2 -0
- data/lib/sequel/plugins/table_select.rb +2 -0
- data/lib/sequel/plugins/tactical_eager_loading.rb +2 -0
- data/lib/sequel/plugins/timestamps.rb +2 -0
- data/lib/sequel/plugins/touch.rb +2 -0
- data/lib/sequel/plugins/tree.rb +2 -0
- data/lib/sequel/plugins/typecast_on_load.rb +2 -0
- data/lib/sequel/plugins/unlimited_update.rb +2 -0
- data/lib/sequel/plugins/update_or_create.rb +2 -0
- data/lib/sequel/plugins/update_primary_key.rb +2 -0
- data/lib/sequel/plugins/update_refresh.rb +2 -0
- data/lib/sequel/plugins/uuid.rb +2 -0
- data/lib/sequel/plugins/validate_associated.rb +2 -0
- data/lib/sequel/plugins/validation_class_methods.rb +2 -0
- data/lib/sequel/plugins/validation_helpers.rb +3 -1
- data/lib/sequel/plugins/xml_serializer.rb +2 -0
- data/lib/sequel/sql.rb +3 -1
- data/lib/sequel/timezones.rb +2 -0
- data/lib/sequel/version.rb +3 -1
- data/spec/adapters/mysql_spec.rb +4 -0
- data/spec/adapters/postgres_spec.rb +35 -11
- data/spec/core/connection_pool_spec.rb +1 -1
- data/spec/extensions/association_pks_spec.rb +4 -2
- data/spec/extensions/caching_spec.rb +1 -1
- data/spec/extensions/csv_serializer_spec.rb +7 -0
- data/spec/extensions/date_arithmetic_spec.rb +1 -1
- data/spec/extensions/dirty_spec.rb +6 -6
- data/spec/extensions/force_encoding_spec.rb +12 -12
- data/spec/extensions/input_transformer_spec.rb +1 -1
- data/spec/extensions/migration_spec.rb +16 -0
- data/spec/extensions/modification_detection_spec.rb +2 -2
- data/spec/extensions/nested_attributes_spec.rb +1 -1
- data/spec/extensions/optimistic_locking_spec.rb +1 -1
- data/spec/extensions/pg_array_spec.rb +3 -8
- data/spec/files/double_migration/001_create_sessions.rb +9 -0
- data/spec/files/double_migration/002_create_nodes.rb +19 -0
- data/spec/files/double_migration/003_3_create_users.rb +4 -0
- data/spec/files/empty_migration/001_create_sessions.rb +9 -0
- data/spec/files/empty_migration/002_create_nodes.rb +0 -0
- data/spec/files/empty_migration/003_3_create_users.rb +4 -0
- metadata +11 -3
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen-string-literal: true
|
2
|
+
#
|
1
3
|
# The pg_array extension adds support for Sequel to handle
|
2
4
|
# PostgreSQL's array types.
|
3
5
|
#
|
@@ -74,14 +76,17 @@
|
|
74
76
|
# customize the array type handling. See the Sequel::Postgres::PGArray.register
|
75
77
|
# method documentation.
|
76
78
|
#
|
79
|
+
# While this extension can parse PostgreSQL arrays with explicit bounds, it
|
80
|
+
# currently ignores explicit bounds, so such values do not round
|
81
|
+
# trip.
|
82
|
+
#
|
77
83
|
# If you want an easy way to call PostgreSQL array functions and
|
78
84
|
# operators, look into the pg_array_ops extension.
|
79
85
|
#
|
80
|
-
# This extension requires the
|
86
|
+
# This extension requires the strscan and delegate libraries.
|
81
87
|
|
82
88
|
require 'delegate'
|
83
89
|
require 'strscan'
|
84
|
-
require 'json'
|
85
90
|
Sequel.require 'adapters/utils/pg_types'
|
86
91
|
|
87
92
|
module Sequel
|
@@ -121,10 +126,6 @@ module Sequel
|
|
121
126
|
# (usually a string), and should return the appropriate typecasted object.
|
122
127
|
# :oid :: The PostgreSQL OID for the array type. This is used by the Sequel postgres adapter
|
123
128
|
# to set up automatic type conversion on retrieval from the database.
|
124
|
-
# :parser :: Can be set to :json to use the faster JSON-based parser. Note that the JSON-based
|
125
|
-
# parser can only correctly handle integers values correctly. It doesn't handle
|
126
|
-
# full precision for numeric types, and doesn't handle NaN/Infinity values for
|
127
|
-
# floating point types.
|
128
129
|
# :scalar_oid :: Should be the PostgreSQL OID for the scalar version of this array type. If given,
|
129
130
|
# automatically sets the :converter option by looking for scalar conversion
|
130
131
|
# proc.
|
@@ -163,7 +164,7 @@ module Sequel
|
|
163
164
|
end
|
164
165
|
|
165
166
|
array_type = (opts[:array_type] || db_type).to_s.dup.freeze
|
166
|
-
creator =
|
167
|
+
creator = Creator.new(array_type, converter)
|
167
168
|
|
168
169
|
typecast_method_map[db_type] = :"#{type}_array"
|
169
170
|
|
@@ -343,7 +344,7 @@ module Sequel
|
|
343
344
|
UNQUOTED_RE = /[{}",]|[^{}",]+/
|
344
345
|
QUOTED_RE = /["\\]|[^"\\]+/
|
345
346
|
NULL_RE = /NULL",/
|
346
|
-
OPEN_RE =
|
347
|
+
OPEN_RE = /((\[\d+:\d+\])+=)?\{/
|
347
348
|
|
348
349
|
# Set the source for the input, and any converter callable
|
349
350
|
# to call with objects to be created. For nested parsers
|
@@ -353,7 +354,7 @@ module Sequel
|
|
353
354
|
super(source)
|
354
355
|
@converter = converter
|
355
356
|
@stack = [[]]
|
356
|
-
@recorded =
|
357
|
+
@recorded = String.new
|
357
358
|
end
|
358
359
|
|
359
360
|
# Take the buffer of recorded characters and add it to the array
|
@@ -367,7 +368,7 @@ module Sequel
|
|
367
368
|
entry = @converter.call(entry)
|
368
369
|
end
|
369
370
|
@stack.last.push(entry)
|
370
|
-
@recorded =
|
371
|
+
@recorded = String.new
|
371
372
|
end
|
372
373
|
end
|
373
374
|
|
@@ -460,27 +461,6 @@ module Sequel
|
|
460
461
|
end
|
461
462
|
end
|
462
463
|
|
463
|
-
# Callable object that takes the input string and parses it using.
|
464
|
-
# a JSON parser. This should be faster than the standard Creator,
|
465
|
-
# but only handles integer types correctly.
|
466
|
-
class JSONCreator < Creator
|
467
|
-
# Character conversion map mapping input strings to JSON replacements
|
468
|
-
SUBST = {'{'.freeze=>'['.freeze, '}'.freeze=>']'.freeze, 'NULL'.freeze=>'null'.freeze}
|
469
|
-
|
470
|
-
# Regular expression matching input strings to convert
|
471
|
-
SUBST_RE = %r[\{|\}|NULL].freeze
|
472
|
-
|
473
|
-
# Parse the input string by using a gsub to convert non-JSON characters to
|
474
|
-
# JSON, running it through a regular JSON parser. If a converter is used, a
|
475
|
-
# recursive map of the output is done to make sure that the entires in the
|
476
|
-
# correct type.
|
477
|
-
def call(string)
|
478
|
-
array = Sequel.parse_json(string.gsub(SUBST_RE){|m| SUBST[m]})
|
479
|
-
array = Sequel.recursive_map(array, @converter) if @converter
|
480
|
-
PGArray.new(array, @type)
|
481
|
-
end
|
482
|
-
end
|
483
|
-
|
484
464
|
# The type of this array. May be nil if no type was given. If a type
|
485
465
|
# is provided, the array is automatically casted to this type when
|
486
466
|
# literalizing. This type is the underlying type, not the array type
|
@@ -532,9 +512,9 @@ module Sequel
|
|
532
512
|
|
533
513
|
# Register all array types that this extension handles by default.
|
534
514
|
|
535
|
-
register('text', :oid=>1009, :type_symbol=>:string)
|
536
|
-
register('integer', :oid=>1007, :
|
537
|
-
register('bigint', :oid=>1016, :
|
515
|
+
register('text', :oid=>1009, :scalar_oid=>25, :type_symbol=>:string)
|
516
|
+
register('integer', :oid=>1007, :scalar_oid=>23)
|
517
|
+
register('bigint', :oid=>1016, :scalar_oid=>20, :scalar_typecast=>:integer)
|
538
518
|
register('numeric', :oid=>1231, :scalar_oid=>1700, :type_symbol=>:decimal)
|
539
519
|
register('double precision', :oid=>1022, :scalar_oid=>701, :type_symbol=>:float)
|
540
520
|
|
@@ -546,8 +526,8 @@ module Sequel
|
|
546
526
|
register('time with time zone', :oid=>1270, :scalar_oid=>1083, :type_symbol=>:time_timezone, :scalar_typecast=>:time)
|
547
527
|
register('timestamp with time zone', :oid=>1185, :scalar_oid=>1184, :type_symbol=>:datetime_timezone, :scalar_typecast=>:datetime)
|
548
528
|
|
549
|
-
register('smallint', :oid=>1005, :
|
550
|
-
register('oid', :oid=>1028, :
|
529
|
+
register('smallint', :oid=>1005, :scalar_oid=>21, :scalar_typecast=>:integer)
|
530
|
+
register('oid', :oid=>1028, :scalar_oid=>26, :scalar_typecast=>:integer)
|
551
531
|
register('real', :oid=>1021, :scalar_oid=>700, :scalar_typecast=>:float)
|
552
532
|
register('character', :oid=>1014, :array_type=>:text, :scalar_typecast=>:string)
|
553
533
|
register('character varying', :oid=>1015, :scalar_typecast=>:string, :type_symbol=>:varchar)
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen-string-literal: true
|
2
|
+
#
|
1
3
|
# The pg_enum extension adds support for Sequel to handle PostgreSQL's enum
|
2
4
|
# types. To use this extension, first load it into your Database instance:
|
3
5
|
#
|
@@ -68,7 +70,8 @@ module Sequel
|
|
68
70
|
# :before :: Add the new value before this existing value.
|
69
71
|
# :if_not_exists :: Do not raise an error if the value already exists in the enum.
|
70
72
|
def add_enum_value(enum, value, opts=OPTS)
|
71
|
-
sql =
|
73
|
+
sql = String.new
|
74
|
+
sql << "ALTER TYPE #{quote_schema_table(enum)} ADD VALUE#{' IF NOT EXISTS' if opts[:if_not_exists]} #{literal(value.to_s)}"
|
72
75
|
if v = opts[:before]
|
73
76
|
sql << " BEFORE #{literal(v.to_s)}"
|
74
77
|
elsif v = opts[:after]
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen-string-literal: true
|
2
|
+
#
|
1
3
|
# The pg_hstore extension adds support for the PostgreSQL hstore type
|
2
4
|
# to Sequel. hstore is an extension that ships with PostgreSQL, and
|
3
5
|
# the hstore type stores an arbitrary key-value table, where the keys
|
@@ -265,7 +267,7 @@ module Sequel
|
|
265
267
|
# literal version of the hstore. Separated out for use by
|
266
268
|
# the bound argument code.
|
267
269
|
def unquoted_literal
|
268
|
-
str =
|
270
|
+
str = String.new
|
269
271
|
comma = false
|
270
272
|
commas = COMMA
|
271
273
|
quote = QUOTE
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen-string-literal: true
|
2
|
+
#
|
1
3
|
# The pg_interval extension adds support for PostgreSQL's interval type.
|
2
4
|
#
|
3
5
|
# This extension integrates with Sequel's native postgres and jdbc/postgresql
|
@@ -49,7 +51,7 @@ module Sequel
|
|
49
51
|
def self.literal_duration(duration)
|
50
52
|
h = Hash.new(0)
|
51
53
|
duration.parts.each{|unit, value| h[unit] += value}
|
52
|
-
s =
|
54
|
+
s = String.new
|
53
55
|
|
54
56
|
DURATION_UNITS.each do |unit|
|
55
57
|
if (v = h[unit]) != 0
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen-string-literal: true
|
2
|
+
#
|
1
3
|
# The schema_dumper extension supports dumping tables and indexes
|
2
4
|
# in a Sequel::Migration format, so they can be restored on another
|
3
5
|
# database (which can be the same type or a different type than
|
@@ -213,7 +215,8 @@ END_MIG
|
|
213
215
|
# For the table and foreign key metadata array, return an alter_table
|
214
216
|
# string that would add the foreign keys if run in a migration.
|
215
217
|
def dump_add_fk_constraints(table, fks)
|
216
|
-
sfks =
|
218
|
+
sfks = String.new
|
219
|
+
sfks << "alter_table(#{table.inspect}) do\n"
|
217
220
|
sfks << create_table_generator do
|
218
221
|
fks.sort_by{|fk| fk[:columns].map(&:to_s)}.each do |fk|
|
219
222
|
foreign_key fk[:columns], fk
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen-string-literal: true
|
2
|
+
#
|
1
3
|
# The select_remove extension adds Sequel::Dataset#select_remove for removing existing selected
|
2
4
|
# columns from a dataset. It's not part of Sequel core as it is rarely needed and has
|
3
5
|
# some corner cases where it can't work correctly.
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen-string-literal: true
|
2
|
+
#
|
1
3
|
# This adds the following dataset methods:
|
2
4
|
#
|
3
5
|
# []= :: filter with the first argument, update with the second
|
@@ -107,7 +109,7 @@ module Sequel
|
|
107
109
|
def to_csv(include_column_titles = true)
|
108
110
|
n = naked
|
109
111
|
cols = n.columns
|
110
|
-
csv =
|
112
|
+
csv = String.new
|
111
113
|
csv << "#{cols.join(COMMA)}\r\n" if include_column_titles
|
112
114
|
n.each{|r| csv << "#{cols.collect{|c| r[c]}.join(COMMA)}\r\n"}
|
113
115
|
csv
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen-string-literal: true
|
2
|
+
#
|
1
3
|
# The thread_local_timezones extension allows you to set a per-thread timezone that
|
2
4
|
# will override the default global timezone while the thread is executing. The
|
3
5
|
# main use case is for web applications that execute each request in its own thread,
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen-string-literal: true
|
2
|
+
#
|
1
3
|
# This adds a <tt>Sequel::Dataset#to_dot</tt> method. The +to_dot+ method
|
2
4
|
# returns a string that can be processed by graphviz's +dot+ program in
|
3
5
|
# order to get a visualization of the dataset. Basically, it shows a version
|
@@ -123,7 +125,7 @@ module Sequel
|
|
123
125
|
dot "PlaceholderLiteralString: #{str.inspect}"
|
124
126
|
v(e.args, :args)
|
125
127
|
when SQL::JoinClause
|
126
|
-
str = "#{e.join_type.to_s.upcase} JOIN"
|
128
|
+
str = "#{e.join_type.to_s.upcase} JOIN".dup
|
127
129
|
if e.is_a?(SQL::JoinOnClause)
|
128
130
|
str << " ON"
|
129
131
|
elsif e.is_a?(SQL::JoinUsingClause)
|
data/lib/sequel/model.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen-string-literal: true
|
2
|
+
|
1
3
|
module Sequel
|
2
4
|
class Model
|
3
5
|
# Associations are used in order to specify relationships between model classes
|
@@ -2553,7 +2555,7 @@ END
|
|
2553
2555
|
# create large cartesian products. If you must graph multiple one_to_many and many_to_many associations,
|
2554
2556
|
# make sure your filters are narrow if you have a large database.
|
2555
2557
|
#
|
2556
|
-
# Each association's order, if
|
2558
|
+
# Each association's order, if defined, is respected. +eager_graph+ probably
|
2557
2559
|
# won't work correctly on a limited dataset, unless you are
|
2558
2560
|
# only graphing many_to_one, one_to_one, and one_through_one associations.
|
2559
2561
|
#
|
data/lib/sequel/model/base.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen-string-literal: true
|
2
|
+
|
1
3
|
module Sequel
|
2
4
|
class Model
|
3
5
|
extend Enumerable
|
@@ -1134,7 +1136,9 @@ module Sequel
|
|
1134
1136
|
attr_writer(*BOOLEAN_SETTINGS)
|
1135
1137
|
|
1136
1138
|
# The hash of attribute values. Keys are symbols with the names of the
|
1137
|
-
# underlying database columns.
|
1139
|
+
# underlying database columns. The returned hash is a reference to the
|
1140
|
+
# receiver's values hash, and modifying it will also modify the receiver's
|
1141
|
+
# values.
|
1138
1142
|
#
|
1139
1143
|
# Artist.new(:name=>'Bob').values # => {:name=>'Bob'}
|
1140
1144
|
# Artist[1].values # => {:id=>1, :name=>'Jim', ...}
|