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

Commit

Permalink
Merge pull request #80 from tomeara/extra_props_in_jsonb
Browse files Browse the repository at this point in the history
extra_props field can use JSONB
  • Loading branch information
nelhage committed Nov 11, 2014
2 parents ef5f293 + 324d8f8 commit 9b0fbfe
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,8 @@ If it encounters a MongoDB object with fields not listed in the
collection map, it will discard the extra fields, unless
`:extra_props` is set in the `:meta` hash. If it is, it will collect
any missing fields, JSON-encode them in a hash, and store the
resulting text in `_extra_props` in SQL.
resulting text in `_extra_props` in SQL. You can set `:extra_props`
to use `JSON`, `JSONB`, or `TEXT`.

As of PostgreSQL 9.3, you can declare columns as type "JSON" and use
the [native JSON support][pg-json] to inspect inside of JSON-encoded
Expand Down
9 changes: 6 additions & 3 deletions lib/mosql/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,13 @@ def create_schema(db, clobber=false)
primary_key keys
if meta[:extra_props]
type =
if meta[:extra_props] == "JSON"
"JSON"
case meta[:extra_props]
when 'JSON'
'JSON'
when 'JSONB'
'JSONB'
else
"TEXT"
'TEXT'
end
column '_extra_props', type
end
Expand Down

0 comments on commit 9b0fbfe

Please sign in to comment.