Support inferring custom-defined types

Open
#142 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Feature
Clarity
Needs clarification
Activity status
Stale
Tech stack
postgresql, ruby
Domain
databases

Research direction

Start by tracing how PostgreSQL column metadata is inspected and how the displayed :type value is inferred for the custom inventory_item column. The work is done when custom-defined types no longer produce a nil type and the expected behavior is covered by an appropriate test.

Written by the indexing model from the issue text.

Description

help wanted inferrer postgres

In PG you can define custom column types, ie like that:

CREATE TYPE inventory_item AS (
  name            text,
  supplier_id     integer,
  price           numeric
);

then specify a column like that:

column :composite1, 'inventory_item', default: Sequel.literal("ROW('fuzzy dice', 42, 1.99)")

This is what Sequel gives us about that column:

[:composite1, {:oid=>6663255, :db_type=>"inventory_item", :default=>"ROW('fuzzy dice'::text, 42, 1.99)", :allow_null=>true, :primary_key=>false, :type=>nil, :ruby_default=>nil}]

Refs hanami/model#370

Dominant language
Ruby
Stars
220
Forks
97
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from rom-rb/rom-sql

All issues in rom-rb/rom-sql

Similar issues

More Ruby issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.