Codeception / module-db

DB module for Codeception
MIT License
23 stars 24 forks source link

haveInDatabase insert value to table with 1 column #7

Open cmath10 opened 4 years ago

cmath10 commented 4 years ago

Hello! I have in my postgres DB table with 1 serial column (id) and not able to insert a row into this table in my test. I could insert a row into any other table that has more than 1 column, but not into the table that has the only id column. Is it possible, maybe with another method?

Naktibalda commented 4 years ago

Please show the line of code that you used and the error message that you got.

cmath10 commented 4 years ago
$id = $I->haveInDatabase('my_table', []);

Message was about sql syntax error, resulting sql query looked like

INSERT INTO my_table() VALUES ()

my_table has only id autoincrement column (postgres SERIAL)

Naktibalda commented 4 years ago

What exactly is a use case for inserting a row with auto increment id with no known fields?

You are welcome to make a patch and raise a pull request though.

cmath10 commented 4 years ago

What exactly is a use case for inserting a row with auto increment id with no known fields?

I have a system with multiple entities of different nature and users could leave comments to them. Comments link to these entities via the table ("commentable"), the scheme looks like: entity (commentable_id) -> commentable (id) <- comment (commentable_id). No other fields, commentable_id is the only common thing. I trying to make a test for comment creation, and this little issue blocks me (actually, I can add a column with a null value, but I'd like to not do that).

You are welcome to make a patch and raise a pull request though.

Ok, whats code of conduct and how I could set up project for dev? I tried to set up tests, but in my local installation, only DbTest & SqliteTest tests passed. Also got Call to a member function _resetConfig() on null I use docker images php:5.6-cli & postgres:10.10-alpine, db codeception_test, user postgres, no password.