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

Upgraded selectRelated to work like in the current Django version. #52

Merged
merged 8 commits into from Mar 7, 2018

Conversation

Projects
None yet
2 participants
@pavleb
Contributor

pavleb commented Feb 20, 2016

One can list the foreign keys to be loaded thus limiting the DB traverse. In the current version the selectRelated loaded all the foreign keys recursively, which is quite demanding for large DB structures.

Pavle Boškoski and others added some commits Feb 20, 2016

Pavle Boškoski
Upgraded selectRelated to work like in the current Django version. On…
…e can list the foreign keys to be loaded thus limiting the DB traverse

@pavleb pavleb closed this Feb 22, 2016

@pavleb pavleb reopened this Feb 22, 2016

}
QDjangoQuery query(db);
query.prepare(QString::fromLatin1("INSERT INTO %1 (%2) VALUES(%3)").arg(
query.prepare(QString::fromLatin1("INSERT INTO %1 (%2) VALUES (%3)").arg(

This comment has been minimized.

@jlaine

jlaine Aug 15, 2016

Owner

why the whitespace change?

@@ -400,11 +410,11 @@ QDjangoQuery QDjangoQuerySetPrivate::insertQuery(const QVariantMap &fields) cons
foreach (const QString &name, fields.keys()) {
const QDjangoMetaField field = metaModel.localField(name.toLatin1());
fieldColumns << db.driver()->escapeIdentifier(field.column(), QSqlDriver::FieldName);
fieldHolders << QLatin1String("?");
fieldHolders << QString::fromLatin1(":%1").arg(name);//QLatin1String("?");

This comment has been minimized.

@jlaine

jlaine Aug 15, 2016

Owner

don't keep commented code

@@ -579,10 +580,11 @@ bool QDjangoQuerySet<T>::remove()
* executes its query.
*/
template <class T>
QDjangoQuerySet<T> QDjangoQuerySet<T>::selectRelated() const
QDjangoQuerySet<T> QDjangoQuerySet<T>::selectRelated(QStringList *relatedFields) const

This comment has been minimized.

@jlaine

jlaine Aug 15, 2016

Owner

Please document the new argument, explaining how it works.

Also, why a pointer to a QStringList instead of passing by reference? This seems un-Qt.

@@ -400,7 +410,7 @@ QDjangoQuery QDjangoQuerySetPrivate::insertQuery(const QVariantMap &fields) cons
foreach (const QString &name, fields.keys()) {
const QDjangoMetaField field = metaModel.localField(name.toLatin1());
fieldColumns << db.driver()->escapeIdentifier(field.column(), QSqlDriver::FieldName);
fieldHolders << QLatin1String("?");
fieldHolders << QString::fromLatin1(":%1").arg(name);

This comment has been minimized.

@jlaine

jlaine Aug 20, 2016

Owner

Why are we touching insertQuery?

I think this change is what is causing the test build to fail

@pavleb

This comment has been minimized.

Contributor

pavleb commented Oct 10, 2016

I have added detailed example in the docs describing how the method works. Please let me know if you need anything extra.

@pavleb

This comment has been minimized.

Contributor

pavleb commented Oct 10, 2016

I hoped that the corrected .travis.yml file would fix the build problem. That is why I merged the current master in my branch. I didn't changed any of the code since the previous build. I was just adding extra explenation in the docs.

@pavleb pavleb closed this Mar 14, 2017

@pavleb pavleb reopened this Mar 14, 2017

@jlaine jlaine merged commit bda4755 into jlaine:master Mar 7, 2018

1 check passed

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