Skip to content

DataFixtures error? #62

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

Closed
ioleo opened this issue Aug 8, 2014 · 2 comments · Fixed by #63
Closed

DataFixtures error? #62

ioleo opened this issue Aug 8, 2014 · 2 comments · Fixed by #63

Comments

@ioleo
Copy link

ioleo commented Aug 8, 2014

I've created a project with this bundle as a dependency.

Then I run php app/console doctrine:schema:create -> OK
Then php app/console doctrine:fixtures:load -> ERROR

[Doctrine\DBAL\DBALException]
An exception occurred while executing 'INSERT INTO elfinder_file (parent_id, name, content, size, mtime, mime, read, write, locked, hidden, width, height) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)' with params [0, "DATABASE", "", 0, 0, "directory", 1, 1, 0, 0, 0, 0]:

And below another:

SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'read, write, locked, hidden, width, height) VALUES (0, 'DATABASE', '', 0, 0, 'di' at line 1

Now, I have no idea why this does not work. I've opened MySql Workbench and run this query:

INSERT INTO prognozy_demo.elfinder_file (id, parent_id, name, content, size, mtime, mime, read, write, locked, hidden, width, height)
VALUES (1, 0, "DATABASE", "", 0, 0, "directory", 1, 1, 0, 0, 0, 0);

And it worked.

Also, I've tried commenting out the flush operation in LoadRootElement and run php app/console doctrine:fixtures:load again -> OK.

So.. it's something wrong with the ElFinderFile entity? Or the LoadRootElement fixture?

@ioleo
Copy link
Author

ioleo commented Aug 8, 2014

OK, I think it's due to column named write. WRITE is a reserved keyword in mysql. The solution is to wrap "write" in quotes.. but Doctrine should do that by default?

Mysql Reserved Words Reference

@ioleo
Copy link
Author

ioleo commented Aug 8, 2014

It seems Doctrine does not wrap these in quotes by default. see SO anwser

Both read and write are mysql reserved words. So their column names need to be wrapped in ` `` in annotations. I'll submit a PR.

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

Successfully merging a pull request may close this issue.

1 participant