Skip to content

Bind parameter DEFAULT is replaced with ? #3374

@hfhbd

Description

@hfhbd

SQLDelight Version

master #af1e04406489a324d3e53efcf68700cc88e9844d

Operating System

nA

Gradle Version

nA

Kotlin Version

1.7.10

Dialect

HSql (and PostgreSQL after merge)

AGP Version

No response

Describe the Bug

Given sql:

CREATE TABLE dog (
  name VARCHAR(8) NOT NULL,
  breed VARCHAR(40) NOT NULL,
  is_good BOOLEAN DEFAULT TRUE NOT NULL
);

insertDog:
INSERT INTO dog
VALUES (?, ?, DEFAULT);
public fun insertDog(
    name: String,
    breed: String,
    is_good: Boolean,
  ): Unit {
    driver.execute(2111717998, """
        |INSERT INTO dog (name, breed, is_good)
        |VALUES (?, ?, ?)
        """.trimMargin(), 3) {
          check(this is JdbcPreparedStatement)
          bindString(0, name)
          bindString(1, breed)
          bindLong(2, if (is_good) 1L else 0L)
        }
    notifyQueries(2111717998) { emit ->
      emit("dog")
    }
  }

Expected:

public fun insertDog(
  name: String,
  breed: String
): Unit {
  driver.execute(2111717998, """
      |INSERT INTO dog (name, breed, is_good)
      |VALUES (?, ?, DEFAULT)
      """.trimMargin(), 2) {
        check(this is JdbcPreparedStatement)
        bindString(0, name)
        bindString(1, breed)
      }
  notifyQueries(2111717998) { emit ->
    emit("dog")
  }
}

Stacktrace

No response

Gradle Build Script

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions