greg-rychlewski

greg-rychlewski

PostgrexTextExt: Text Extensions for Postgrex

Hi,

I’ve created a small helper library called PostgrexTextExt. It allows users to enable text protocol encoding/decoding in Postgrex for any PostgeSQL data type they choose, even if Postgrex doesn’t currently support it.

Github: GitHub - greg-rychlewski/postgrex_text_ext · GitHub
Hex: PostgrexTextExt — PostgrexTextExt v0.1.0

I created it based on some edge cases I saw while helping with Ecto over the past year. In particular, it seems like it helps in the following cases:

I started off wanting to make an extension just for OIDs, but then I realized with very little effort you can make it work for any type.

How it’s used:

  1. Specify the data types in your configuration
  config :postgrex_text_ext,
    type_names: ["regconfig", "ltree"],
    type_outputs: ["range_out"]

There are 2 levels of granularity: type name and type output. These correspond to the typname and typoutput columns in the pg_type system catalog.

A list of type names and outputs is provided here. You may also use the pg_type system catalog: SELECT typname, typoutput FROM pg_type;.

  1. Define a custom type module, as needed by Postgrex
Postgrex.Types.define(MyApp.PostgrexTypes, [PostgrexTextExt], [])

Where Next?

Popular in Announcing Top

zorbash
I created Kitto a framework for dashboards inspired by Dashing. The distributed characteristics of Elixir and the low memory footprint...
New
bryanjos
Hi, I just published version 0.23.0 of Elixirscript. https://github.com/bryanjos/elixirscript/blob/master/CHANGELOG.md Most of the chan...
New
OvermindDL1
I created a new library (rather I pulled out a couple files from my big project), it manages an operating system PID file for the BEAM. ...
New
RobertDober
Earmark is a pure-Elixir Markdown converter. It is intended to be used as a library (just call Earmark.as_html), but can also be used as...
239 12978 134
New
msaraiva
Surface is an experimental library built on top of Phoenix LiveView and its new LiveComponent API that aims to provide a more declarative...
564 44265 214
New
woylie
Flop is an Elixir library that applies filtering, ordering and pagination parameters to your Ecto queries. offset-based pagination with...
New
martinthenth
Hello everybody :wave: Recently, some of my colleagues talked about database ids and uuids and their problems, and I remembered the pain...
New

Other popular topics Top

aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
dogweather
I wrote this comment on r/haskell, and it’s not popular there. :wink: But I think I’m on to something… Haskell reminds me of Java, and e...
New
gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
New
sorentwo
Hello! tl;dr Announcing Oban, an Ecto based job processing library with a focus on reliability and historical observability. After spen...
985 44778 311
New
albydarned
Hello all! I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New

We're in Beta

About us Mission Statement