schema_plus 1.8.3 → 1.8.4

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: 7a5f207e0ebe6cbe96157c4762ac33335023a439
4
- data.tar.gz: 024b7be47e963277cc5a673cc5639bede4348d58
3
+ metadata.gz: b535cbef242d2c3616d089e7ef267ffcda421a06
4
+ data.tar.gz: e788022566d93869fd22c992c1e15b6acee28bf9
5
5
  SHA512:
6
- metadata.gz: 4e40fb778ee431cac5b5393f417036f62be5b256ad63dd98ea67cab6c7414e9a6abf7ac4a3b591a72f484c4b547cc1e8d727b27b7b8e993873e7b28c941d7e25
7
- data.tar.gz: 18eee79285313cef82db8533032862e9662c9c8ac74c454afc2b80fd137a6081aa97594636becb63d56f260c4a213d98b49501da243c31c6ef1df196ce40330c
6
+ metadata.gz: 2c4bb4ccada1450523f33121bf5c7f4071c53f1714c6fbe6cd1c32efdce9aa85ddf7130194332b048127af5ef18ecbff4b738be8e6e172126d68abf686e9e0c2
7
+ data.tar.gz: c5f26b566f7cc429eb62d53a0d1f84faed2583b4bbc1f76b0ceabcc6e44ad3f80571456aef55a614720a9a106ea38e89bb18c508b3839eb91943c85591d57f28
@@ -23,6 +23,8 @@ gemfile:
23
23
  - gemfiles/rails-4.2/Gemfile.postgresql
24
24
  - gemfiles/rails-4.2/Gemfile.sqlite3
25
25
  env: POSTGRESQL_DB_USER=postgres MYSQL_DB_USER=travis
26
+ addons:
27
+ postgresql: '9.3'
26
28
  before_script: bundle exec rake create_databases
27
29
  after_script: bundle exec rake drop_databases
28
30
  script: bundle exec rake travis
@@ -2,6 +2,10 @@
2
2
 
3
3
  ## Change Log
4
4
 
5
+ ## 1.8.4
6
+
7
+ * Bug fix: Allow default value as hash for json columns (#195)
8
+
5
9
  ## 1.8.3
6
10
 
7
11
  * Don't modifiy migration column options hashes (#191). Thanks to [@lowjoel](https://github.com/lowjoel)
data/README.md CHANGED
@@ -258,6 +258,12 @@ resolves to:
258
258
  NOW() # PostgreSQL
259
259
  (DATETIME('now')) # SQLite3
260
260
  invalid # MySQL
261
+
262
+ If you are using Postgresql with a `json` column, the default value may be an unadorned hash. A hash having just one key `:expr` or `:value` will be taken as schema_plus syntax; i.e, these two are equivalent:
263
+
264
+ t.json :fields, default: { field1: 'a', field2: 'b' }
265
+ t.json :fields, default: { value: { field1: 'a', field2: 'b' } }
266
+
261
267
 
262
268
  ### Column Defaults: Using
263
269
 
@@ -199,7 +199,7 @@ module SchemaPlus
199
199
  if options_include_default?(options)
200
200
  default = options[:default]
201
201
 
202
- if default.is_a? Hash
202
+ if default.is_a? Hash and [[:expr], [:value]].include?(default.keys)
203
203
  value = default[:value]
204
204
  expr = sql_for_function(default[:expr]) || default[:expr] if default[:expr]
205
205
  else
@@ -1,3 +1,3 @@
1
1
  module SchemaPlus
2
- VERSION = "1.8.3"
2
+ VERSION = "1.8.4"
3
3
  end
@@ -24,7 +24,7 @@ Gem::Specification.new do |s|
24
24
  s.add_dependency("activerecord", ">= 3.2", "< 4.3")
25
25
  s.add_dependency("valuable")
26
26
 
27
- s.add_development_dependency("schema_dev", "~> 1.2", ">= 1.2.5")
27
+ s.add_development_dependency("schema_dev", "~> 1.4")
28
28
  s.add_development_dependency("rake")
29
29
  s.add_development_dependency("rspec", "~> 3.0.0")
30
30
  s.add_development_dependency("rdoc")
@@ -49,6 +49,13 @@ describe ActiveRecord::Migration do
49
49
  expect(@model.create.reload.bool).to be true
50
50
  end
51
51
 
52
+ it "should properly handle default values for json (#195)", :postgresql => :only do
53
+ recreate_table(@model) do |t|
54
+ t.json :json, :default => {}
55
+ end
56
+ expect(@model.create.reload.json).to eq({})
57
+ end if ActiveRecord::VERSION::MAJOR >= 4
58
+
52
59
  it "should create auto foreign keys" do
53
60
  recreate_table(@model) do |t|
54
61
  t.integer :user_id
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: schema_plus
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.3
4
+ version: 1.8.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ronen Barzel
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-01-13 00:00:00.000000000 Z
12
+ date: 2015-01-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord
@@ -51,20 +51,14 @@ dependencies:
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '1.2'
55
- - - ">="
56
- - !ruby/object:Gem::Version
57
- version: 1.2.5
54
+ version: '1.4'
58
55
  type: :development
59
56
  prerelease: false
60
57
  version_requirements: !ruby/object:Gem::Requirement
61
58
  requirements:
62
59
  - - "~>"
63
60
  - !ruby/object:Gem::Version
64
- version: '1.2'
65
- - - ">="
66
- - !ruby/object:Gem::Version
67
- version: 1.2.5
61
+ version: '1.4'
68
62
  - !ruby/object:Gem::Dependency
69
63
  name: rake
70
64
  requirement: !ruby/object:Gem::Requirement