JordanMarr / SqlHydra

SqlHydra is a suite of NuGet packages for working with databases in F# including code generation tools and query expressions.
MIT License
212 stars 20 forks source link

Support arrays #99

Closed jwosty closed 6 days ago

jwosty commented 6 days ago

It would be nice-to-have if SqlHydra supported other array types (specifically I'm using the npgsql adapter). Note that bytea is already supported

Example schema:

CREATE TABLE foo
(
    id uuid NOT NULL DEFAULT gen_random_uuid(),
    some_data text[] NOT NULL
);

Not a showstopper; obviously the workaround is just to normalize this kind of data into actual relations.

JordanMarr commented 6 days ago

Hmm... I thought it already did support postgres arrays. For example, in npgsql, your generated code should include array types: https://github.com/JordanMarr/SqlHydra/blob/3525f6a2839e5c839417f447c83669fb24f495fd/src/Tests/Npgsql/AdventureWorksNet8.fs#L7523

JordanMarr commented 6 days ago

Also, the npgsql generation code should add array mappings programmatically: https://github.com/JordanMarr/SqlHydra/blob/3525f6a2839e5c839417f447c83669fb24f495fd/src/SqlHydra.Cli/Npgsql/NpgsqlDataTypes.fs#L59

jwosty commented 6 days ago

Oh, looks like I was using an older version of sqlhydra CLI in this particular project without realizing it. Yup, confirming that this does work fine.