Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add better ddl2cpp test coverage of column types #191

Open
christianparpart opened this issue Jan 29, 2025 · 0 comments
Open

Add better ddl2cpp test coverage of column types #191

christianparpart opened this issue Jan 29, 2025 · 0 comments

Comments

@christianparpart
Copy link
Member

This is the file i had in mind:

-- Test mapping of various SQL column types and properties to C++ types.

CREATE TABLE IF NOT EXISTS ColumnTypeTest1 (
    -- primary keys
    integerAutoincrementPK  INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,

    -- nullability
    integerNotNull          INTEGER NOT NULL,
    integerNull             INTEGER NULL,

    -- various column types
    tinyIntColumn           TINYINT NULL,
    smallIntColumn          SMALLINT NULL,
    integerColumn           INTEGER NULL,
    bigIntColumn            BIGINT NULL,
    numericColumn           NUMERIC(10, 2) NULL,
    booleanColumn           BOOLEAN NULL,
    dateColumn              DATE NULL,
    timestampColumn         TIMESTAMP NULL,
    datetimeColumn          DATETIME NULL,

    charColumn              CHAR(8) NULL,
    varcharColumn           VARCHAR(30) NULL,
    textColumn              TEXT NULL,
    blobColumn              BLOB NULL,

    binaryColumn            BINARY(16) NULL,
    varBinaryColumn         VARBINARY(16) NULL,

    -- Unicode column types
    nCharColumn             NCHAR(8) NULL,
    nVarCharColumn          NVARCHAR(30) NULL,
    nTextColumn             NTEXT NULL
);

CREATE TABLE IF NOT EXISTS ColumnTypeTest2 (
    -- primary keys
    guidPK                  GUID NOT NULL PRIMARY KEY
);

CREATE TABLE IF NOT EXISTS ColumnTypeTest3 (
    -- primary keys
    varcharPK               VARCHAR(30) NOT NULL PRIMARY KEY
);

@Yaraslaut but now I realize that this is not quite working in the way we're currently doing the tests, because this is SQL dialect dependant, and thus, we cannot run that test on every database, but only on hard-coded SQLite (as done right now).

Some column names and properties may however differ, depending on the dialect. Would it make sense to move the actual logic of ddl2cpp into the core library and then ahve a way to run the tests in C++, using the migration query builder API? 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant