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

sqlite id bigint #6396

Open
remco-pc opened this issue May 14, 2024 · 4 comments
Open

sqlite id bigint #6396

remco-pc opened this issue May 14, 2024 · 4 comments

Comments

@remco-pc
Copy link

Bug Report

Q A
Version 4.0.2

Summary

when doing a column lookup throught:

$tables = Table::all($object, $name, $environment);
        $sanitized_table = preg_replace('/[^a-zA-Z0-9_]/', '', $options->table);
        if (in_array($sanitized_table, $tables, true)) {
            $columns = $schema_manager->listTableColumns($sanitized_table);
            if($columns){
                $list = [];
                foreach($columns as $column){
                    $record = $column->toArray();
                    $record['type'] = File::basename(get_class($column->getType()));
                    $list[]= $record;
                }
                return $list;
            }
        }

i get an array of columns.
But the id column which is defined as a bigint is turning into an integer. if i disable autoincrement it is threated as an bigint.
So when a bigint column has an autoincrement=true it will become an integer in sqlite.

Current behaviour

The bigint becomes silently an integer without noticing the builder

Expected behaviour

the id column should become a bigint with autoincrement=true

@derrabus
Copy link
Member

Please try to reproduce your issue using only DBAL APIs.

@remco-pc
Copy link
Author

remco-pc commented May 15, 2024

When using doctrine schema manager i get an array of data describing the column definition of a sqlite db file. ($schema_manager->listTableColumns($sanitized_table))

When using a combination of bigint with auto increment it is of integer type. When i remove the auto increment, it becomes a bigint.

[
    {
        "name": "id",
        "type": "IntegerType",
        "default": null,
        "notnull": true,
        "length": null,
        "precision": null,
        "scale": 0,
        "fixed": false,
        "unsigned": false,
        "autoincrement": true,
        "columnDefinition": null,
        "comment": ""
    },
...

also i needed to do this:

$record = $column->toArray();
$record['type'] = File::basename(get_class($column->getType()));

the type doesnt have a to string defined which should and be the same as in the schema/ entitiy defined so we can validate the creation of the table

the unsigned is false where it should be true, because of the autoincrement.

{
        "name": "id",
        "type": "BigIntType",
        "default": null,
        "notnull": true,
        "length": null,
        "precision": null,
        "scale": 0,
        "fixed": false,
        "unsigned": true,
        "autoincrement": false,
        "columnDefinition": null,
        "comment": ""
    },

@remco-pc
Copy link
Author

@derrabus its $schema_manager->listTableColumns($stable); should the type not be casted to string ?

@mvorisek
Copy link
Contributor

mvorisek commented May 31, 2024

Here #6411 is a PR with fix and test.

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

3 participants