Comments (12)
Ok I see what needs to happen:
testTask "Insert Enum ADONET" {
use conn = new Npgsql.NpgsqlConnection(connectionString)
use cmd = conn.CreateCommand()
cmd.CommandText <-
"""
INSERT INTO experiments.person (name, current_mood)
VALUES (@name, @mood::mood)
"""
let pName = cmd.CreateParameter()
pName.ParameterName <- "@name"
pName.Value <- "john doe"
cmd.Parameters.Add pName |> ignore
let pMood = cmd.CreateParameter()
pMood.ParameterName <- "@mood"
pMood.Value <- "happy"
cmd.Parameters.Add pMood |> ignore
conn.Open()
let! results = cmd.ExecuteNonQueryAsync()
Expect.isTrue (results > 0) ""
}
from sqlhydra.
That sounds doable as long as there is a way to query the custom types.
It may be possible through the NpgslConnection
GetSchema
method; otherwise, we will need a query to get it.
from sqlhydra.
I got it working already (with strings).
It would cool to have it generate a discriminated union for each enum type, but that's for another day.
Will let you know when this is ready on NuGet.
from sqlhydra.
SqlHyrda.Npgsql v0.800.1 is published.
Let me know if that causes any issues with inserts/updates.
from sqlhydra.
I assume this is resolved so closing.
from sqlhydra.
Sorry, I should have gotten back to you sooner... I get an Npgsql.PostgresException
when attempting to insert a column:
Npgsql.PostgresException (0x80004005): 42804: column "color" is of type colors but expression is of type text
Basically, any string being inserted needs to be typecasted to the proper enum type like the following:
SELECT 'blue'::colors;
** EDIT **: Changed "blue"
to 'blue'
from sqlhydra.
Any chance that it could it be a case-sensitivity issue?
from sqlhydra.
I think I would have gotten a different error had it been a case-sensitivity issue:
db=# CREATE TYPE colors AS ENUM ('red', 'green', 'blue');
CREATE TYPE
db=# SELECT 'Blue'::colors;
ERROR: invalid input value for enum colors: "Blue"
LINE 1: SELECT 'Blue'::colors;
db=# SELECT 'blue'::colors;
colors
--------
blue
(1 row)
from sqlhydra.
I don't know if this helps or not, but here's me creating a table and inserting a row from the psql command line:
db=# CREATE TABLE cars (color colors);
CREATE TABLE
db=# INSERT INTO cars (color) VALUES ('blue');
INSERT 0 1
db=# SELECT * FROM cars;
color
-------
blue
(1 row)
from sqlhydra.
This is going to be really cool... 😎
from sqlhydra.
New release!
https://github.com/JordanMarr/SqlHydra/releases/tag/v0.810.0
You will need to manually register the generated enums with Npgsql (at least for now).
from sqlhydra.
Added a caveat that you may need to watch out for in the release notes.
I filed an npgsql issue.
from sqlhydra.
Related Issues (20)
- Missing oracle timestamp datatypes HOT 5
- Feature Request: Upserting multiple records to a single statement HOT 2
- New "Query Logging" feature doesn't capture inserts properly HOT 1
- Some `where` property comparisons do not create a `QueryParameter` HOT 1
- Make a selected column from a leftJoined table option with `Some`
- Support net8.0 HOT 17
- Add documentation and setup configuration on how to clone the repo, build the project, and run tests. HOT 2
- Creating sqlhydra file updates the wrong .fsproj file HOT 9
- SQL Server Temporal Tables Select Issue HOT 8
- Retrieve Multiple result sets (UNION ALL) using SqlHydra.Query HOT 1
- Insert and Update Builders break when column name is the same as another table. HOT 2
- Mapping object with list of objects 1 to n relationship HOT 4
- Best practice for multiple environments and the config.toml file HOT 7
- Design patterns for DDD HOT 8
- Is it possible to support materialized views from Postgres? HOT 22
- Generate types in GitHub workflow generates no table types HOT 5
- Show filter info in SqlHydra.Cli command line output HOT 1
- Custom pooling with SqlHydra HOT 8
- SqlHydra.Cli doesn't map Sqlite longvarchar column types HOT 5
- Error after upgrading V2.5.0: 'Microsoft.FSharp.Core.FSharpOption`1 is not a F# record type. HOT 9
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sqlhydra.