mini_record 0.4.6 → 0.4.7
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/.travis.yml +3 -1
- data/lib/mini_record/auto_schema.rb +14 -5
- data/lib/mini_record/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3fd46ce5c4e1771383d8c7d957c5ef5e5cf8125b
|
4
|
+
data.tar.gz: 5af6a72b0753880d14aab443a98e8d250785fee1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3281bb6e931815f700f8b1e617797d44566a10e497edfa66c7227326636e3f3d38efc015f939fba2909d48b30fcd85cfcf3fdab27d25480df76a48f010b41a7a
|
7
|
+
data.tar.gz: 122d59cb22ebc304d27cb4f100f94ff6656024071b00fc3ae55b6c2c91750185a753f1454ee65e126bd04add1e8734cad4bfcdecb24df6c6d720b4b832b363a3
|
data/.travis.yml
CHANGED
@@ -114,7 +114,7 @@ module MiniRecord
|
|
114
114
|
# t.column :type, "ENUM('EMPLOYEE','CLIENT','SUPERUSER','DEVELOPER')"
|
115
115
|
if type.is_a?(String)
|
116
116
|
# will be converted in: t.column :type, "ENUM('EMPLOYEE','CLIENT')"
|
117
|
-
options.reverse_merge!(:limit => 0) unless
|
117
|
+
options.reverse_merge!(:limit => 0) unless postgresql_limitless_column?(type)
|
118
118
|
table_definition.column(column_name, type, options)
|
119
119
|
else
|
120
120
|
# wil be converted in: t.string :name
|
@@ -139,9 +139,9 @@ module MiniRecord
|
|
139
139
|
alias :property :field
|
140
140
|
alias :col :field
|
141
141
|
|
142
|
-
def
|
142
|
+
def postgresql_limitless_column? type
|
143
143
|
return unless connection.is_a?(ActiveRecord::ConnectionAdapters::PostgreSQLAdapter)
|
144
|
-
type =~ /range/
|
144
|
+
type =~ /range|json/i
|
145
145
|
end
|
146
146
|
|
147
147
|
def timestamps
|
@@ -320,7 +320,14 @@ module MiniRecord
|
|
320
320
|
table = if name = association.options[:join_table]
|
321
321
|
name.to_s
|
322
322
|
else
|
323
|
-
|
323
|
+
association_table_name = association.name.to_s.classify.constantize.table_name
|
324
|
+
table_name_substrings = [table_name,association_table_name].collect { |string| string.split('_') }
|
325
|
+
common_substrings = Array.new
|
326
|
+
table_name_substrings.first.each_index { |i| table_name_substrings.first[i] == table_name_substrings.last[i] ? common_substrings.push(table_name_substrings.first[i]) : break }
|
327
|
+
common_prefix = common_substrings.join('_')
|
328
|
+
table_names = [table_name.clone,association_table_name.clone].sort
|
329
|
+
table_names.last.gsub!(/^#{common_prefix}_/,'')
|
330
|
+
table_names.join("_")
|
324
331
|
end
|
325
332
|
unless connection.tables.include?(table.to_s)
|
326
333
|
foreign_key = association.options[:foreign_key] || association.foreign_key
|
@@ -411,7 +418,9 @@ module MiniRecord
|
|
411
418
|
# Add indexes
|
412
419
|
indexes.each do |name, options|
|
413
420
|
options = options.dup
|
414
|
-
|
421
|
+
options.delete(:foreign)
|
422
|
+
adjusted_index_name = "index_#{table_name}_on_" + (options[:column].is_a?(Array) ? options[:column].join('_and_') : options[:column]).to_s
|
423
|
+
index_name = (options[:name] || adjusted_index_name).to_s
|
415
424
|
unless connection.indexes(table_name).detect { |i| i.name == index_name }
|
416
425
|
logger.debug "[MiniRecord] Adding index #{index_name} #{options[:column].inspect} on #{table_name}" if logger
|
417
426
|
connection.add_index(table_name, options.delete(:column), options) unless dry_run
|
data/lib/mini_record/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mini_record
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Davide D'Agostino
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-03-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -65,7 +65,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
65
65
|
version: '0'
|
66
66
|
requirements: []
|
67
67
|
rubyforge_project: mini_record
|
68
|
-
rubygems_version: 2.
|
68
|
+
rubygems_version: 2.4.5
|
69
69
|
signing_key:
|
70
70
|
specification_version: 4
|
71
71
|
summary: MiniRecord is a micro gem that allow you to write schema inside your model
|