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

fix for then your pSQL sequences are not standard format #3506

Merged
merged 7 commits into from Sep 13, 2016

Conversation

Projects
None yet
3 participants
@alexjeen
Contributor

alexjeen commented Sep 10, 2016

This fixed a problem when your sequences are not a standard format (ie. table_id_seq).

@Naktibalda

This comment has been minimized.

Show comment
Hide comment
@Naktibalda

Naktibalda Sep 10, 2016

Member
  1. Please convert tabs to spaces and delete that unnecessary space between [] and = in $primaryKey [] = $column['attname'];
  2. Could you add a test for non-standard sequence to https://github.com/Codeception/Codeception/blob/2.2/tests/unit/Codeception/Lib/Driver/PostgresTest.php ?
  3. Please explain the reason to change query in getPrimaryKey method. The original query was copied from https://wiki.postgresql.org/wiki/Retrieve_primary_key_columns and yours isn't. (Add test for table not supported by original query if it isn't covered by the test for non-standard sequence).
Member

Naktibalda commented Sep 10, 2016

  1. Please convert tabs to spaces and delete that unnecessary space between [] and = in $primaryKey [] = $column['attname'];
  2. Could you add a test for non-standard sequence to https://github.com/Codeception/Codeception/blob/2.2/tests/unit/Codeception/Lib/Driver/PostgresTest.php ?
  3. Please explain the reason to change query in getPrimaryKey method. The original query was copied from https://wiki.postgresql.org/wiki/Retrieve_primary_key_columns and yours isn't. (Add test for table not supported by original query if it isn't covered by the test for non-standard sequence).

alexjeen added some commits Sep 11, 2016

reverted the database query to get columns
the one i made was specific to the public schema however we set schema by query so it’s not necassery
@alexjeen

This comment has been minimized.

Show comment
Hide comment
@alexjeen

alexjeen Sep 11, 2016

Contributor

Hi there,

  1. I've let my sublime handle the PSR requirement (not in the first case because it often messed up the CodeCeption docs). I hope it's good now.
  2. I've added the test but have yet to figure out how to run it (spent an hour trying to get it to work)
  3. Your query was right, my query was based on "one schema" so I've reverted it again.
Contributor

alexjeen commented Sep 11, 2016

Hi there,

  1. I've let my sublime handle the PSR requirement (not in the first case because it often messed up the CodeCeption docs). I hope it's good now.
  2. I've added the test but have yet to figure out how to run it (spent an hour trying to get it to work)
  3. Your query was right, my query was based on "one schema" so I've reverted it again.
@Naktibalda

This comment has been minimized.

Show comment
Hide comment
@Naktibalda

Naktibalda Sep 11, 2016

Member

To run the tests you need a running postgresql daemon, schema named codeception_test
and passwordless user named postgres (or you can change credentials in PostgresTest.php file)

Run the tests using command
php codecept run tests/unit/Codeception/Lib/Driver/PostgresTest.php -vv

Member

Naktibalda commented Sep 11, 2016

To run the tests you need a running postgresql daemon, schema named codeception_test
and passwordless user named postgres (or you can change credentials in PostgresTest.php file)

Run the tests using command
php codecept run tests/unit/Codeception/Lib/Driver/PostgresTest.php -vv

@alexjeen

This comment has been minimized.

Show comment
Hide comment
@alexjeen

alexjeen Sep 12, 2016

Contributor

Alright, I've commited and pushed. All 10 tests pass.

Contributor

alexjeen commented Sep 12, 2016

Alright, I've commited and pushed. All 10 tests pass.

@@ -124,6 +124,12 @@ public function testGetEmptyArrayIfTableHasNoPrimaryKey()
$this->assertEquals([], $this->postgres->getPrimaryKey('no_pk'));
}
public function testLastInsertIdReturnsSequenceValueWhenNonStandardSequenceNameIsUsed()

This comment has been minimized.

@Naktibalda

Naktibalda Sep 13, 2016

Member

I replaced your test with a test which actually tests the change in lastInsertId.

@Naktibalda

Naktibalda Sep 13, 2016

Member

I replaced your test with a test which actually tests the change in lastInsertId.

@Naktibalda Naktibalda merged commit 02ee5b7 into Codeception:2.2 Sep 13, 2016

3 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
semaphoreci The build passed on Semaphore.
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment