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

haveInDatabase insert value to table with 1 column #7

Open
cmath10 opened this issue Apr 9, 2020 · 4 comments
Open

haveInDatabase insert value to table with 1 column #7

cmath10 opened this issue Apr 9, 2020 · 4 comments

Comments

@cmath10
Copy link

cmath10 commented Apr 9, 2020

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
Copy link
Member

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

@cmath10
Copy link
Author

cmath10 commented Apr 13, 2020

$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
Copy link
Member

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
Copy link
Author

cmath10 commented Apr 13, 2020

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.

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

2 participants