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

unrecognized configuration parameter "tables" #164

Closed
c33s opened this issue Jul 2, 2012 · 9 comments
Closed

unrecognized configuration parameter "tables" #164

c33s opened this issue Jul 2, 2012 · 9 comments
Labels

Comments

@c33s
Copy link

c33s commented Jul 2, 2012

php app/console propel:table:drop --force

leads to

    [Propel] Exception caught
    SQLSTATE[42704]: Undefined object: 7 ERROR:  unrecognized configuration parameter "tables"

only found http://stackoverflow.com/questions/7367077/symfony2-how-to-make-a-pgsql-database-reverse-enginering-process-with-propelbun

config error or propel bug?

db tested: postgres, sqlite

@willdurand
Copy link

The issue here is that we run SHOW TABLES to determine tables but it doesn't work with PostgreSQL.

@c33s
Copy link
Author

c33s commented Jul 3, 2012

hmm i see,

Postgres

postgres equivalent for SHOW TABLES is

SELECT table_name FROM information_schema.tables
SELECT tablename FROM pg_catalog.pg_tables

the problem with both commands are, that they are also listing internal table schemas( pg_catalog and infromation_schema).

so you can hardcode a little bit like this:

SELECT tablename FROM pg_catalog.pg_tables WHERE schemaname='public'
SELECT table_name FROM information_schema.tables WHERE table_schema = 'public'

but then you force the user to use the public schema. how is the support of postgres schemas in propel? if there is any schema support we maybe can use it for this.

infos partly from http://stackoverflow.com/questions/769683/show-tables-in-postgresql

what also would be possible is to make something like this:

SELECT tablename FROM pg_catalog.pg_tables WHERE tableowner='my_symyony_db_user'

all the system tables are owned by the postgres user, so sleecting by my_symyony_db_user should work. also by selecting by "not" works:

SELECT tablename FROM pg_catalog.pg_tables WHERE tableowner != 'postgres'

Sqlite

for sqlite the command is (tested with sqlitemanager in firefox on windows)
SELECT name FROM sqlite_master WHERE type='table'

general command:
SELECT * FROM dbname.sqlite_master WHERE type='table';

http://stackoverflow.com/questions/82875/how-do-i-list-the-tables-in-a-sqlite-database-file

Conclusio

so if we want to fix this we have to refactor the following section https://github.com/propelorm/PropelBundle/blob/1.1/Command/TableDropCommand.php#L85

for me this is not a PropelBundle bug, but a Propel bug, because Propel, as good DBAL, should handle this.

if i use propel i just want to call xxx->getTableNames() and don't want to care how it works internally or be confronted to handle it with hacks by myself on every location i want to use show tables.

@willdurand
Copy link

Well. Does a DBAL need database introspection at runtime? I'm not sure. It's better if you focus on performance ;)

@c33s
Copy link
Author

c33s commented Jul 6, 2012

Does a DBAL need database introspection at runtime?

my answer would be yes. if i need performance i still can call plain sql. but if i simply want it to work, i would need it

@willdurand
Copy link

This feature was more an "extra" command than a really required feature. I don't plan to work on that at the moment, but we really need to find a better solution.

@c33s
Copy link
Author

c33s commented Jul 11, 2012

what do you think of having such a feature?

i think it's not that difficult to research it for all databases. propel2 maybe? where should the $xxx->getTableNames() be added? to the connection? $con->getTableNames()?

if you tell me where to add, i can have a look at it and try forging a PR

@willdurand
Copy link

Let me think about that :) Oh, and please open an issue in the Propel2 tracker as a Feature Request.

@stof
Copy link

stof commented Jul 11, 2012

@marcj
Copy link
Member

marcj commented Oct 8, 2014

We have already a parser since years that support this, although especially Postgres and SQLite is only with v2 really stable. I've no idea why MySQL is still in v2 https://github.com/propelorm/PropelBundle/blob/2.0/Command/TableDropCommand.php hardcoded down to v1. We have for all supported vendors a reverser schema parser:

$database = new Database();
$parser = new MysqlSchemaParser();
$parser = new SqliteSchemaParser();
$parser = new PgsqlSchemaParser();
$parser->setConnection($conn);
$parse->parse($database);

$tables = $database->getTables();

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

5 participants