mimi-db 0.3.3 → 0.3.4
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/lib/mimi/db/extensions/sequel-cockroachdb.rb +26 -0
- data/lib/mimi/db/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8b532921f6053d27aa6bef3c6b23de79bc5a254e
|
4
|
+
data.tar.gz: 0d7dbdf74782666e62e0c311225c430a633dba5e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 23e370e7ebadb2fb577fd925bf43cc9913996552f6a4d76ce89bf1342580c7cb3ceaaa711740edbafadaa347ac60aa9cd227663ff999d009b5efb5c3d6b83ba5
|
7
|
+
data.tar.gz: b3742333df64202ff97144c1a9b09ff8c384cdfc52ca809116564c7bd1779a37d99350f477f2892e1a420d74473ad76a4aba7f0b8e92fa1749b636bb698a1a71
|
@@ -23,6 +23,32 @@ module Sequel
|
|
23
23
|
# 100000 # mimics Postgres v10
|
24
24
|
end
|
25
25
|
|
26
|
+
# Retrieves indexes for the given table
|
27
|
+
#
|
28
|
+
# NOTE: Apparently CockroachDB is not fully compatible with Postgres or Sequel's
|
29
|
+
# Postgres adapter, and it can't correctly figure out indexes and their properties.
|
30
|
+
# As a workaround, a specific #indexes() method is implemented here, which executes
|
31
|
+
# `SHOW INDEXES FROM ...` and parses the results.
|
32
|
+
#
|
33
|
+
# @param table_name [String,Symbol]
|
34
|
+
# @return [Hash] index_name => index_properties
|
35
|
+
#
|
36
|
+
def indexes(table_name)
|
37
|
+
idxs = {}
|
38
|
+
results = fetch('show indexes from ' + table_name.to_s).all
|
39
|
+
results.each do |idx_entry|
|
40
|
+
idx_name = idx_entry[:Name].to_sym
|
41
|
+
next if idx_name == :primary # ignore primary index
|
42
|
+
idxs[idx_name] ||= { name: idx_name.to_s }
|
43
|
+
idx = idxs[idx_name]
|
44
|
+
idx[:unique] = idx_entry[:Unique]
|
45
|
+
idx[:deferrable] = false
|
46
|
+
idx[:columns] ||= []
|
47
|
+
idx[:columns] << idx_entry[:Column].to_sym unless idx_entry[:Implicit]
|
48
|
+
end
|
49
|
+
idxs
|
50
|
+
end
|
51
|
+
|
26
52
|
private
|
27
53
|
|
28
54
|
def dataset_class_default
|
data/lib/mimi/db/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mimi-db
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alex Kukushkin
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-06-
|
11
|
+
date: 2018-06-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mimi-core
|