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 +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/db/client.rb +4 -0
- data/lib/db/features.rb +89 -0
- data/lib/db/version.rb +1 -1
- data/lib/db.rb +1 -0
- data.tar.gz.sig +0 -0
- metadata +2 -1
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e32753720467fe5085b599ca44812117efa453bbb6ae959e4bb8990cab6d4087
|
4
|
+
data.tar.gz: b3a6480f045f16d015c0d9b105e361b6eddbbff489a45ac3e9145a49011ea07e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 78a879265c001e502faa4c8227a0f3457501bee7b55ac15eb4f7fe7ed267cdba0c476e411bc862dfe310b44d64fadcdb02f358fb0038f22fe3a56f4cb60c8ce9
|
7
|
+
data.tar.gz: 3b8be8be3b52d3f0d1b3cddbac2149e664a29fffed62d994eb8759f11ebb264df12ed6e620f8bf00da68ee1391c5486af59be0f5e6e274716408b585d89e1c74
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/lib/db/client.rb
CHANGED
data/lib/db/features.rb
ADDED
@@ -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
data/lib/db.rb
CHANGED
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.
|
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
|