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

Regression in 2.0.11 - haveInDatabase() no longer works with tables that don't have a primary key #1761

Closed
n8whnp opened this issue Mar 5, 2015 · 12 comments
Assignees
Labels
Milestone

Comments

@n8whnp
Copy link
Contributor

n8whnp commented Mar 5, 2015

After upgrading from 2.0.10.1 we noticed a number of failing tests because haveInDatabase is now throwing an exception when trying to insert data into a table without a primary key. It is now throwing the error:

Exception: Table exampletable is not valid or doesn't have no primary key

This error appears to be introduced in PR: #1727.

@DavertMik DavertMik added the Bug label Mar 6, 2015
@seggen-ibuildings
Copy link

Also, inserting data into a table with a database prefix doesn't work either. For example: $I->haveInDatabase('testdb.exampletable', array(...));

$this->driver->getPrimaryColumn($table) will fail with:
PDOException: SQLSTATE[3D000]: Invalid catalog name: 1046 No database selected

@verschoof
Copy link
Contributor

We have the same issue with a table that doesn't have a primary key.

@DavertMik DavertMik added the Db label Apr 9, 2015
@DavertMik DavertMik added this to the 2.0.13 milestone Apr 9, 2015
@akireikin
Copy link
Contributor

I have this issue with a regular table (without prefix, with pk). It seems that:

SHOW KEYS FROM category WHERE Key_name = "PRIMARY"

called from Codeception\Lib\Driver\Db::getPrimaryColumn() does not work for postgres. As a temp workaround, we can override it in Codeception\Lib\Driver\PostgreSqllike it is done for Sqlite.

Relates to #1846

@DavertMik
Copy link
Member

fixed with #1846

@n8whnp
Copy link
Contributor Author

n8whnp commented Apr 27, 2015

@DavertMik does this fix the issue with MySQL database tables that simply do not have a primary key? That was the initial report here. I don't see anything in the commit that resolves that issue.

@josh7weaver
Copy link

I am using a MySql table without a primary key and am seeing the same error mentioned above.

@vgilevich
Copy link

Same for me - still is not working for table with primary key for 2 fields.

@Naktibalda Naktibalda reopened this Aug 18, 2015
@n8whnp
Copy link
Contributor Author

n8whnp commented Aug 18, 2015

Just so we are clear since it looks like lots of different issues getting mixed together, the basic problem for us remains that we have tables w/o primary keys we need to insert data into, that is no longer possible due to the reported regression.

@Naktibalda Naktibalda modified the milestones: 2.1.3, 2.0.13 Aug 19, 2015
@Naktibalda Naktibalda self-assigned this Aug 19, 2015
@Naktibalda
Copy link
Member

Why would you have a table without a primary key?
I consider it being a database design issue.

I will implement support for multi-column primary keys,
it could be re-used to use include all data columns for tables without primary key.

PostgreSQL way: https://wiki.postgresql.org/wiki/Retrieve_primary_key_columns
Sqlite way: http://www.sqlite.org/pragma.html#pragma_table_info

@n8whnp
Copy link
Contributor Author

n8whnp commented Aug 20, 2015

@Naktibalda I work with legacy software, we are working to improve the schema, but part of that is ensuring good test coverage first ;)

Naktibalda added a commit to Naktibalda/Codeception that referenced this issue Aug 24, 2015
Naktibalda added a commit to Naktibalda/Codeception that referenced this issue Aug 24, 2015
@Naktibalda
Copy link
Member

I solved all primary key issues.

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

8 participants