Can JOOQ alias a Liquibase JSONB data type for H2/Postgresql - postgresql

I'm using this H2 feature to create an alias for JSONB in the jdbc string:
spring.datasource.url: jdbc:h2:mem:testdb;INIT=create domain if not exists jsonb as text;MODE=PostgreSQL
But JOOQs' codegen liquibase support (generator pointed at liquibase files) doesn't recognize the JSONB column type.
and I keep getting:
Reason: liquibase.exception.DatabaseException: Unknown data type: "JSONB";
Is there a way to tell the generator to alias this data type to TEXT?

You can try to init your h2 with CREATE TYPE "JSONB" AS json

Related

Ora2PG REPLACE_AS_BOOLEAN property and exclude one column by replacing

I'm using ora2pg to import an oracle db schema into a postgresql db schema. I configured all in the correct way and I'm able to dump the oracle dn into the postgresql db.
In the schema that I'm converting I have some columns number(1,0) that I need to convert as boolean in the pg schema.
At first I used this configuration
REPLACE_AS_BOOLEAN NUMBER:1
so every column with this type will be conmverted as boolean in the pg db.
The problem is that I have a column in the oracle schema defined as number(1,0). This column has to remain numeric and maintain the same type on the pg schema, so it hasn't to be converted as boolean.
This means that i changed the property in this manner
REPLACE_AS_BOOLEAN TABLE1:COLUMN1 TABLE2:COLUMN2 TABLE3:COLUMN3
I have a lot of columns that they have to be converted as boolean and the definition of this property became very long.
Is there a method to define the REPLACE_AS_BOOLEAN property to replace all the column with type number(1,0), but with some exception for one or some of them?
I had to wrote the property with the list of all the tables name and columns name

How to use a custom postgresql type in seaORM?

I have the following table in postgres
create table retailers(id: integer, name: citext);
citext is just case insensitive text in postgres. How do I modify the Entity creation in SeaORM to support that?
When I generate entities in SeaORM in rust, I get the following error:
error: Missing macro attribute, either `string_value` or `num_value` should be specified or specify repr[X] and have a value for every entry
--> src/entity/sea_orm_active_enums.rs:10:5
How do I "register" new types in seaORM in Rust?

JSONB PostgreSQL with jOOQ 3.10

How can I write String variable to PostgreSQL JSONB column without generated classes using jOOQ 3.10?
dsl.insertInto(table, Arrays.asList(
DSL.field("configuration")
))
.values(
data.getConfiguration()
).execute();
I have a json string into data.getConfiguration(), but I get exception
org.postgresql.util.PSQLException: ERROR: column "configuration" is of type jsonb but expression is of type character varying
The answer is the same as for your previous question. Write a data type binding (or better: upgrade your jOOQ version!).
DSL.field(name("jsonb_column"),
SQLDataType.VARCHAR.asConvertedDataType(new MyJSONBBinding()));
The manual link on the previous answer I've given shows how to do exactly that.

How to map an Array of JSON (of Postgres) into GORM objects and how to process them?

I am mapping a Postgres table into Golang's GORM Framework.
How to map the following column type in Postgres?
doc json[] DEFAULT ARRAY[]::json[]
And how do I modify it with GORM?

Explicit jsonb type cast in Squeryl

I'm using Squeryl 0.9.5-7 and Postgres 9.4 with jsonb datatype and want to insert some data:
case class Log(id: String, meta: String) //meta will contain json
val logs = table[Log]
logs.insert(Log(randomId, "{\"Hi\": \"I'm a json!\"}"))
But got a typecast error that says "Column meta has jsonb type but expression has character varying type. Rewrite expression or convert it's type."
How can I explicitly cast my String field into jsonb so that raw sql-parameter will look like ?::jsonb?
And then, it's interesting how to write json-queries such as #> or ->> with Squeryl?
I found a better way, that doesn't require to create a CAST in the database.
If you're using squeryl 0.9.6, you can add an explicit cast in your schema which tells squeryl to explicitly cast your string into a jsonb.
on(logs)(s => declare(
s.meta is (dbType("jsonb").explicitCast) // enables explicit casting into jsonb
))
With Squeryl 0.9.6 you can register support for your own custom types. Here's an example. For non standard operators, take a look at custom functions
In my experience with postgres 9.4, reading works fine as a Squeryl String but inserting fails with:
ERROR: column "****" is of type json but expression is of type
character varying [error] Hint: You will need to rewrite or cast the
expression. [error] Position: 166 [error] errorCode: 0, sqlState:
42804
So, the solution I found is to create a 'AS ASSIGNMENT' cast in my postgres database and that does the trick:
CREATE CAST(VARCHAR AS JSON)
WITH INOUT
AS ASSIGNMENT