mini_record 0.4.6 → 0.4.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 24a1cc995d7a4bc966d6aa5408ddccf9e69df115
4
- data.tar.gz: c6506a687118394b8302ae7791b61e775e3915bf
3
+ metadata.gz: 3fd46ce5c4e1771383d8c7d957c5ef5e5cf8125b
4
+ data.tar.gz: 5af6a72b0753880d14aab443a98e8d250785fee1
5
5
  SHA512:
6
- metadata.gz: 837c811faa4db44c8b8882075b9b0e080d765ee5666cb5075510358e6a71ed43a2431f833e8f04fa4dc60c0b7424ad81a6b727b1f6b9b4d7c1ec57d26e89fa15
7
- data.tar.gz: 52747b51587991a9ffb2ee1ea3e50d66309c549536e1285d46d24b50dc1da478b3b47fd9c76c606d1cf47c166f3f05383bfae2d454c2d9c9693696f13c4c8b55
6
+ metadata.gz: 3281bb6e931815f700f8b1e617797d44566a10e497edfa66c7227326636e3f3d38efc015f939fba2909d48b30fcd85cfcf3fdab27d25480df76a48f010b41a7a
7
+ data.tar.gz: 122d59cb22ebc304d27cb4f100f94ff6656024071b00fc3ae55b6c2c91750185a753f1454ee65e126bd04add1e8734cad4bfcdecb24df6c6d720b4b832b363a3
@@ -1,5 +1,7 @@
1
1
  language: ruby
2
- before_install: 'gem update --system'
2
+ before_install:
3
+ - gem update --system
4
+ - gem update bundler
3
5
  rvm:
4
6
  - 1.9.3
5
7
  - 2.1.0
@@ -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 postgresql_range?(type)
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 postgresql_range? type
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
- [table_name, association.name.to_s].sort.join("_")
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
- index_name = (options[:name] || name).to_s
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
@@ -1,3 +1,3 @@
1
1
  module MiniRecord
2
- VERSION = "0.4.6"
2
+ VERSION = "0.4.7"
3
3
  end
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.6
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: 2015-05-14 00:00:00.000000000 Z
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.2.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