New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSON vs JSONB - type default in schema builder #991

Closed
light24bulbs opened this Issue Sep 22, 2015 · 6 comments

Comments

Projects
None yet
3 participants
@light24bulbs
Contributor

light24bulbs commented Sep 22, 2015

Should JSONB be changed to the default type in the JSON schema builder? I'm having some truly wacky results with JSON and realized I should have been using JSONB. Postgres docs recommends it as the default choice for most applications.

In the interest of abstracting away from weird database quirks wherever possible, do you think JSONB should be the default?

@light24bulbs

This comment has been minimized.

Contributor

light24bulbs commented Sep 22, 2015

Hm actually this is probably left in as legacy support for everyone still running postgres 9.3 huh? It makes sense that the new type would be an opt in feature if it isn't widely supported.

@rhys-vdw

This comment has been minimized.

Collaborator

rhys-vdw commented Sep 23, 2015

I think it's reasonable to leave the responsibility of this decision to the users of knex, much as Postgres does for its users. Also what would you call the json type? legacyJson? Could cause more confusion.

@rhys-vdw rhys-vdw added the discussion label Sep 23, 2015

@elhigu

This comment has been minimized.

Collaborator

elhigu commented Sep 29, 2015

Could it be more clear to use if knex would have separate json and jsonb column types? They are quite different types with different behaviour and operators.

Current way of having to create jsonb column by setting it with boolean parameter is a bit awkward. It is like making biginteger column by creating integer column with extra boolean flag that says "this is actually biginteger column".

@light24bulbs

This comment has been minimized.

Contributor

light24bulbs commented Sep 29, 2015

Hmm, I agree. That's a small thing (no big deal) but it would make it more
explicit. Especially for people maintaining the migrations later on.

On Tue, Sep 29, 2015 at 12:57 PM, Mikael Lepistö notifications@github.com
wrote:

Could it be more clear to use if knex would have separate json and jsonb
column types? They are quite different types with different behaviour and
operators.

Current way of having to create jsonb column by setting it with boolean
parameter is a bit awkward. It is like making biginteger column by
creating integer column with extra boolean flag that says "this is
actually biginteger column".


Reply to this email directly or view it on GitHub
#991 (comment).

-Forrest

@rhys-vdw

This comment has been minimized.

Collaborator

rhys-vdw commented Sep 30, 2015

@elhigu, @light24bulbs: I also agree, will accept a PR adding jsonb column type to schema builder and adding deprecation message to schema.json when using boolean flag.

@elhigu

This comment has been minimized.

Collaborator

elhigu commented Nov 4, 2015

Fix didn't include deprecation message since it was most straight forward implementation which just calls this.json(name, true)

@elhigu elhigu closed this Jan 5, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment