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

blob column seems broken #662

Open
1 of 3 tasks
dereuromark opened this issue Nov 21, 2023 · 3 comments
Open
1 of 3 tasks

blob column seems broken #662

dereuromark opened this issue Nov 21, 2023 · 3 comments
Labels

Comments

@dereuromark
Copy link
Member

dereuromark commented Nov 21, 2023

This is a (multiple allowed):

  • bug

  • enhancement

  • feature-discussion (RFC)

  • CakePHP Version: 5.x

What you did

Schema for testing:

'image' => ['type' => 'blob', 'length' => null, 'null' => true],

Expected Behavior

Should work for sqlite (does), but also for mysql (NO) and postgres (NO).
For the latter it would translate to bytea I assume, for mysql blob should be fine.

Actual Behavior

Error in bootstrap script: PDOException:
SQLSTATE[42601]: Syntax error: 7 ERROR:  syntax error at or near "DEFAULT"
LINE 5: "image" DEFAULT NULL,

Refs https://github.com/dereuromark/cakephp-captcha/actions/runs/6946005086

@dereuromark dereuromark added this to the 4.x (CakePHP 5) milestone Nov 21, 2023
@dereuromark
Copy link
Member Author

I also tried

'image' => ['type' => 'varbinary'],

Similar/same issue:

SQLSTATE[42601]: Syntax error: 7 ERROR: syntax error at or near ","
LINE 5: "image",

@ajibarra
Copy link
Member

ajibarra commented Dec 1, 2023

@dereuromark Could you please share your code?

I have tried with a new migration and:

$this->table('posts')
            ->addColumn('name', 'string', ['length' => 255])
            ->addColumn('description', 'string', ['length' => 255])
            ->addColumn('image', 'blob', ['length' => null, 'null' => true])
            ->create();

and it creates the field correctly. I am probably missing something but if you share your code it's better.

My versions:

cakephp/cakephp                                5.0.3   The CakePHP framework
cakephp/migrations                             4.1.1   Database Migration plugin for CakePHP based on Phinx

@dereuromark
Copy link
Member Author

The code is linked in that failing CI run
You can execute it locally by checking out master (cakephp 5) and see that it only works for SQlite apparently.
Not sure why blob doesnt seem to work for Mysql and Postgres.

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

No branches or pull requests

2 participants