All Projects → reposilite-playground → exposed-upsert

reposilite-playground / exposed-upsert

Licence: Unlicense license
Upsert DSL extension for Exposed, Kotlin SQL framework

Programming Languages

kotlin
9241 projects

Projects that are alternatives of or similar to exposed-upsert

yii2-mariadb
MariaDB Driver for Yii2
Stars: ✭ 24 (+14.29%)
Mutual labels:  mariadb
dbclient
데이터배이스 관리 / 자동 메일링 / Admin 자동화 / Database IDE Tool. SQL Development Helper. Support DBMS Oracle/Mysql/MS-SQL
Stars: ✭ 35 (+66.67%)
Mutual labels:  mariadb
wp-docker
A docker environment for WordPress site development.
Stars: ✭ 42 (+100%)
Mutual labels:  mariadb
Python-Course
🐍 This is the most complete course in Python, completely practical and all the lessons are explained with examples, so that they can be easily understood. 🍫
Stars: ✭ 18 (-14.29%)
Mutual labels:  mariadb
ansible-role-mysql
An Ansible role that installs MySQL or MariaDB
Stars: ✭ 20 (-4.76%)
Mutual labels:  mariadb
mariadb
MariaDB docker container image
Stars: ✭ 42 (+100%)
Mutual labels:  mariadb
wnmp-dev
Development environment: Windows + nginx + MySQL + PHP
Stars: ✭ 52 (+147.62%)
Mutual labels:  mariadb
docker-iot-stack
💻 My personal Docker IoT Stack
Stars: ✭ 24 (+14.29%)
Mutual labels:  mariadb
ansible-role-phpmyadmin
Ansible Role - phpMyAdmin
Stars: ✭ 40 (+90.48%)
Mutual labels:  mariadb
sequelize-paper-trail
Sequelize plugin for tracking revision history of model instances.
Stars: ✭ 90 (+328.57%)
Mutual labels:  mariadb
Database-Naming-Convention
Database Naming Conventions & Best Practices
Stars: ✭ 76 (+261.9%)
Mutual labels:  mariadb
docker-db-backup
Backup mutltiple databases types on a scheduled basis with many customizable options
Stars: ✭ 302 (+1338.1%)
Mutual labels:  mariadb
LAMPP-Manager
A simple LAMPP manager designed to automate all the work.
Stars: ✭ 117 (+457.14%)
Mutual labels:  mariadb
go-graphkb
A Graph-oriented Knowledge Base written in Go
Stars: ✭ 25 (+19.05%)
Mutual labels:  mariadb
db-command
Performs basic database operations using credentials stored in wp-config.php.
Stars: ✭ 65 (+209.52%)
Mutual labels:  mariadb
datastation
App to easily query, script, and visualize data from every database, file, and API.
Stars: ✭ 2,519 (+11895.24%)
Mutual labels:  mariadb
mariadb-galera-swarm
Easy to use MariaDb Galera Cluster container based on official mariadb image with support for Docker Swarm Mode.
Stars: ✭ 193 (+819.05%)
Mutual labels:  mariadb
mariadb-cluster
MariaDB Galera cluster running on CoreOS using the official Docker images
Stars: ✭ 11 (-47.62%)
Mutual labels:  mariadb
docker-compose-all-mysql
MySQL and MariaDB docker containers of MySQL v5.5, v5.6, v5.7, v8.0, mariadb v10.0, v10.1, v10.2, v10.3
Stars: ✭ 105 (+400%)
Mutual labels:  mariadb
slonik-utilities
Utilities for manipulating data in PostgreSQL database using Slonik.
Stars: ✭ 22 (+4.76%)
Mutual labels:  upsert

Exposed Upsert CI codecov

Upsert DSL extension for Exposed, Kotlin SQL framework. Project bases on various solutions provided by community in the official "Exposed: Support upsert functionality" feature request. After 4 years, maintainers still didn't provide a solution, so here's a straightforward alternative.

  • Implements all dialects that support native upsert possibilities
  • Tested against real databases through dedicated Docker containers provided by Testcontainers
  • Licensed to public domain, you can do whatever you want with sources in this repository

Coverage

Supported databases with tests run against real databases using Testcontainers:

DB Status
H2 Unsupported
H2 (MySQL Dialect)
MySQL
MariaDB
Oracle Not implemented (Licensed to enterprise)
PostgreSQL
SQL Server Unsupported
SQLite

Usage

class StatisticsTable : Table("statistics") {
    // [...]
    
    val uniqueTypeValue = withUnique("unique_http_method_to_uri", httpMethod, uri)
}

StatisticsTable.upsert(conflictIndex = StatisticsTable.uniqueTypeValue,
    insertBody = {
        it[this.httpMethod] = record.httpMethod
        it[this.uri] = record.uri
        it[this.count] = record.count
    },
    updateBody = {
        with(SqlExpressionBuilder) {
            it.update(StatisticsTable.count, StatisticsTable.count + record.count)
        }
    }
)

Notes

  • Remember to keep the same order of fields in insert & upsert body
  • Default values are not supported (GH-3)
  • Upsert functionality between (MySQL, MariaDB, H2 with MySQL dialect) and (PostgreSQL, SQLite) are slightly different. To keep the compatibility between these databases, you should always use only one condition of uniqueness (unique column OR unique index). MySQL based dialects may handle multiple queries due to the better support provided by generic ON DUPLICATE KEY query.

Download

Gradle

repositories {
    maven { url 'https://repo.panda-lang.org/releases' }
}

dependencies {
    implementation 'net.dzikoysk:exposed-upsert:1.0.3'
}

Manual

You can find all available versions in the repository:

Who's using

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].