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

com.tianyisoft.database.grammar.MysqlGrammar.kt Maven / Gradle / Ivy

The newest version!
package com.tianyisoft.database.grammar

import com.tianyisoft.database.Builder

class MysqlGrammar: Grammar() {
    override val operators = listOf("sounds like")

    override fun compileInsertOrIgnore(builder: Builder, values: List>): String {
        return compileInsert(builder, values).replaceFirst("insert", "insert ignore")
    }

    override fun compileUpsert(
        builder: Builder,
        values: List>,
        update: Map,
        uniqueBy: List
    ): String {
        val sql = compileInsert(builder, values) + " on duplicate key update "
        val columns = update.map {
            "${wrap(it.key)} = ${parameter(it.value)}"
        }.joinToString()
        return sql + columns
    }

    override fun compileRandom(seed: String): String {
        return "rand($seed)"
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy