10000 Shell and Doctrine · Issue #11750 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

Shell and Doctrine #11750

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
ysramirez opened this issue Aug 24, 2014 · 10 comments
Closed

Shell and Doctrine #11750

ysramirez opened this issue Aug 24, 2014 · 10 comments

Comments

@ysramirez
Copy link

This happend only in shell with php app/console all works fine

doctrine:database:drop --force [ok]
doctrine:database:create [ok]
doctrine:schema:create [bad] :-1:

[Doctrine\ORM\Tools\ToolsException]                                                                                                                                    
  Schema-Tool failed with Error 'An exception occurred while executing 'CREATE TABLE  A ... all the table utf8_unicode_ci ENGINE =   
  InnoDB    
  [Doctrine\DBAL\DBALException]                                                                                                                                          
  An exception occurred while executing 'CREATE TABLE  A ... all the table..  DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB':                                          
  SQLSTATE[3D000]: Invalid catalog name: 1046 No database selected        
  [PDOException]                                                    
  SQLSTATE[3D000]: Invalid catalog name: 1046 No database selected  
@ghost
Copy link
ghost commented Aug 24, 2014

you can't mask the table name. please print the actual output.

@sstok
Copy link
Contributor
sstok commented Aug 24, 2014

SQLSTATE[3D000]: Invalid catalog name: 1046 No database selected

Did you set a default connection?
And wasn't the way to create/update the schema doctrine:schema:update --force?

@steve-todorov
Copy link

It would be really easier for us to help you if you post your config.yml. We don't know how your settings look like, so every comment here would be a long shot in guessing.

@ysramirez
Copy link
Author

@sstok this is not a part of my project, I was testing the framework in a new instalation. Obviously this is a bug. I proved it in my project too and I had the same answer.

@steve-todorov the config.yml is the default.

@jrobeson

  [Doctrine\ORM\Tools\ToolsException]                                                                                                         
  Schema-Tool failed with Error 'An exception occurred while executing 'CREATE TABLE Firsttable (id INT AUTO_INCREMENT NOT NULL, name VARCHA  
  R(255) NOT NULL, lastname VARCHAR(255) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB':      
  SQLSTATE[3D000]: Invalid catalog name: 1046 No database selected' while executing DDL: CREATE TABLE Firsttable (id INT AUTO_INCREMENT NOT   
  NULL, name VARCHAR(255) NOT NULL, lastname VARCHAR(255) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGI  
  NE = InnoDB     
[Doctrine\DBAL\DBALException]                                                                                                               
  An exception occurred while executing 'CREATE TABLE Firsttable (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(255) NOT NULL, lastname VARCH  
  AR(255) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB':                                     
  SQLSTATE[3D000]: Invalid catalog name: 1046 No database selected                       
  [PDOException]                                                    
  SQLSTATE[3D000]: Invalid catalog name: 1046 No database selected

@weaverryan
Copy link
Member

@ysramirez Hmm, googling around, it looks like this issue is usually something wrong with the PDO connection string (which you don't handle directly obviously, Doctrine does that). Could you post what your parameters.yml file looks like and the doctrine section of config.yml? I know you said that config.yml is the default, but if you can post the doctrine section only just in case, that would help rule some things out :).

Cheers!

@stof
Copy link
Member
stof commented Aug 25, 2014

This is because when running the shell, all commands run in the same process, without restarting the kernel between each of them, meaning the same DB connection is kept. doctrine:database:create connect to the DB without specifying a table name (because it does not exist yet) and then the next command reuses the same connection, which breaks.

In general, using the shell is very likely to create weird issues because of the way it run commands (the worse being to try to clear the cache this way). You should either avoid the shell entirely, or run it with the --process-isolation option to at least run each command in their own process (cache:clear will still not work fine in the shell, but all other commands are likely to work)

@ysramirez
Copy link
Author

Hello @weaverryan and @stof, now the question is how to fix it. Honestly I don't use the shell so much but could be an interesting tool without these problems for many reasons for example @javiereguiluz talked about the php -S in the background and this is other trouble whit the process. If we had a solid library to drive it could be great. (I saw some code of all of you in these conversation, you are great coders)

@stof
Copy link
Member
stof commented Aug 25, 2014

I don't see any way to fix the shell running without process isolation. As long as you run all commands in the same process, you will face potentially issues with side effects between commands. The --process-isolation option helps, but there is still the issue that a command could alter the app and the shell process does not reload it (which is why clearing the cache in the shell will create some issue)

@fabpot
Copy link
Member
fabpot commented Aug 26, 2014

I propose to close this issue as a "won't fix". As explained by @stof, the shell has some bad side-effects and as it does not enhance the dev experience that much, I propose to remove it in 3.0 (and to deprecate it in 2.6). I've just added a note in #11742.

@mayeco
Copy link
Contributor
mayeco commented Nov 4, 2014

I use the shell 2 or 3 times and notice very weird behavior with the database, a notice will be nice.

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

No branches or pull requests

7 participants
0