#!/usr/bin/env tclsh

set testdir [file dirname $argv0]
source $testdir/tester.tcl

do_execsql_test_on_specific_db {:memory:} default-value-text {
    CREATE TABLE t1 (x INTEGER PRIMARY KEY, y TEXT DEFAULT 'default_value');
    INSERT INTO t1 (x) VALUES (1);
    SELECT y FROM t1 WHERE x = 1;
} {default_value}

do_execsql_test_on_specific_db {:memory:} default-value-integer {
    CREATE TABLE t2 (x INTEGER PRIMARY KEY, y INTEGER DEFAULT 42);
    INSERT INTO t2 (x) VALUES (1);
    SELECT y FROM t2 WHERE x = 1;
} {42}

do_execsql_test_on_specific_db {:memory:} default-value-real {
    CREATE TABLE t3 (x INTEGER PRIMARY KEY, y REAL DEFAULT 3.14);
    INSERT INTO t3 (x) VALUES (1);
    SELECT y FROM t3 WHERE x = 1;
} {3.14}

do_execsql_test_on_specific_db {:memory:} default-value-null {
    CREATE TABLE t5 (x INTEGER PRIMARY KEY, y TEXT DEFAULT NULL);
    INSERT INTO t5 (x) VALUES (1);
    SELECT y FROM t5 WHERE x = 1;
} {}

do_execsql_test_on_specific_db {:memory:} default-value-boolean {
    CREATE TABLE t6 (x INTEGER PRIMARY KEY, y BOOLEAN DEFAULT 1);
    INSERT INTO t6 (x) VALUES (1);
    SELECT y FROM t6 WHERE x = 1;
} {1}

do_execsql_test_on_specific_db {:memory:} default-value-function {
    CREATE TABLE t7 (x INTEGER PRIMARY KEY, y INTEGER DEFAULT (ABS(-5)));
    INSERT INTO t7 (x) VALUES (1);
    SELECT y FROM t7 WHERE x = 1;
} {5}

do_execsql_test_on_specific_db {:memory:} default-value-identifier {
    CREATE TABLE t7 (x INTEGER PRIMARY KEY, y DEFAULT asdf);
    INSERT INTO t7 (x) VALUES (1);
    SELECT y FROM t7 WHERE x = 1;
} {asdf}
