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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dabcc513cb18747996bb8486b74bd7e26572a0f3
4
- data.tar.gz: 3b032b4db4462545c1e12c151b62df52c3a58a9d
3
+ metadata.gz: 8b532921f6053d27aa6bef3c6b23de79bc5a254e
4
+ data.tar.gz: 0d7dbdf74782666e62e0c311225c430a633dba5e
5
5
  SHA512:
6
- metadata.gz: dce9342d43b146137ba3ec221fdba80982566ffbe728057433f1901a0c03ee598c6d6e775a41cc9a99b5418fe1eeeab8b27267823738059369eb916192a0b7c9
7
- data.tar.gz: 045d50d84a5ff897af1ad772166f68d49e957d2f64e4f1126fb098f69d8a6f9ec361afc34a2f6e74d5aaa35e7b8745932c28fb0cc2292296b2f3902284ab29d0
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
@@ -1,5 +1,5 @@
1
1
  module Mimi
2
2
  module DB
3
- VERSION = '0.3.3'.freeze
3
+ VERSION = '0.3.4'.freeze
4
4
  end
5
5
  end
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.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-26 00:00:00.000000000 Z
11
+ date: 2018-06-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mimi-core