<commit_before>use strict;
use warnings;
use lib 't/lib';

use Test::More;
use SQLite::TestUtils;

check_deps;

plan tests => 12;

sub check_tables {
    my ( $dbh ) = @_;

    local $Test::Builder::Level = $Test::Builder::Level + 1;

    my @tables = $dbh->tables(undef, undef, '%', 'TABLE');

    is_deeply \@tables, [];
}

my $ok;
my $dbh = create_dbh;

NO_EXTRA_COLS: {
    $ok = do {
        local $dbh->{'RaiseError'} = 0;

        $dbh->do(<<'END_SQL');
CREATE VIRTUAL TABLE attrs1 USING attributes;
END_SQL
    };

    ok($ok, 'creating an attribute table with no additional columns should succeed')
        or diag($dbh->errstr);

    check_schema($dbh, attrs1 => {
        attributes => 1,
    });

    $ok = do {
        local $dbh->{'RaiseError'} = 0;

        $dbh->do(<<'END_SQL');
DROP TABLE attrs1
END_SQL
    };

    ok($ok, 'dropping an attribute table should succeed')
        or diag($dbh->errstr);

    check_tables $dbh;
}

ONE_EXTRA_COL: {
    $ok = do {
        local $dbh->{'RaiseError'} = 0;

        $dbh->do(<<'END_SQL');
CREATE VIRTUAL TABLE attrs2 USING attributes(field1 TEXT);
END_SQL
    };

    ok($ok, 'creating an attribute table with an extra column should succeed')
        or diag($dbh->errstr);

    check_schema($dbh, attrs2 => {
        field1     => 1,
        attributes => 1,
    });

    $ok = do {
        local $dbh->{'RaiseError'} = 0;

        $dbh->do(<<'END_SQL');
DROP TABLE attrs2
END_SQL
    };

    ok($ok, 'dropping an attribute table should succeed')
        or diag($dbh->errstr);

    check_tables $dbh;
}

RENAMED_ATTR_COL: {
    $ok = do {
        local $dbh->{'RaiseError'} = 0;

        $dbh->do(<<'END_SQL');
CREATE VIRTUAL TABLE attrs3 USING attributes(a ATTRIBUTES);
END_SQL
    };

    ok($ok, 'creating an attribute table with a renamed attributes column should succeed')
        or diag($dbh->errstr);

    check_schema($dbh, attrs3 => {
        a => 1,
    });

    $ok = do {
        local $dbh->{'RaiseError'} = 0;

        $dbh->do(<<'END_SQL');
DROP TABLE attrs3
END_SQL
    };

    ok($ok, 'dropping an attribute table should succeed')
        or diag($dbh->errstr);

    check_tables $dbh;
}

$dbh->disconnect;<commit_msg>Remove test for extra arguments for virtual table constructor<commit_after>use strict;
use warnings;
use lib 't/lib';

use Test::More;
use SQLite::TestUtils;

check_deps;

plan tests => 4;

sub check_tables {
    my ( $dbh ) = @_;

    local $Test::Builder::Level = $Test::Builder::Level + 1;

    my @tables = $dbh->tables(undef, undef, '%', 'TABLE');

    is_deeply \@tables, [];
}

my $ok;
my $dbh = create_dbh;

NO_EXTRA_COLS: {
    $ok = do {
        local $dbh->{'RaiseError'} = 0;

        $dbh->do(<<'END_SQL');
CREATE VIRTUAL TABLE attrs1 USING attributes;
END_SQL
    };

    ok($ok, 'creating an attribute table with no additional columns should succeed')
        or diag($dbh->errstr);

    check_schema($dbh, attrs1 => {
        attributes => 1,
    });

    $ok = do {
        local $dbh->{'RaiseError'} = 0;

        $dbh->do(<<'END_SQL');
DROP TABLE attrs1
END_SQL
    };

    ok($ok, 'dropping an attribute table should succeed')
        or diag($dbh->errstr);

    check_tables $dbh;
}

$dbh->disconnect;
{'fraction_non_alphanumeric': 0.15802545793231915, 'fraction_numerical': 0.009934802856255821, 'mean_word_length': 2.70771001150748, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 42, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '615949', 'n_tokens_mistral': 1207, 'n_tokens_neox': 1151, 'n_words': 292}