-
-
Notifications
You must be signed in to change notification settings - Fork 93
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
Added support for PostgreSQL types: UUID, Array, JSONB and Money #84
Conversation
182350c
to
a995021
Compare
@@ -0,0 +1,82 @@ | |||
require 'rom/sql/types/pg' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these pg extensions should be opt-in, inferrer class can be set in relation, so we can use different inferrers for different dbs by calling schema_inferrer ROM::SQL::Schema::PGInferrer
in relation class
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How so? Can you please show me? Thanks 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
something like this https://gist.github.com/flash-gordon/901b94a9af623952f1babca50d7b8cd9 /cc @solnic can have some thought on this too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But then the problem becomes to explicit setup it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm also afraid that insertion of array values wouldn't work, at least this is what I came across today trying to use an array type in a manually maintained schema. I'll have a deeper look into this tomorrow |
You're right, it wraps the array like this: |
@flash-gordon It looks like |
We can give it a shot. The only potential problem we may face is lack of On 18 September 2016 at 10:01:39, Nikita Shilnikov (notifications@github.com)
|
what with other db systems (other that pg?) for me it should be some kind of plugin, you can require manually. |
@gotar I'm working on this atm, going to have a preview this weekend |
b24d6c5
to
8d3e6e4
Compare
8d3e6e4
to
f17cd20
Compare
@jodosha I force pushed the branch onto your repo, now I'm going to move some stuff here and there, then I'll let you know when it's ready or if I get any questions. The main thing, you probably already know about, is that I want to wrap all PG-specific code into an automatically activated extension |
Also ColumnInferrer was merged into PostgresInferrer
So that it is possible in insert an empty array without a DB complaining
JSON = Array | Hash | ||
JSONOp = Dry::Types::Definition | ||
.new(Sequel::Postgres::JSONOp) | ||
.constructor(Sequel.method(:pg_json)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is it :pg_json
method?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See Sequel's docs. TLDR Sequel allows to pass various values as a JSON(B) value but they are must be wrapped with pg_json
call beforehand.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah gotcha
This looks good. Pls merge <3 |
🎉 |
/cc @solnic @flash-gordon