Giter Site home page Giter Site logo

Comments (2)

griffio avatar griffio commented on June 30, 2024

🤔 I will try and create a PR to test out a fix 🛠️

There are at-least three ways that could be implemented to set the parameter and type in JDBC to keep the generated data class field as a String type

  • ?::jsonb
  • PGobject - type "jsonb"
  • setObject(index, obj, Types.OTHER)

setObject with types.OTHER appears to be the most viable in the current code base.
💡 A new support method bindObjectOther in

would be needed and a cursor mapping from a new JSON enum type to a String

 JSON -> "$cursorName.getString($columnIndex)"

in

override fun prepareStatementBinder(columnIndex: CodeBlock, value: CodeBlock): CodeBlock {
return CodeBlock.builder()
.add(
when (this) {
SMALL_INT -> "bindShort"
INTEGER -> "bindInt"
BIG_INT -> "bindLong"
DATE, TIME, TIMESTAMP, TIMESTAMP_TIMEZONE, INTERVAL, UUID -> "bindObject"
NUMERIC -> "bindBigDecimal"
},
)
.add("(%L, %L)\n", columnIndex, value)
.build()
}
override fun cursorGetter(columnIndex: Int, cursorName: String): CodeBlock {
return CodeBlock.of(
when (this) {
SMALL_INT -> "$cursorName.getShort($columnIndex)"
INTEGER -> "$cursorName.getInt($columnIndex)"
BIG_INT -> "$cursorName.getLong($columnIndex)"
DATE, TIME, TIMESTAMP, TIMESTAMP_TIMEZONE, INTERVAL, UUID -> "$cursorName.getObject<%T>($columnIndex)"
NUMERIC -> "$cursorName.getBigDecimal($columnIndex)"
},
javaType,

from sqldelight.

OfekTeken avatar OfekTeken commented on June 30, 2024

@griffio I also encountered this issue, and if I remember correctly, this fixed it for now:
CAST(:jsonColumn AS JSONB)
Of course it won't work here because the OP tried to insert using VALUES ?

from sqldelight.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.