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

added postgresql features to reset seq/check integrity #1648

Merged
merged 6 commits into from
Dec 27, 2013
Merged

added postgresql features to reset seq/check integrity #1648

merged 6 commits into from
Dec 27, 2013

Conversation

Ragazzo
Copy link
Contributor

@Ragazzo Ragazzo commented Dec 27, 2013

Added some new features for postgresql. I also raised visibility of extremely useful method findTablesNames. Since it is different per database and user can not have one sql this method is very useful. I also enabled emulating prepare as i've described in comment.
@qiangxue please review when you will have time

@Ragazzo
Copy link
Contributor Author

Ragazzo commented Dec 27, 2013

tested it locally on database with several tables, works well, but to be sure can be tested by some other developers. Later maybe will provide tests (for now i am a little bit not known how to setup database for them in fw tests).

@Ragazzo
Copy link
Contributor Author

Ragazzo commented Dec 27, 2013

related with #1646

@Ragazzo Ragazzo mentioned this pull request Dec 27, 2013
@Ragazzo
Copy link
Contributor Author

Ragazzo commented Dec 27, 2013

fixed some bugs. ready for review.

if ($table !== null && $table->sequenceName !== null) {
$sequence='"'.$table->sequenceName.'"';

if(strpos($sequence,'.')!==false)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please fix code style.

@qiangxue
Copy link
Member

Looks good to me. Please fix the coding style pointed out by @samdark and also add a line to CHANGELOG. I will then merge it. Thanks!

@Ragazzo
Copy link
Contributor Author

Ragazzo commented Dec 27, 2013

i also have small question, i've ported it from Yii1, so there was

if(strpos($sequence,'.')!==false)

and

if(strpos($tableName,'.')!==false)

to be true i dont remember when in postgresql schema can contain ., for table name in ``checkIntegrityit can be but we already specified schema in this method,is this checks needed and correct? Never saw this) Also why we$key = reset($table->primaryKey);` reset pk if it is still contain the same columns for table (this was taken from mysql query-builder of Yii2)?

@qiangxue
Copy link
Member

I'm not sure about if(strpos($sequence,'.')!==false).

For if(strpos($tableName,'.')!==false), you are right that we don't need this check in 2.0. In 1.1, we need it because findTableNames() return table names prefixed with schema names.

$key = reset($table->primaryKey) gets the first column in the primary key. What's wrong with this?

@Ragazzo
Copy link
Contributor Author

Ragazzo commented Dec 27, 2013

I'm not sure about if(strpos($sequence,'.')!==false).

ok, then will leave it for any case.

For if(strpos($tableName,'.')!==false), you are right that we don't need this check in 2.0. In 1.1, we need it because findTableNames() return table names prefixed with schema names.

right, so maybe we need to make this:

#in checkIntegrity method
$schema = $schema ? $schema : $this->db->schema->defaultSchema;

#in foreach cycle
$tableName='"'.$schema.".".$tableName.'"';

or dont needed?

$key = reset($table->primaryKey) gets the first column in the primary key. What's wrong with this?

right, my misunderstanding.

@qiangxue
Copy link
Member

Sounds good to me.

@Ragazzo
Copy link
Contributor Author

Ragazzo commented Dec 27, 2013

ok, so since `"ALTER TABLE "public"."tbl_user_profile" ENABLE TRIGGER ALL; "`` is valid in pgsql, will make changes according to the discussion and submit new push here.

@Ragazzo
Copy link
Contributor Author

Ragazzo commented Dec 27, 2013

done, ready for review.

qiangxue added a commit that referenced this pull request Dec 27, 2013
added postgresql features to reset seq/check integrity
@qiangxue qiangxue merged commit f9c5d87 into yiisoft:master Dec 27, 2013
@qiangxue
Copy link
Member

Thanks!

@Ragazzo Ragazzo deleted the postgresql_features branch December 27, 2013 20:53
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

Successfully merging this pull request may close these issues.

3 participants