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

Pgsql driver implementation (update 4) #505

Merged
merged 23 commits into from
Jun 7, 2013
Merged

Pgsql driver implementation (update 4) #505

merged 23 commits into from
Jun 7, 2013

Conversation

gevik
Copy link
Contributor

@gevik gevik commented Jun 6, 2013

Updated the suggested comments, please review again

@@ -343,6 +343,8 @@ protected function createPdoInstance()
$driver = strtolower(substr($this->dsn, 0, $pos));
if ($driver === 'mssql' || $driver === 'dblib' || $driver === 'sqlsrv') {
$pdoClass = 'yii\db\mssql\PDO';
} else if ($driver === 'pgsql') {
Copy link
Member

Choose a reason for hiding this comment

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

elseif

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Need to change, Netbeans settings :(

@qiangxue
Copy link
Member

qiangxue commented Jun 6, 2013

Do we really need the PDO class?


/**
* Returns value of the last inserted ID.
* @param string|null $sequence the sequence name. Defaults to null.
Copy link
Member

Choose a reason for hiding this comment

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

What does null mean here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If you call getLastInsertedId without inserting a record first then, this method returns null since internally postgresql returns null.

Copy link
Member

Choose a reason for hiding this comment

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

Question was about $sequence, not about return value.

@gevik
Copy link
Contributor Author

gevik commented Jun 6, 2013

The PDO class is the correct place to implement the schema switching functionality to my opinion.

}
}
if (isset($options[self::OPT_DEFAULT_SCHEMA])) {
$schema = trim($options[self::OPT_DEFAULT_SCHEMA]);
Copy link
Member

Choose a reason for hiding this comment

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

Is it possible that default schema is set to multiple spaces? If not then we can use !empty($options[self::OPT_DEFAULT_SCHEMA]) instead of isset and trim and empty string check.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This check is to make sure we have a default schema set even if the option exist with en empty value or when the option has a whitespace as a value.

@qiangxue
Copy link
Member

qiangxue commented Jun 6, 2013

It seems to me we don't really need the custom PDO class because setting search path and default schema can both be done in the afterOpen event of Connection if needed.

* @author Gevik Babakhani <gevikb@gmail.com>
* @since 2.0
*/
class QueryBuilder extends \yii\db\QueryBuilder {
Copy link
Member

Choose a reason for hiding this comment

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

{ should be at the next line

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Refactored == null to is_null == '' to empty(...)
@qiangxue
Copy link
Member

qiangxue commented Jun 6, 2013

I still don't understand why we need the custom PDO here. We don't have it in 1.1. Is there any particular problem that we need to have a custom PDO to solve?

@Ragazzo
Copy link
Contributor

Ragazzo commented Jun 6, 2013

This was in outdated diff, so maybe you did not check it:
also 3 constants (in PDO class, constants realted to search path and default schema) above must be public properties. Please also note this one #205. And in Schema class it default schema must be a property.

@gevik
Copy link
Contributor Author

gevik commented Jun 6, 2013

I have created updates as suggested in the comment.Please review again.

@gevik gevik closed this Jun 6, 2013
@gevik gevik reopened this Jun 6, 2013
@Ragazzo
Copy link
Contributor

Ragazzo commented Jun 6, 2013

I have created updates as suggested in the comment.Please review again.

still constants presents in classes, or about what comment you were talking about?

@gevik
Copy link
Contributor Author

gevik commented Jun 6, 2013

@qiangxue I was under impression that the schema changing/seeting functionality should be as low level as possible. Changing or setting database schema is something that you do only once and to my option it should be set and passed to PDO my configuration. In event of someone needing to set it manually, then they can use the PDO->setSchemaSearchPath.

Gevik Babakhani added 2 commits June 6, 2013 22:19
@qiangxue
Copy link
Member

qiangxue commented Jun 6, 2013

I think we should drop the custom PDO class. The features it adds are not available for other DBMS, and they can be accomplished via the existing Connection::afterOpen event.

@gevik
Copy link
Contributor Author

gevik commented Jun 7, 2013

Removed the custom PDO and added defaultSchema as public property. Please review

try {
$constraints = $this->db->createCommand($sql)->queryAll();
} catch (\Exception $e) {
return false;
Copy link
Member

Choose a reason for hiding this comment

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

Should not catch exceptions because it will hide the reason why the query fails.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I missed that. I have removed it. thanks.

qiangxue added a commit that referenced this pull request Jun 7, 2013
Pgsql driver implementation (update 4)
@qiangxue qiangxue merged commit 51972f2 into yiisoft:master Jun 7, 2013
@qiangxue
Copy link
Member

qiangxue commented Jun 7, 2013

Good job! Thanks!

@gevik
Copy link
Contributor Author

gevik commented Jun 8, 2013

@mark, I hope you get this message. I have looked in the comments but
could not find issues logged by you. Could you provide more info?
Perhaps I missed something.

On 6/8/13 5:10 AM, Mark wrote:

@qiangxue https://github.com/qiangxue why problems that i've
described here and in separated issue, was not fixed and i was
ignored? This problems extremely important.


Reply to this email directly or view it on GitHub
#505 (comment).

);

/**
* Creates a query builder for the MySQL database.
Copy link
Member

Choose a reason for hiding this comment

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

MySQL → PostgreSQL

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will fix

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

@Ragazzo
Copy link
Contributor

Ragazzo commented Jun 8, 2013

@gevik everythng is ok, i was a little bit lost in this big number of commits ;) sorry. Thanks for the pgsql support :)

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.

None yet

6 participants