[Question] Are composite types defined in PostgreSQL supported by SQLProvider?

Open
#427 12 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

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

Research direction

Start with PostgreSQLTests.fsx and trace how SQLProvider discovers and represents stored-procedure parameters. Compare the reported composite-type signature with the existing PostgreSQL type examples and the Npgsql workaround. Done means establishing whether composite types are supported and documenting or testing the required mapping or limitation.

Written by the indexing model from the issue text.

Description

enhancement postgresql
Description

Database has composite types defined which are input/output types to stored procedures. I am attempting to call the said procedure with input parameters. SqlProvider does not see the input parameter and assumes it is a void function.

Repro steps

The composite type defined in the database is

CREATE TYPE product_t AS
   (name text,
    product_type text)

The signature of procedure in the database is

create or replace function func_iproduct( p product_t ) returns void as

On .NET side (F#), I have created a type

type PgProductType(Name:string,ProductType:string)=
  member this.Name = Name 
  member this.ProductType = ProductType
  new() = PgProductType("","")

I believe there should be a way in which I could tell SqlProvider how to map PgProductType to product_t; not sure if this is required or such mapping is automatic. If required, an example how do I go about doing it would be helpful. Without this mapping, if I attempt to execute the procedure, the error message it reports back indicates that SqlProvider does NOT see the input parameter;

let prd = new PgProductType("F#Product","")
ctx.Functions.FuncIproduct.Invoke(prd)

stdin(29,1): error FS0501: The member or object constructor 'Invoke' takes 0 argument(s) but is here given 1. The required signature is 'SqlDataProvider<...>.dataContext.Functions.FuncIproduct.Result.Invoke() : Unit'.

Question

  1. Can I use postgresql composite types? If so, an illustrative example would help.The test suite PostgreSQLTests.fsx does not contain an example to map custom types (though there are examples to map pre-defined postgresql types).
  2. Any alternative solution short of re-implementing queries (using query expressions) foregoing the existing procedures?
Known workarounds

Directly use Npgsql

Related information
  • PostgreSQL 9.6
  • Win 7
Dominant language
F#
Stars
627
Forks
147
Avg merge
2h 2m
Merged PRs (30d)
1

Contributor guide

No contributing guide indexed for this repository

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 fsprojects/SQLProvider

All issues in fsprojects/SQLProvider

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.