Giter VIP home page Giter VIP logo

sqlc-gen-kotlin's People

Contributors

andrewmbenton avatar dependabot[bot] avatar kyleconroy avatar toru-takagi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

sqlc-gen-kotlin's Issues

Is it a specification for sqlc that retrieving null from a nullable boolean column in Postgres results in false?

When creating a boolean (nullable) column in Postgres.

When generating code from SQL that retrieves this column, it becomes results.getBoolean() .
Reading ResultSet.java, it states

"Returns: the column value; if the value is SQL NULL, the value returned is false."

Ideally, if the table contains null, I would like it to return null.

I would like to hear the maintainer's opinion on this.

Kotlin generator doesn't work with named parameters

Version

1.12.0

What happened?

Tried to use named parameters with the Kotlin code generator, but ran into an error. I recreated the issue in the unit tests and came to know that Kotlin enforces the use of positional parameters with the Postgres engine.

Is it possible to get some guidance on which specific areas of the Kotlin code generator I should look at to add support for named parameters

Relevant log output

src/main/resources/authors/postgresql/query.sql:1:1: edited query syntax is invalid: syntax error at or near "dentifivation"
            src/main/resources/authors/postgresql/query.sql:10:1: edited query syntax is invalid: syntax error at or near "ame"
            src/main/resources/authors/postgresql/query.sql:18:1: edited query syntax is invalid: syntax error at or near "d"

Database schema

CREATE TABLE authors (
          id   BIGSERIAL PRIMARY KEY,
          name text      NOT NULL,
          bio  text
);

SQL queries

-- name: GetAuthor :one
SELECT * FROM authors
WHERE id = @identifivation LIMIT @lim;

-- name: ListAuthors :many
SELECT * FROM authors
ORDER BY name;

-- name: CreateAuthor :one
INSERT INTO authors (
          name, bio
) VALUES (
  @name, @bio
)
RETURNING *;

-- name: DeleteAuthor :exec
DELETE FROM authors
WHERE id = @id;

Configuration

{
  "version": "2",
  "sql": [
    {
      "schema": "postgresql/schema.sql",
      "queries": "postgresql/query.sql",
      "engine": "postgresql",
      "gen": {
        "go": {
          "package": "authors",
          "out": "postgresql"
        }
      }
    }
  ]
}

Playground URL

No response

What operating system are you using?

macOS

What database engines are you using?

PostgreSQL

What type of code are you generating?

Kotlin

Missing return statement in :execrows generated code

When using the plugin to generate Kotlin output for :execrows queries with MySql return statements are missing and the resulting files wont compile.

If I look at the template code it looks like the generated code should start with return return conn.prepareStatement however when using the plugin (from the github release or the sqlc release the return statement is not present and the code wont compile.

The source zips for the release do seem to have a return statement.
The following example shows the generated output I'm seeing in QueriesImpl.kt

 @Throws(SQLException::class)
  override fun updateMyRow(newDesc: String, theKey: String): Int {
    conn.prepareStatement(setStateByDdaToken).use { stmt ->
      stmt.setString(1, newDesc)
          stmt.setString(2, theKey)

      stmt.execute()

      stmt.updateCount
    }
  }

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.