package com.intellisrc.db.jdbc

/**
 * @since 18/06/15.
 */
class FirebirdTest extends JDBCTest {

    String getTableCreate(String name = "test") {
        return """CREATE TABLE $name (
                id INTEGER GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
                name VARCHAR(10) NOT NULL UNIQUE,
                version FLOAT,
                active BOOLEAN,
                updated DATE
        );"""
    }

    String getTableCreateMultiplePK(String name) {
        return """CREATE TABLE ${name} (
                  uid INTEGER NOT NULL,
                  gid INTEGER NOT NULL,
                  name VARCHAR(30) NOT NULL,
                  PRIMARY KEY (gid,uid)
        )"""
    }

    /**
     * Launch test:
     * docker run --name firebird -e ISC_PASSWORD=test -e FIREBIRD_DATABASE=test -e FIREBIRD_USER=test -e FIREBIRD_PASSWORD=test -p 127.0.0.1:33050:3050 -d jacobalberty/firebird:3.0
     *
     * You can use the `launch_dbs_for_testing.sh` script located in /modules/db/ to launch it.
     *
     * @return
     */
    @Override
    JDBC getDB() {
        return new Firebird(
            user    : "test",
            hostname: "127.0.0.1",
            password: "test",
            dbname  : "/firebird/data/test",
            port    : 33050
        )
    }
}