All Downloads are FREE. Search and download functionalities are using the official Maven repository.

app.cash.sqldelight.dialects.postgresql.grammar.mixins.ColumnDefMixin.kt Maven / Gradle / Ivy

There is a newer version: 2.0.2
Show newest version
package app.cash.sqldelight.dialects.postgresql.grammar.mixins

import app.cash.sqldelight.dialects.postgresql.grammar.psi.PostgreSqlTypeName
import com.alecstrong.sql.psi.core.psi.SqlColumnDef
import com.alecstrong.sql.psi.core.psi.impl.SqlColumnDefImpl
import com.intellij.lang.ASTNode

internal class ColumnDefMixin(node: ASTNode) : SqlColumnDefImpl(node), SqlColumnDef {

  override fun hasDefaultValue(): Boolean {
    return isSerial() || super.hasDefaultValue()
  }
}

private fun SqlColumnDef.isSerial(): Boolean {
  val typeName = columnType.typeName as PostgreSqlTypeName
  return typeName.smallSerialDataType != null || typeName.serialDataType != null || typeName.bigSerialDataType != null
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy