Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default value in TableDefinition causes no parameter $1 when creating table #20

Open
janvladimirmostert opened this issue Feb 4, 2019 · 0 comments

Comments

@janvladimirmostert
Copy link

This happens on Postgres, haven't tried it on other databases.

I create a test table, notice the .default("TEST123") on the name-column:

    object TestEntity : TableDefinition(name = "test") {
        val id = integer("id").autoIncrement().primaryKey()
        val name = varchar("name", 50).default("TEST123")
    }

Now when I try and use this TableDefinition to generate a scema:

val trans = DatabaseHandler.createTransaction()
trans.databaseSchema().create(listOf(TestEntity))

I get the following error:

Exception in thread "main" org.postgresql.util.PSQLException: ERROR: there is no parameter $1
CREATE TABLE IF NOT EXISTS test (id SERIAL NOT NULL, name VARCHAR(50) NOT NULL DEFAULT ?, CONSTRAINT PK_test PRIMARY KEY (id))
Arguments: [SQLArgument(index=0, value=TEST123)]

    at org.jetbrains.squash.drivers.JDBCTransaction.executeStatement(JDBCTransaction.kt:87)
    at org.jetbrains.squash.schema.DatabaseSchemaBase.create(DatabaseSchemaBase.kt:12)
    at Tables.main(Tables.kt:14)
Caused by: org.postgresql.util.PSQLException: ERROR: there is no parameter $1
    at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2440)
    at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2183)
    at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:308)
    at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:441)
    at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:365)
    at org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgPreparedStatement.java:143)
    at org.postgresql.jdbc.PgPreparedStatement.execute(PgPreparedStatement.java:132)
    at org.jetbrains.squash.drivers.JDBCTransaction.executeStatement(JDBCTransaction.kt:75)
    ... 2 more
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant