db 0.13.0 → 0.14.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 64a6f849cc021f19902e7aa339156fd839b6ee03f8bb481c66a86524cdd447d8
4
- data.tar.gz: c4bd22be9d7cc9b9862682f0c10856cac5723f684daf426ecf60737124faa7cc
3
+ metadata.gz: e32753720467fe5085b599ca44812117efa453bbb6ae959e4bb8990cab6d4087
4
+ data.tar.gz: b3a6480f045f16d015c0d9b105e361b6eddbbff489a45ac3e9145a49011ea07e
5
5
  SHA512:
6
- metadata.gz: 1bfa44a0456cca0c87a6f40349a7b7da597bdf53e1169aa0490532f98a90fad3179d562a1c3d5f40750888659ec705d4007984eebf9f1aa97be242918d4c66f9
7
- data.tar.gz: 130a8e292f7f584da81fb8700071d35c0cda6cac8392ebe45e0b53f0527c5f26ab527db4aac3d01d9b051772d605175f27e32625a5d12a431fde19729d8bb8cd
6
+ metadata.gz: 78a879265c001e502faa4c8227a0f3457501bee7b55ac15eb4f7fe7ed267cdba0c476e411bc862dfe310b44d64fadcdb02f358fb0038f22fe3a56f4cb60c8ce9
7
+ data.tar.gz: 3b8be8be3b52d3f0d1b3cddbac2149e664a29fffed62d994eb8759f11ebb264df12ed6e620f8bf00da68ee1391c5486af59be0f5e6e274716408b585d89e1c74
checksums.yaml.gz.sig CHANGED
Binary file
data/lib/db/client.rb CHANGED
@@ -25,6 +25,10 @@ module DB
25
25
 
26
26
  # Close all open connections in the connection pool.
27
27
  def close
28
+ @pool.wait_until_free do
29
+ Console.warn(self) {"Waiting for #{@adapter} pool to drain: #{@pool}"}
30
+ end
31
+
28
32
  @pool.close
29
33
  end
30
34
 
@@ -0,0 +1,89 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Released under the MIT License.
4
+ # Copyright, 2024, by Samuel Williams.
5
+
6
+ module DB
7
+ # Standardized feature detection for database adapters.
8
+ # All features default to false, and adapters can enable specific capabilities.
9
+ class Features
10
+ def initialize(**features)
11
+ @features = features
12
+ end
13
+
14
+ # Check if a specific feature is enabled.
15
+ def enabled?(feature)
16
+ @features.fetch(feature, false)
17
+ end
18
+
19
+ # Get all enabled features.
20
+ def enabled_features
21
+ @features.select{|_, enabled| enabled}.keys
22
+ end
23
+
24
+ # Create a new Features instance with additional or modified features.
25
+ def with(**additional_features)
26
+ self.class.new(**@features, **additional_features)
27
+ end
28
+
29
+ # PostgreSQL-style column type modification: ALTER COLUMN name TYPE type USING expression.
30
+ def alter_column_type?
31
+ @features.fetch(:alter_column_type, false)
32
+ end
33
+
34
+ # MySQL-style column modification: MODIFY COLUMN name type.
35
+ def modify_column?
36
+ @features.fetch(:modify_column, false)
37
+ end
38
+
39
+ # Support for USING clause in column type changes.
40
+ def using_clause?
41
+ @features.fetch(:using_clause, false)
42
+ end
43
+
44
+ # Support for IF EXISTS/IF NOT EXISTS clauses.
45
+ def conditional_operations?
46
+ @features.fetch(:conditional_operations, false)
47
+ end
48
+
49
+ # Schema operations can be rolled back within transactions.
50
+ def transactional_schema?
51
+ @features.fetch(:transactional_schema, false)
52
+ end
53
+
54
+ # Multiple operations can be combined in a single ALTER TABLE statement.
55
+ def batch_alter_table?
56
+ @features.fetch(:batch_alter_table, false)
57
+ end
58
+
59
+ # Support for concurrent/online schema changes.
60
+ def concurrent_schema?
61
+ @features.fetch(:concurrent_schema, false)
62
+ end
63
+
64
+ # Support for adding constraints with validation deferred.
65
+ def deferred_constraints?
66
+ @features.fetch(:deferred_constraints, false)
67
+ end
68
+
69
+ # PostgreSQL-style SERIAL/BIGSERIAL auto-increment columns.
70
+ def serial_columns?
71
+ @features.fetch(:serial_columns, false)
72
+ end
73
+
74
+ # MySQL-style AUTO_INCREMENT auto-increment columns.
75
+ def auto_increment?
76
+ @features.fetch(:auto_increment, false)
77
+ end
78
+
79
+ # SQLite-style INTEGER PRIMARY KEY auto-increment.
80
+ def integer_primary_key_autoincrement?
81
+ @features.fetch(:integer_primary_key_autoincrement, false)
82
+ end
83
+
84
+ # Support for IDENTITY columns (SQL Server/newer PostgreSQL).
85
+ def identity_columns?
86
+ @features.fetch(:identity_columns, false)
87
+ end
88
+ end
89
+ end
data/lib/db/version.rb CHANGED
@@ -5,5 +5,5 @@
5
5
 
6
6
  # @namespace
7
7
  module DB
8
- VERSION = "0.13.0"
8
+ VERSION = "0.14.0"
9
9
  end
data/lib/db.rb CHANGED
@@ -6,3 +6,4 @@
6
6
  require_relative "db/version"
7
7
  require_relative "db/adapters"
8
8
  require_relative "db/client"
9
+ require_relative "db/features"
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: db
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.13.0
4
+ version: 0.14.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
@@ -66,6 +66,7 @@ files:
66
66
  - lib/db/client.rb
67
67
  - lib/db/context/session.rb
68
68
  - lib/db/context/transaction.rb
69
+ - lib/db/features.rb
69
70
  - lib/db/query.rb
70
71
  - lib/db/records.rb
71
72
  - lib/db/version.rb
metadata.gz.sig CHANGED
Binary file