question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Postgres enum values

See original GitHub issue

It seems that enum values when using postgres are not supported. Maybe even the Data API does not support enums in stringValue parameters (I just asked AWS about this).

Similar problem with jsonb type: https://github.com/jeremydaly/data-api-client/issues/34

Workaround:

I managed to get enums working by wrapping the value in a function (which tells typeorm to pass it as raw - so it avoids parameters)

example:

status: () => `'${Status.PENDING}'`,

// instead of
status: Status.PENDING,

What also works is casting (mentioned in the linked issue):

UPDATE property SET status=:status::property_status_enum

(enum name in schema is property_status_enum and passed query parameters: {status: 'pending'})

Casting requires you to use raw queries which kind of goes against typeorm workflow. Could this casting be implemented in this driver or somewhere else? @ArsenyYankovsky

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:6
  • Comments:28 (11 by maintainers)

github_iconTop GitHub Comments

5reactions
nimrodkorcommented, Aug 2, 2020

Would love this feature too @ArsenyYankovsky

4reactions
ArsenyYankovskycommented, Apr 2, 2021

@seawatts @davingreen I just released a driver with a fix for this (2.0.4). You also don’t have to use my fork anymore since new TypeORM 0.3.32 was released. Feel free to comment here or open a new issue if something doesn’t work.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Documentation: 15: 8.7. Enumerated Types - PostgreSQL
Enumerated (enum) types are data types that comprise a static, ordered set of values. They are equivalent to the enum types supported in...
Read more >
SQL query to get all values a enum can have - Stack Overflow
You can get all the enum values for an enum using the following query. The query lets you pick which namespace the enum...
Read more >
Looking up Enum types and values in Postgres - Sadique Ali
Postgres ' Enum, like their counterparts in many programming languags are data types that allow only a predefined set of values to be...
Read more >
Dealing with Enum Type in PostgreSQL - DEV Community ‍ ‍
It is treated as type in PostgreSQL · It applies to all tables in same schema · It has static values · Enum...
Read more >
How enum Works in PostgreSQL? (Examples) - eduCBA
PostgreSQL enum is the data type that was used in PostgreSQL to store same type of values in the column field, we can...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found