Skip to content
This repository was archived by the owner on Dec 22, 2020. It is now read-only.

Commit 9b0fbfe

Browse files
committed
Merge pull request #80 from tomeara/extra_props_in_jsonb
extra_props field can use JSONB
2 parents ef5f293 + 324d8f8 commit 9b0fbfe

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,8 @@ If it encounters a MongoDB object with fields not listed in the
176176
collection map, it will discard the extra fields, unless
177177
`:extra_props` is set in the `:meta` hash. If it is, it will collect
178178
any missing fields, JSON-encode them in a hash, and store the
179-
resulting text in `_extra_props` in SQL.
179+
resulting text in `_extra_props` in SQL. You can set `:extra_props`
180+
to use `JSON`, `JSONB`, or `TEXT`.
180181

181182
As of PostgreSQL 9.3, you can declare columns as type "JSON" and use
182183
the [native JSON support][pg-json] to inspect inside of JSON-encoded

lib/mosql/schema.rb

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,13 @@ def create_schema(db, clobber=false)
101101
primary_key keys
102102
if meta[:extra_props]
103103
type =
104-
if meta[:extra_props] == "JSON"
105-
"JSON"
104+
case meta[:extra_props]
105+
when 'JSON'
106+
'JSON'
107+
when 'JSONB'
108+
'JSONB'
106109
else
107-
"TEXT"
110+
'TEXT'
108111
end
109112
column '_extra_props', type
110113
end

0 commit comments

Comments
 (0)